Create a Chat Completion
POST/v1/chat/completions
Authorization
Your Mixedbread API key as a bearer token. Format: `Bearer YOUR_API_KEY`.
Request Body
toast-1Public model ID.
autoControls tool selection. Use `auto`, `none`, `required`, or force a named function or hosted tool. With hosted tools it applies to the first model turn; later turns of the server loop use `auto`.
16Maximum server-executed tool calls (hosted tools and `prune_context`) for this completion. Ignored when none are declared.
Constraints
Extra fields to include on hosted call items, e.g. `search_corpus_call.results`. Unsupported values are ignored.
truePersist the completion so it can be retrieved and continued later. Set to `false` to prevent completion content from being stored for later retrieval.
ID of a stored completion this turn continues. Groups turns into one conversation and restores its prior model context, hosted tool calls and server-side context edits included.
falseReturn the completion as server-sent events.
Maximum tokens to generate for the completion.
Constraints
Alias for `max_completion_tokens`; used only when `max_completion_tokens` is absent.
Constraints
trueAllow the model to request function tools in parallel.
Up to 16 string key-value pairs. Keys may contain up to 64 characters and values up to 512 characters.
Response Body
Unique completion ID, prefixed with `chatcmpl_`.
chat.completionUnix timestamp when the completion was created.
The stable public model ID, `toast-1`.
Server-executed tool calls of a hosted run, in execution order. Each item carries its call `type` (e.g. `search_corpus_call`), `id`, `status`, an `error` when it failed, and the call's arguments echoed as fields named for the tool (`queries` for a search, `pattern` for a grep); chunk `results` ride along only for requested `include` keys.
Metadata copied from the request.
Short display title for the stored conversation.
from openai import OpenAI
client = OpenAI(
base_url="https://api.mixedbread.com/v1",
api_key="YOUR_API_KEY",
)
completion = client.chat.completions.create(
model="toast-1",
messages=[
{
"role": "user",
"content": "What is a search agent?",
}
],
)
print(completion.choices[0].message.content){
"id": "chatcmpl_abc123",
"object": "chat.completion",
"created": 1786622400,
"model": "toast-1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A search agent plans queries, gathers evidence with tools, and synthesizes an answer.",
"tool_calls": null,
"reasoning_content": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 19,
"total_tokens": 34
},
"metadata": null,
"title": "What is a search agent?"
}