Skip to content

Chat Completions

http
POST /v1/chat/completions
Authorization: Bearer sk-tbl-<your-key>
Content-Type: application/json

Request and response shapes follow the OpenAI Chat Completions API. Unknown OpenAI fields are accepted and ignored. TAIBLES-specific options live under a top-level taibles object (via the SDK extra_body mechanism where applicable).

Request body

FieldRequiredDescription
modelyesAgent id (default-assistant, slug, UUID) or chat LLM URL — see Agents and models
messagesyesNon-empty array of chat messages. The last message must have role user or tool
streamnoIf true, respond with Server-Sent Events
toolsnoOpenAI-style tool definitions for client-executed tools
tool_choicenoAccepted for compatibility
temperature, top_p, max_tokens, max_completion_tokens, stop, usernoAccepted for compatibility where applicable
taiblesnoTAIBLES extensions (see below)

Messages

Standard roles (system, user, assistant, tool) are supported. Content may be a string or OpenAI-style multipart content; text is taken from the message for the agent turn.

If you omit taibles.conversation_id, TAIBLES creates a new conversation and seeds server-side history from the messages before the final turn. The final user/tool turn is submitted as the new message.

Streaming

Set "stream": true. The response is text/event-stream with OpenAI-style chunks, ending with data: [DONE]. Mid-stream failures are emitted as an OpenAI-style error event instead of a silent close.

Client-executed tools

Pass OpenAI tools (function definitions). When the agent needs a client-side tool, the completion finishes with finish_reason: "tool_calls" and assistant tool_calls in the message (or streaming deltas). Send tool results back as role: "tool" messages (last message(s) must be tool results) to continue the turn.

Server-side agent tools (integrations, knowledge, automations, and so on) run inside TAIBLES and do not require this loop.

TAIBLES extensions

Send via top-level taibles (Python/JS SDKs: extra_body={"taibles": {...}}).

FieldDescription
conversation_idUUID of an existing conversation for server-side continuity. Must be a valid UUID if set. Omit to start a new conversation.
builtin_toolsOptional list of builtin tool categories the assistant may use: memory, files, actions, automations. Omit or null → all categories allowed.

Example:

json
{
  "model": "default-assistant",
  "messages": [{"role": "user", "content": "Remember that our Q3 kickoff is Monday."}],
  "taibles": {
    "conversation_id": "01234567-89ab-cdef-0123-456789abcdef",
    "builtin_tools": ["memory", "files"]
  }
}

Python:

python
completion = client.chat.completions.create(
    model="default-assistant",
    messages=[{"role": "user", "content": "Continue where we left off."}],
    extra_body={
        "taibles": {
            "conversation_id": conversation_id,
        }
    },
)

Response

Non-streaming responses are OpenAI chat.completion objects. Streaming responses are chat.completion.chunk events.

Conversation id

Every successful completion exposes the conversation id so you can continue server-side:

  • Response header: X-Taibles-Conversation-Id
  • Body field: taibles.conversation_id (also present on the final streaming chunk)

Echo that value back as taibles.conversation_id on the next request to keep state on the server.

Finish reasons

ValueMeaning
stopNormal completion
tool_callsAssistant requested client-executed tools

Errors

Errors use an OpenAI-style envelope. Common cases:

HTTPType / codeWhen
400invalid_request_errorInvalid body, empty messages, bad conversation_id, agent without chat support
401 / 403auth errorsMissing or invalid API key
404invalid_request_error / model_not_foundUnknown model
429rate_limit_error / rate_limit_exceededRate limited

Built with VitePress