Skip to main content
SONZAI
Api

Chat

Chat with agent (SSE streaming)

POST
/agents/{agentId}/chat
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Request Body

application/json

Chat request payload

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

text/event-stream

application/problem+json

curl -X POST "https://loading/api/v1/agents/string/chat" \  -H "Content-Type: application/json" \  -d '{    "messages": [      {        "content": "string",        "role": "string"      }    ]  }'
{
  "$schema": "/api/v1/schemas/ChatSSEChunk.json",
  "build_duration_ms": 0,
  "choices": [
    {
      "delta": {
        "content": "string"
      },
      "finish_reason": "string",
      "index": 0
    }
  ],
  "data": null,
  "enriched_context": null,
  "error": {
    "message": "string"
  },
  "message_index": 0,
  "side_effects": null,
  "type": "string",
  "used_fast_path": true
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Playground chat with agent (SSE streaming)

POST
/agents/{agentId}/playground/chat
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Request Body

application/json

Chat request payload

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

text/event-stream

application/problem+json

curl -X POST "https://loading/api/v1/agents/string/playground/chat" \  -H "Content-Type: application/json" \  -d '{    "messages": [      {        "content": "string",        "role": "string"      }    ]  }'
{
  "$schema": "/api/v1/schemas/ChatSSEChunk.json",
  "build_duration_ms": 0,
  "choices": [
    {
      "delta": {
        "content": "string"
      },
      "finish_reason": "string",
      "index": 0
    }
  ],
  "data": null,
  "enriched_context": null,
  "error": {
    "message": "string"
  },
  "message_index": 0,
  "side_effects": null,
  "type": "string",
  "used_fast_path": true
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}