Skip to main content

Chats

LLM completions with optional persistent configuration, supporting both stateless and per-chat modes.

Overview

Chats provide two ways to call the completions API:

  • Stateless (POST /chats/completions) — pass the full provider configuration on every request. No setup required.
  • Per-chat (POST /chats/{chat_id}/completions) — create a Chat resource once to store the AI provider, default system message, and model; then pass only the messages array per request.

Both endpoints support SSE streaming via stream: true.

See the Permissions Reference for the IAM action strings for this module.

Data Model

Chat

FieldTypeDescription
idstringPublic ID prefixed with cht_
project_idstringPublic ID of the owning project
ai_provider_idstringPublic ID of the AI provider used for completions
namestringOptional human-readable name
system_messagestringOptional default system prompt applied to all completions
modelstringOptional model override (falls back to provider's default_model)
created_atstringISO 8601 creation timestamp
updated_atstringISO 8601 last-updated timestamp

Message

Each message in the messages array sent to the completions endpoint:

FieldTypeDescription
rolesystem | user | assistantIdentifies the author of the message
contentstringText body (use this or document_id, not both)
document_idstringPublic ID of a document — the server resolves its content before the call

Key Concepts

System Message Override

When running POST /chats/{chat_id}/completions, if a message with role: system is included in the messages array it replaces the Chat's stored system_message for that call only — the Chat record is not modified.

AI Provider Resolution

For per-chat completions the AI provider is taken from the Chat record. For stateless completions it is passed directly in the request body. See AI Providers for the full list of supported providers and how secrets are resolved.

Streaming

Set stream: true in the request body to receive an SSE stream. Each event contains a JSON object with a choices[0].delta.content chunk. The stream ends with data: [DONE].

Tool Output Selection

For document_id-based messages, the server fetches the document and uses its content field as the message body. For tool-output selection with jq expressions (the output_path behavior), use Agents directly — that feature is not part of the Chats message schema.

Examples

Create a chat

soat create-chat \
--project-id proj_ABC \
--ai-provider-id aip_abc123 \
--name "Support Assistant" \
--system-message "You are a helpful support assistant."

Run a stateless completion

soat create-chat-completion \
--ai-provider-id aip_abc123 \
--system-message "You are a helpful assistant." \
--messages '[{"role":"user","content":"Hello!"}]'