Skip to Content
Asteria Docs
Chat & Discovery

Chat Completions

OpenAI-compatible chat completions endpoint. Supports both streaming (SSE) and non-streaming responses. **Routing modes**, controlled by the `model` + `agent` fields: - **Gateway mode** (`agent` omitted): pure LLM proxy, no system prompt and none of our tools. Rate limiting and budget enforcement still apply. Your own function tools work here: send `tools` (and optionally `tool_choice`), run the `message.tool_calls` you get back, and send each result as a `role: "tool"` message. Any agent framework that speaks Chat Completions works this way. - **Orchestrator mode** (`agent: "asteria"`): full Asteria agent with RAG, web search, code execution, and sub-agents. Its tools are ours, so a non-empty `tools`, a forcing `tool_choice`, and tool messages are refused. - **Custom agent mode** (`agent: "<slug>"`): invoke a shared custom agent by slug. The agent's system prompt and tools are applied. **Which model**: send `model: "default"` to use the organization's default chat model and its fallback chain, which is the robust choice, because a pinned model id can be removed by an org admin later and start returning `400`. Omitting the field entirely does the same thing, but most OpenAI-compatible clients cannot omit it, so `"default"` is the reachable form (GH #1329). **This endpoint is stateless.** Nothing is retained between calls, exactly as with OpenAI Chat Completions: send the conversation back in `messages`. State lives in `POST /v1/responses`. A `store` parameter is accepted for compatibility and does nothing. It creates no thread, and it does not retain the completion either, since there is no `GET /v1/chat/completions/{id}` to read one back from. Setting it is harmless, but keep your own copy of the response. The one exception is `thread_id`, an Asteria extension: pass one returned by an earlier call and the request runs inside that conversation, which is what the conversation-scoped tools need. Without it the orchestrator simply does not offer them, rather than offering tools that would refuse: - `scratchpad_*` and `measure_*`, which are keyed on a conversation. - `sandbox_start` / `sandbox_check` / `sandbox_stop`. A background job is delivered into a conversation after the turn ends. `sandbox_run` answers inside the turn and is always available. - `add_to_user_bio` and `search_past_conversations`. An API key is an organisation, not a person, so these are never available here. Everything else works either way, including the sandbox workspace: files that `fetch_url` or `crawl_site` bring in are visible to `sandbox_run` within the same request. Without a `thread_id` that workspace is discarded when the response completes, so nothing carries to the next call. **Non-standard parameters need `extra_body`.** `agent`, `thread_id`, `collection_uuid`, `enable_fallback` and `include_org_context` are ours, and an OpenAI SDK builds typed request params, so passing one as a keyword is a client-side `TypeError` that never reaches us. In `openai-python`: ```python client.chat.completions.create( model="default", messages=[{"role": "user", "content": "Hello"}], extra_body={"agent": "asteria", "thread_id": thread_id}, ) ```

POST
/v1/chat/completions

Authorization

ApiKey
headerAuthorization<token>

Your API key (sk-ast-...)

Request Body

application/json
  1. body

Request body for /v1/chat/completions.

model?|

LLM model ID (e.g. 'claude-opus-4-6'), or "default" for the organization's default chat model and its fallback chain. Omitting the field does the same thing, but most OpenAI-compatible clients cannot omit it. Pinning a real model id is brittle: an org admin can later remove it, breaking your calls.

agent?|

Agent slug or 'asteria'. Omit for gateway mode. Non-standard: send via extra_body={'agent': 'asteria'}.

enable_fallback?Enable Fallback

Opt-in fallback chain if primary model fails. Non-standard: send via extra_body={'enable_fallback': true}.

Defaultfalse
include_org_context?Include Org Context

Agent mode only: give the agent your organization's system instructions and context, as in the web app. Set false to send neither. Ignored in gateway mode. Non-standard: send via extra_body={'include_org_context': false}.

Defaulttrue
messages*array<>

List of messages in the conversation

Items1 <= items <= 200
stream?Stream

Enable server-sent events streaming

Defaultfalse
max_tokens?|

Maximum tokens to generate

temperature?|

Sampling temperature (0 = deterministic, 2 = creative)

top_p?|

Nucleus sampling threshold

frequency_penalty?|

Accepted for compatibility, not used

presence_penalty?|

Accepted for compatibility, not used

stop?|array<string>|

Stop sequence or sequences. Applied across all provider families; a single string is normalized to one sequence.

store?|

Accepted for compatibility, not used

reasoning_effort?|

How much the model reasons before answering. Omit it to use the level your organization set for the model. Overrides temperature on Anthropic models.

tools?array<>|

Functions the model may call, in gateway mode. The model's calls come back in message.tool_calls for your code to run; send each result back as a role: tool message. Refused in agent mode, where the agent's tools are ours.

tool_choice?||

auto, none, required, or one named function. Gateway mode only.

collection_uuid?|

Document collection UUID for RAG queries. Non-standard: send via extra_body={'collection_uuid': ...}.

thread_id?|

Resume an existing conversation created by this API. Chat Completions is otherwise stateless: omit this and no conversation is created, which is the drop-in behaviour. Tools that need a conversation (scratchpad, measures, background sandbox jobs) are unavailable without it. Non-standard: send via extra_body={'thread_id': ...}.

Response Body

Chat completion response (non-streaming)

application/json
  1. response

Response for non-streaming /v1/chat/completions.

id?Id
object?Object
Default"chat.completion"
created?Created
model?Model
Default"asteria"
choices*array<>
usage?

Token usage statistics.

thread_id?string|null
Example Request
curl -X POST 'https://api.asteria-labs.com/v1/chat/completions' \  -H 'Content-Type: application/json' \  -d '{  "messages": [    {      "role": "system"    }  ]}'
Example Response
{  "id": "string",  "object": "chat.completion",  "created": 0,  "model": "asteria",  "choices": [    {      "index": 0,      "message": {        "role": "system",        "content": "string",        "name": "string",        "tool_calls": [          {            "id": "string",            "type": "function",            "function": {              "name": "string",              "arguments": ""            }          }        ],        "tool_call_id": "string"      },      "finish_reason": "stop"    }  ],  "usage": {    "prompt_tokens": 0,    "completion_tokens": 0,    "total_tokens": 0  },  "thread_id": "string"}