---
title: Make your first Orchestor API request
description: List image models with curl and the Orchestor CLI.
canonical_url: https://orchestor.io/docs/en/rest-api/getting-started
markdown_url: https://orchestor.io/docs/en/rest-api/getting-started.md
related:
  - https://orchestor.io/docs/cli
  - https://orchestor.io/docs/rest-api/endpoint-reference/models/get-list-image-models
  - https://orchestor.io/docs/cli/installation
  - https://orchestor.io/docs/errors
  - https://orchestor.io/docs/concepts/rate-limits
contentType: guide
---

# Make your first Orchestor API request

Use curl to list image models from the Orchestor API, then repeat the request with the CLI. This read-only request leaves workspace data and credits intact.

## Prerequisites

- An Orchestor workspace where you can create an API key
- Bash or Zsh and curl 7.76.0 or later for `--fail-with-body`

## Choose REST or the CLI

| Approach | When to use it |
| --- | --- |
| REST API with curl | Send the HTTP request directly and inspect the status and response body. |
| [Orchestor CLI](https://orchestor.io/docs/cli.md) | Run the same operation from a terminal or shell script. |

## Create a workspace-scoped API key

> **API keys are secrets**
> 
> Keep keys on the server side and out of browser code, logs, and source control.

1. **Open the API key creation form**
   Select the workspace you want to use. Open [API keys](https://platform.orchestor.io/api-keys), start creating a secret key, and give it a name such as `first-api-request`.
2. **Choose the scope and permissions**
   Set the scope to the current workspace, select the read-only key type, and create the key.
3. **Load the key into your shell**
   Run this command, paste the key shown when you created it, and press Enter. The shell hides your input.

   ```bash title="terminal"
   read -rs ORCHESTOR_API_KEY && export ORCHESTOR_API_KEY
   ```

## Make a request with curl

Use the same shell to list image models. Curl prints the HTTP status and saves the response body to `image-models.json` and the headers to `image-models.headers`.

```bash title="terminal"
curl --fail-with-body --silent --show-error \
  --output image-models.json \
  --dump-header image-models.headers \
  --write-out "HTTP %{http_code}\n" \
  --header "Authorization: Bearer $ORCHESTOR_API_KEY" \
  https://api.orchestor.io/v1/image-router/models
```

A successful request prints the following status.

```text title="terminal"
HTTP 200
```

In the file, `data.models` contains model IDs, names, capabilities, and pricing. See the [list image models response](https://orchestor.io/docs/rest-api/endpoint-reference/models/get-list-image-models.md) for the fields.

## Make the same request with the CLI

1. **Install the Orchestor CLI**
   Run this command on macOS or Linux. For Windows, see [CLI installation](https://orchestor.io/docs/cli/installation.md).

   ```bash title="terminal"
   curl -fsSL https://orchestor.io/install | sh
   ```
2. **List image models**
   Run this in the shell where you set `ORCHESTOR_API_KEY`. The CLI uses the same key and prints the model list as JSON.

   ```bash title="terminal"
   orc image models list --json
   ```

## Understand API key scope

| Setting | What it means for this key |
| --- | --- |
| Workspace | The key belongs to the workspace you selected when you created it. |
| Permissions | The key can read public API resources. Image generation requires write access. |
| `X-Workspace-ID` | You can omit this header for the request above. If you send it, use the workspace ID bound to your key. |

## Handle common 401, 403, and 429 responses

Check `error.code` in the response body that curl saved.

| Status | Cause | What to check |
| --- | --- | --- |
| `401` | The key is missing or invalid (`auth_required`), or you sent both authentication headers. | Check `ORCHESTOR_API_KEY`. Send either `Authorization: Bearer` or `x-api-key`. |
| `403` | `workspace_mismatch`. The requested workspace differs from the one bound to the key. | Remove `X-Workspace-ID` or use a key for the requested workspace. |
| `429` | `rate_limit_exceeded`. The API key has reached its request limit. | Wait the number of seconds in `Retry-After` before retrying. |

For other errors and retry guidance, see [Errors and retries](https://orchestor.io/docs/errors.md) and [Rate limits](https://orchestor.io/docs/concepts/rate-limits.md).

## Preview an image generation request

Image generation requires a key with write access and spends workspace balance. An asynchronous request uses the following method, headers, and JSON body.

```http title="terminal"
POST /v1/image-router/generate
Authorization: Bearer <API_KEY>
Content-Type: application/json
Idempotency-Key: <UNIQUE_KEY>

{"model":"gpt-image-2","prompt":"A ceramic vase on a table in morning light","mode":"async"}
```

The acceptance response includes `data.job.id`, `data.status_url`, and `data.result_url`. Poll `GET /v1/jobs/{id}/status` at the returned interval. When the status is `COMPLETED` and `result_ready` is `true`, fetch `GET /v1/jobs/{id}/result`. Stop polling if the job fails or is canceled.

Follow the [quickstart](https://orchestor.io/docs/quickstart.md) to generate an image and fetch its result. See [idempotency keys](https://orchestor.io/docs/concepts/idempotency.md), [polling](https://orchestor.io/docs/concepts/polling.md), and [webhooks](https://orchestor.io/docs/webhooks.md) for retry and completion handling.

## What you learned

You can use a workspace-scoped, read-only key to list image models with curl or the CLI. When you move on to generation, use the model IDs and capabilities from the list to build your request.

## Explore the reference

- [REST API overview](https://orchestor.io/docs/rest-api.md)
- [Get job status](https://orchestor.io/docs/rest-api/requests/get-request-status.md)
- [Orchestor MCP](https://orchestor.io/docs/mcp.md)

---

- [Documentation index](https://orchestor.io/docs/llms.txt)
- [Documentation sitemap](https://orchestor.io/docs/sitemap.md)
