API reference
This page lists each endpoint of the inference API and its parameters. The source is the contract contracts/openapi/inference.yaml. The Control API, for deployments and account tasks, is in the CLI and the dashboard.
Base URL and authentication#
Send each request to the API URL of your region, with the header Authorization: Bearer <key>. The key must have the scope inference. All bodies are JSON.
Endpoints#
| Method and path | Use | Body limit |
|---|---|---|
POST /v1/chat/completions | Chat with a model. | 10 MiB |
POST /v1/completions | Complete a text prompt. | 10 MiB |
POST /v1/embeddings | Make vectors from text. | 10 MiB |
POST /v1/messages | Anthropic Messages format, shared models only. | 10 MiB |
GET /v1/models | List the shared models and your deployments. | — |
POST /v1/predict/{deployment_id} | Send any JSON to a custom container. | 50 MiB |
POST /v1/chat/completions#
| Field | Type | Required | Limits |
|---|---|---|---|
model | string | Yes | 1 to 128 characters |
messages | array | Yes | 1 to 2,048 messages |
max_tokens | integer | No | 1 to 131,072 |
max_completion_tokens | integer | No | 1 to 131,072 |
temperature | number | No | 0 to 2 |
top_p | number | No | 0 to 1 |
n | integer | No | 1 to 8 |
stop | string or array | No | Up to 4 strings of 64 characters |
stream | boolean | No | — |
stream_options.include_usage | boolean | No | — |
presence_penalty | number | No | −2 to 2 |
frequency_penalty | number | No | −2 to 2 |
seed | integer | No | — |
response_format | object | No | — |
tools | array | No | Up to 128 tools |
tool_choice | string or object | No | — |
prompt_cache_key | string | No | 1 to 256 characters |
prompt_cache_retention | string | No | 1h, shared models only |
user | string | No | Accepted and not stored |
A message has role (system, user, assistant or tool) and content. The content is a string or a list of up to 64 parts. See Chat completions for examples.
POST /v1/completions#
| Field | Type | Required | Limits |
|---|---|---|---|
model | string | Yes | 1 to 128 characters |
prompt | string or array | Yes | Up to 64 prompts |
max_tokens | integer | No | 1 to 131,072 |
temperature | number | No | 0 to 2 |
top_p | number | No | 0 to 1 |
stop | string or array | No | Up to 4 strings |
stream | boolean | No | — |
seed | integer | No | — |
prompt_cache_key | string | No | 1 to 256 characters |
POST /v1/embeddings#
| Field | Type | Required | Limits |
|---|---|---|---|
model | string | Yes | 1 to 128 characters |
input | string or array | Yes | Up to 2,048 strings of 200,000 characters |
encoding_format | string | No | float or base64 |
dimensions | integer | No | 1 to 8,192 |
POST /v1/messages#
The Anthropic Messages format for shared models. The key can be in x-api-key or in Authorization. Errors have the Anthropic shape. See Anthropic Messages API.
GET /v1/models#
Returns the shared models and the deployments of your organization. Use an id from this list as model.
POST /v1/predict/{deployment_id}#
Sends the JSON body to the custom container of a deployment without change. The response is the response of the container. The body can have up to 50 MiB.
Response headers#
| Header | Endpoints | Meaning |
|---|---|---|
X-Request-Id | All | The ID of the request. |
X-Ember-Region | Chat, messages | The region that answered. |
X-Ember-Cold-Start-Ms | Chat | The time that a cold start added. |
X-Ember-Cost-Micro-Usd | Chat, completions, embeddings, messages | The cost of a shared-model request without streaming. |
X-RateLimit-* | All | The rate limits. See Rate limits and errors. |
Errors#
Errors have the body {"error": {"code": "...", "message": "...", "request_id": "..."}}. Rate limits and errors lists each code.