Skip to content

Chat completions

The chat completions API is compatible with the OpenAI chat completions format. Existing OpenAI client libraries can be used by pointing them to ${RUNTIME_BASE_URL}/v1 and adding the X-Tenant-ID header.

The complete, interactive API reference of the Agent Runtime is available at ${RUNTIME_BASE_URL}/docs.

Every published agent or team is an instance. Get the list first:

GET ${RUNTIME_BASE_URL}/v1/instances
Authorization: Bearer ${RUNTIME_TOKEN}
X-Tenant-ID: ${TENANT_ID}
{
"data": [
{
"id": "support-assistant.agent.support-assistant-agent",
"name": "Support Assistant Agent",
"type": "agent_instance",
"metadata": { "description": "Agent with retrieval capabilities for troubleshooting" }
}
]
}

Use the id as the model in chat requests. See Deployments for how instance IDs are built.

POST ${RUNTIME_BASE_URL}/v1/chat/completions
{
"model": "support-assistant.agent.support-assistant-agent",
"messages": [
{ "id": "msg-001", "role": "user", "content": "The packaging line camera is drifting." }
],
"stream": false,
"metadata": {
"chat_id": "conv-abc-123",
"message_id": "msg-002",
"user_id": "john.doe"
}
}
FieldDescription
modelInstance ID from /v1/instances
messagesConversation history in OpenAI format. Roles: system, user, assistant, tool.
streamtrue for Server-Sent Events, see Streaming events
toolsOptional functions your application provides, see External tools
tool_choiceOptional. Forces the use of one external tool.
metadataIDs that let the service keep the conversation state, see Sessions
{
"id": "support-assistant.agent.support-assistant-agent-a1b2c3d4",
"object": "chat.completion",
"created": 1736650000,
"model": "support-assistant.agent.support-assistant-agent",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Please confirm the camera model and when the drift started."
},
"finish_reason": "stop"
}
]
}

finish_reason is stop for a normal answer and tool_calls if the agent wants your application to run an external tool.

Streaming ("stream": true)Non-streaming
TextArrives token by tokenArrives as one answer
Progress, notificationsDelivered as eventsNot included
CitationsDelivered as eventsAppended to the answer text
Guardrail replacementsDelivered as replace eventAlready applied to the answer
Approval requestsDelivered as confirmation eventNot delivered. Do not use agents with tools that need approval.

Use streaming for interactive chat interfaces. Non-streaming is fine for background processing.