Command Palette

Search for a command to run...

Chat API

Programmatically interact with your Botrelic agents.

Endpoint

The Chat API allows you to send messages to an agent and receive its responses. This is the primary API for building custom chat interfaces or integrating Botrelic into existing applications.

POST https://api.botrelic.com/v1/chat/completions

Authentication

All API requests must be authenticated using a Bearer token. You can generate an API key in your workspace settings.

Authorization: Bearer YOUR_API_KEY

Request example

Sends a message to an agent and returns the response. Include the session_id to maintain conversation context.

curl -X POST https://api.botrelic.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "agent_id": "agt_123456789",
  "session_id": "sess_987654321",
  "messages": [
    {
      "role": "user",
      "content": "Hello, how can I help you today?"
    }
  ]
}'

Response example

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "botrelic-agent-v1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I can help you with your account settings."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}

Error codes

The API uses standard HTTP status codes to indicate the success or failure of an API request.

400 Bad Request

The request was unacceptable, often due to missing a required parameter.

401 Unauthorized

No valid API key provided.

403 Forbidden

The API key doesn't have permissions to perform the request.

404 Not Found

The requested resource doesn't exist.

429 Too Many Requests

Too many requests hit the API too quickly.

5xx Server Errors

Something went wrong on Botrelic's end.

Related APIs