API reference

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

ApproachWhen to use it
REST API with curlSend the HTTP request directly and inspect the status and response body.
Orchestor CLIRun 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, 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.

    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.

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.

terminal
HTTP 200

In 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

  1. Install the Orchestor CLI

    Run this command on macOS or Linux. For Windows, see CLI installation.

    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.

    terminal
    orc image models list --json

Understand API key scope

SettingWhat it means for this key
WorkspaceThe key belongs to the workspace you selected when you created it.
PermissionsThe key can read public API resources. Image generation requires write access.
X-Workspace-IDYou 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.

StatusCauseWhat to check
401The 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.
403workspace_mismatch. The requested workspace differs from the one bound to the key.Remove X-Workspace-ID or use a key for the requested workspace.
429rate_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.

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 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.

Explore the reference