Mixedbread

Create a Chat Completion

POST/v1/chat/completions

Authorization

Authorizationstringrequired

Your Mixedbread API key as a bearer token. Format: `Bearer YOUR_API_KEY`.

Request Body

modelstringdefault: toast-1

Public model ID.

tool_choicestring | objectdefault: auto

Controls 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`.

max_tool_callsinteger | nulldefault: 16

Maximum server-executed tool calls (hosted tools and `prune_context`) for this completion. Ignored when none are declared.

Constraints

Minimum: 1
includearray | null

Extra fields to include on hosted call items, e.g. `search_corpus_call.results`. Unsupported values are ignored.

storebooleandefault: true

Persist the completion so it can be retrieved and continued later. Set to `false` to prevent completion content from being stored for later retrieval.

previous_completion_idstring | null

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.

streambooleandefault: false

Return the completion as server-sent events.

temperaturenumber | null
top_pnumber | null
max_completion_tokensinteger | null

Maximum tokens to generate for the completion.

Constraints

Minimum: 16
max_tokensinteger | null

Alias for `max_completion_tokens`; used only when `max_completion_tokens` is absent.

Constraints

Minimum: 16
parallel_tool_callsbooleandefault: true

Allow the model to request function tools in parallel.

metadataobject | null

Up to 16 string key-value pairs. Keys may contain up to 64 characters and values up to 512 characters.

Response Body

idstringrequired

Unique completion ID, prefixed with `chatcmpl_`.

objectstringrequireddefault: chat.completion
createdintegerrequired

Unix timestamp when the completion was created.

modelstringrequired

The stable public model ID, `toast-1`.

hosted_tool_callsarray | null

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.

metadataobject | null

Metadata copied from the request.

titlestring | null

Short display title for the stored conversation.

Request
POST/v1/chat/completions
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)
Response
JSON
{
  "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?"
}