A first completion against https://api.ambient.xyz/v1 takes a key and one
request. The API is OpenAI-compatible, so an existing client only needs a
new base URL and key.
Get an API key#
Create a key at app.ambient.xyz/keys. Requests authenticate with a standard bearer header:
Authorization: Bearer $AMBIENT_API_KEYThe model catalog endpoint requires no authentication, so you can browse the network before you have a key:
curl https://api.ambient.xyz/v1/modelsMake your first request#
The examples use
ambient/large, an Ambient-managed model alias. Any model id fromGET /v1/modelsworks, provided itsis_readyflag istrue.curl https://api.ambient.xyz/v1/chat/completions \ -H "Authorization: Bearer $AMBIENT_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "ambient/large", "messages": [ {"role": "user", "content": "Say hello from Ambient."} ], "max_tokens": 512 }'max_tokensis 512 because it caps reasoning and answer combined. Reasoning models can spend a small budget entirely on thinking and returnnullcontent.If the request returns
429with a message like"No workers available", the model has no miners serving it right now. Pick another model whoseis_readyistrue, and see Errors and retries.What you got back#
The body is a standard OpenAI-style chat completion:
Field What it is idCompletion id ( chatcmpl-…)choices[0].message.contentThe answer text choices[0].message.reasoningThe model's thinking trace, when the model exposes one (some models use reasoning_content)choices[0].finish_reasonstopfor a clean finish;lengthmeans the token budget ran outusageToken counts, including completion_tokens_details.reasoning_tokensEvery inference also returns an
inference-idresponse header, a stable identifier for the request (also visible asx-request-idand embedded in the completionid). Log it: it is the handle for the request on the network.Next steps#
- Models and readiness covers the catalog, pricing
from the API, and how
is_readyworks. - Streaming explains SSE chunks and how reasoning deltas differ from content deltas.
- Errors and retries is the full error taxonomy.
- Verified inference documents the verification request flags and their current status.
- The OpenAI SDK and Anthropic SDK guides cover full SDK setup.
- Models and readiness covers the catalog, pricing
from the API, and how