Skip to main content
POST
/
api
/
ai
/
chat
/
completions
curl --request POST \
  --url https://api.yourapp.com/api/ai/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "chat_123",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "What is the capital of France?"
      }
    ],
    "model": "gpt-4o",
    "temperature": 0.7,
    "stream": false
  }'
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The capital of France is Paris."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 8,
    "total_tokens": 28
  }
}

Request Body

chatId
string
required
Chat session identifier
messages
array
required
Array of message objects
model
string
default:"gpt-4o"
Model identifier
provider
string
Provider name (e.g., OpenAI, Anthropic, Google)
temperature
number
default:"0.7"
Sampling temperature (0.0 to 2.0)
max_tokens
number
Maximum number of tokens to generate
stream
boolean
default:"false"
Enable streaming response

Response

id
string
Completion ID
object
string
Object type (chat.completion)
created
number
Unix timestamp of creation
model
string
Model used for completion
choices
array
Array of completion choices
usage
object
Token usage information
curl --request POST \
  --url https://api.yourapp.com/api/ai/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "chat_123",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "What is the capital of France?"
      }
    ],
    "model": "gpt-4o",
    "temperature": 0.7,
    "stream": false
  }'
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The capital of France is Paris."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 8,
    "total_tokens": 28
  }
}