Skip to main content

Endpoint

Authentication

Overview

The AI Chat API accepts a conversation history as an array of messages and returns the model’s reply along with token usage statistics. Each message carries a role (user, assistant, or system) and a content string, enabling full multi-turn conversations and system-level instructions.

Use cases

  • Add AI-powered chat to any application without managing model infrastructure
  • Build customer support bots with custom system prompts
  • Prototype conversational features quickly with a single POST request
  • Create multi-turn dialogue flows where prior context shapes each reply

Details

Messages are processed in order, so the conversation history must be complete each time you call the API. The system role is used to set behavior or persona for the model. Up to 50 messages are accepted per request, and each message content is limited to 10,000 characters. Token usage is returned in the usage field when available.

Request body

Message object

Example

Response

200 OK

Example

400 Bad Request

Returned when the messages field is missing, not an array, empty, exceeds 50 items, or contains an invalid role or oversized content.

401 Unauthorized

402 Payment Required

429 Too Many Requests

502 Bad Gateway

Returned when the upstream AI service is unavailable or returns an unexpected error.

cURL example