Skip to main content
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,
  "phase": "string",
  "side_effects": null,
  "tool": "string",
  "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"
}

Queue an asynchronous chat request

POST
/agents/{agentId}/chat/async
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

application/json

curl -X POST "https://loading/api/v1/agents/string/chat/async" \  -H "Content-Type: application/json" \  -d '{    "messages": [      {        "content": "string",        "role": "string"      }    ]  }'
{
  "$schema": "/api/v1/schemas/AsyncChatStartOutputBody.json",
  "processing_id": "string",
  "status": "string"
}
Empty

Poll an async chat result

GET
/agents/{agentId}/chat/result/{processingId}
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

processingId*string

Processing ID returned by POST /chat/async

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/agents/string/chat/result/string"
{
  "$schema": "/api/v1/schemas/AsyncChatResultOutputBody.json",
  "created_at": "2019-08-24T14:15:22Z",
  "error": "string",
  "phase": "string",
  "response": "string",
  "side_effects": null,
  "status": "string",
  "tool": "string",
  "updated_at": "2019-08-24T14:15:22Z"
}
{
  "$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,
  "phase": "string",
  "side_effects": null,
  "tool": "string",
  "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"
}