Chat Completions (Chat)
OpenAI-compatible: POST /v1/chat/completions. Unified access to mainstream large language models.
- Path:
https://www.tokenpad.ai/v1/chat/completions - Auth:
Authorization: Bearer sk-your_token_here
For multimodal input, change content from a string to an array; see the examples below for each part's type. Support for images, audio, or video depends on the selected model.
1. Text only
curl -X POST https://www.tokenpad.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your_token_here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "Hello, introduce yourself in one sentence."}
],
"stream": false
}'
2. Multimodal: Image + Text
type: image_url, where url supports HTTP(S) or data:image/...;base64,....
curl -X POST https://www.tokenpad.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your_token_here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "What is in this image? Briefly explain." },
{
"type": "image_url",
"image_url": { "url": "https://example.com/cat.jpg" }
}
]
}
]
}'
For multiple images, append additional image_url parts.
3. Multimodal: Audio + Text
Two common formats (choose based on model capabilities):
A. OpenAI-style input_audio (base64)
curl -X POST https://www.tokenpad.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your_token_here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-audio-preview",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "What is this audio saying? Summarize it in English." },
{
"type": "input_audio",
"input_audio": {
"data": "<base64-audio>",
"format": "wav"
}
}
]
}
]
}'
B. URL-style audio_url (supported by some channels)
curl -X POST https://www.tokenpad.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your_token_here" \
-H "Content-Type: application/json" \
-d '{
"model": "your-audio-capable-model",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Please transcribe and summarize this audio." },
{
"type": "audio_url",
"audio_url": { "url": "https://example.com/sample.wav" }
}
]
}
]
}'
Text-to-Speech (TTS) uses the dedicated endpoint
POST /v1/audio/speechand is not part of chatmessagesmultimodality.
4. Multimodal: Video + Text (Selected Models)
curl -X POST https://www.tokenpad.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your_token_here" \
-H "Content-Type: application/json" \
-d '{
"model": "your-video-capable-model",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Summarize the main content of this video." },
{
"type": "video_url",
"video_url": { "url": "https://example.com/demo.mp4" }
}
]
}
]
}'
5. Common Parameters
| Param | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID |
messages | array | Yes | content: string or [text / image_url / input_audio / audio_url / video_url] |
stream | boolean | No | Default false |
temperature | number | No | 0~2 |
max_tokens | integer | No | Max output tokens |
SDK: official openai with base_url="https://www.tokenpad.ai/v1" and your platform Token as api_key.
5. Common Error Codes & Troubleshooting
HTTP codes, error body format, and troubleshooting are maintained in one dedicated page (not duplicated under each example).
👉 Gateway Error Codes & Troubleshooting
Quick reference:
| Code | Meaning |
|---|---|
| 400 | Invalid parameters / content moderation or copyright block |
| 402 | Insufficient account balance (not 429) |
| 429 | RPS/RPM limits or in-flight task cap (low balance) |
| 403 | Token / IP / model permission (balance → 402; content filter → 400) |
200 + status: failed | Async video/long-task business failure on poll |
HTTP status matches call log status_code for traceability by log_id.
Maintenance: update the
error-codesarticle only; this appendix links to it.