Skip to main content
POST
/
v1
/
chat
/
completions
curl --request POST \
  --url https://toapis.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {
        "role": "user",
        "content": "Hello, please introduce yourself"
      }
    ]
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1703884800,
  "model": "claude-sonnet-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm Claude, an AI assistant made by Anthropic. I can help you answer questions, analyze information, write code, create content, and much more. How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 38,
    "total_tokens": 51
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.toapis.com/llms.txt

Use this file to discover all available pages before exploring further.

  • OpenAI-compatible Chat Completions API
  • Specify the model via the model parameter — see Model List for all supported models
  • Supports streaming output (SSE)
  • Supports multi-turn conversation and system prompts
  • Select models support vision input (images) and extended thinking

Authorizations

Authorization
string
required
All endpoints require Bearer Token authenticationGet your API Key from the API Key Management PageAdd to request header:
Authorization: Bearer YOUR_API_KEY

Body

model
string
required
Model name — see Model List for all supported modelsExamples: "claude-sonnet-4-6", "gpt-5", "qwen3-max"
messages
object[]
required
List of conversation messages in chronological order
stream
boolean
default:false
Whether to enable streaming output (Server-Sent Events)
  • true: Stream tokens incrementally
  • false: Return the complete response at once
max_tokens
integer
Maximum number of tokens to generateUses the model’s default limit when not set
temperature
number
default:1
Sampling temperature, controls output randomness
  • Range: 0 to 2
  • Lower values produce more deterministic output; higher values produce more varied output
top_p
number
default:1
Nucleus sampling probability thresholdRange: 0 to 1. It is not recommended to modify both temperature and top_p at the same time
stop
string | string[]
Stop sequences — generation stops when these strings are encounteredMaximum 4 stop sequences

Response

id
string
Unique identifier for this request
object
string
Object type, always chat.completion
created
integer
Request creation timestamp (Unix)
model
string
The model that was actually used
choices
object[]
List of generated results
  • choices[].message.role: Message role, always assistant
  • choices[].message.content: Generated text content
  • choices[].finish_reason: Stop reason — stop / length / content_filter
  • choices[].index: Result index
usage
object
Token usage statistics for this request
  • usage.prompt_tokens: Input token count
  • usage.completion_tokens: Output token count
  • usage.total_tokens: Total token count
curl --request POST \
  --url https://toapis.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {
        "role": "user",
        "content": "Hello, please introduce yourself"
      }
    ]
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1703884800,
  "model": "claude-sonnet-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm Claude, an AI assistant made by Anthropic. I can help you answer questions, analyze information, write code, create content, and much more. How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 38,
    "total_tokens": 51
  }
}