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 | Run the same operation from a terminal or shell script. |
Create a workspace-scoped API key
Keep keys on the server side and out of browser code, logs, and source control.
- Open the API key creation form
Select the workspace you want to use. Open API keys, start creating a secret key, and give it a name such as
first-api-request. - Choose the scope and permissions
Set the scope to the current workspace, select the read-only key type, and create the key.
- 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.
terminalread -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.
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/modelsA successful request prints the following status.
HTTP 200In the file, data.models contains model IDs, names, capabilities, and pricing. See the list image models response for the fields.
Make the same request with the CLI
- Install the Orchestor CLI
Run this command on macOS or Linux. For Windows, see CLI installation.
terminalcurl -fsSL https://orchestor.io/install | sh - 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.terminalorc 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 and Rate limits.
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.
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 to generate an image and fetch its result. See idempotency keys, polling, and webhooks 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.