Skip to main content
POST
Create chat completion

Authorizations

x-teamai-api-key
string
header
required

Secret API key created in Workspace Settings → API Keys (workspace keys) or Organization Admin → API Keys (organization keys).

Body

application/json
messages
object[]
required

Conversation messages in AI SDK UI-message format. Must contain at least one message with role user.

agentId
string
required

Agent to run. Must belong to the API key's workspace.

chatId
string

Existing chat to continue. Omit to create a new chat titled from the first user message. Providing an unknown ID returns 404.

projectId
string

Project whose instructions, memory, and files are injected into the conversation context.

stream
boolean
default:false

Return a Server-Sent Events stream instead of JSON.

temperature
number
default:0.7
model
string

Model identifier. Falls back to the workspace default model when the requested model is not enabled for the workspace.

variables
object

Prompt template variables.

systemVariables
object

Response

Completion result. Note this endpoint returns the payload directly, without the data envelope used by other endpoints. When stream: true, the response is text/event-stream instead.

text
string

Assistant reply text.

messageId
string

Persisted assistant message ID.

chatId
string
warnings
object[]

Present only when tool setup errors occurred.