On this page

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 pathUseBody limit
POST /v1/chat/completionsChat with a model.10 MiB
POST /v1/completionsComplete a text prompt.10 MiB
POST /v1/embeddingsMake vectors from text.10 MiB
POST /v1/messagesAnthropic Messages format, shared models only.10 MiB
GET /v1/modelsList the shared models and your deployments.—
POST /v1/predict/{deployment_id}Send any JSON to a custom container.50 MiB

POST /v1/chat/completions#

FieldTypeRequiredLimits
modelstringYes1 to 128 characters
messagesarrayYes1 to 2,048 messages
max_tokensintegerNo1 to 131,072
max_completion_tokensintegerNo1 to 131,072
temperaturenumberNo0 to 2
top_pnumberNo0 to 1
nintegerNo1 to 8
stopstring or arrayNoUp to 4 strings of 64 characters
streambooleanNo—
stream_options.include_usagebooleanNo—
presence_penaltynumberNo−2 to 2
frequency_penaltynumberNo−2 to 2
seedintegerNo—
response_formatobjectNo—
toolsarrayNoUp to 128 tools
tool_choicestring or objectNo—
prompt_cache_keystringNo1 to 256 characters
prompt_cache_retentionstringNo1h, shared models only
userstringNoAccepted 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#

FieldTypeRequiredLimits
modelstringYes1 to 128 characters
promptstring or arrayYesUp to 64 prompts
max_tokensintegerNo1 to 131,072
temperaturenumberNo0 to 2
top_pnumberNo0 to 1
stopstring or arrayNoUp to 4 strings
streambooleanNo—
seedintegerNo—
prompt_cache_keystringNo1 to 256 characters

POST /v1/embeddings#

FieldTypeRequiredLimits
modelstringYes1 to 128 characters
inputstring or arrayYesUp to 2,048 strings of 200,000 characters
encoding_formatstringNofloat or base64
dimensionsintegerNo1 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#

HeaderEndpointsMeaning
X-Request-IdAllThe ID of the request.
X-Ember-RegionChat, messagesThe region that answered.
X-Ember-Cold-Start-MsChatThe time that a cold start added.
X-Ember-Cost-Micro-UsdChat, completions, embeddings, messagesThe cost of a shared-model request without streaming.
X-RateLimit-*AllThe rate limits. See Rate limits and errors.

Errors#

Errors have the body {"error": {"code": "...", "message": "...", "request_id": "..."}}. Rate limits and errors lists each code.