Không cần đăng nhập để đọc
Tích hợp AI gateway chỉ với vài bước
OIA-Global gom chat, vision, embeddings và ảnh/video vào một base URL tương thích OpenAI. Copy base URL, gắn API key, chọn model — xong.
Base URL của bạn
https://ai.drabo.store/api/v11. Base URL
Dùng URL này trong SDK / client
https://ai.drabo.store/api/v1
2. API key
Gắn Bearer token vào mọi request
Authorization: Bearer <key>
3. Model
Gọi theo dạng prefix/model-id
prefix/model-id
Tổng quan
Gateway proxy tới nhiều provider AI qua một base URL duy nhất. Chọn đúng loại API bên dưới khi tích hợp — không cần học API riêng của từng nhà cung cấp.
Gợi ý nhanh
https://ai.drabo.store/api/v1DashScope ảnh/video:
https://ai.drabo.store/api/v1/dashscope/...Models
Liệt kê model khả dụng — prefix, kind (chat / image / video / embed).
Chat & Text
Hội thoại văn bản — OpenAI-compatible và Ollama native.
Vision (Image Understanding)
Gửi ảnh + câu hỏi → model trả lời text (multimodal chat).
Text to Image
Prompt văn bản → sinh ảnh. OpenAI format hoặc DashScope Wan (async).
Image Edit & Generation
Chỉnh sửa / tạo ảnh từ ảnh tham chiếu + prompt (Wan sync).
Text to Video
Prompt văn bản → video MP4 (async task, Alibaba Wan).
Image to Video
Ảnh khung đầu/cuối + prompt → video MP4 (async, wan2.7-i2v).
Poll Async Task
Lấy kết quả sau khi tạo ảnh/video async — dùng task_id từ response POST.
Embeddings
Text → vector embedding (OpenAI format hoặc Ollama native).
Tích hợp nhanh
Copy snippet phù hợp stack của bạn — mọi ví dụ dùng cùng endpoint chat OpenAI.
curl --location --request POST 'https://ai.drabo.store/api/v1/chat/completions' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "alibabacloud/qwen-plus",
"messages": [
{
"role": "user",
"content": "Xin chào!"
}
],
"stream": false
}'Checklist
- Lấy API key từ admin (gateway key) hoặc dùng provider key trực tiếp (BYOK).
- Gọi
GET https://ai.drabo.store/api/v1/modelsđể xem model khả dụng. - Gọi
POST https://ai.drabo.store/api/v1/chat/completionsvớimodel: "prefix/model-id". - Đọc
choices[0].message.contenttrong response JSON.
/api/v1/modelsLiệt kê models
Trả về danh sách model gateway đang expose. Dùng để populate dropdown client.
Response body
{
"object": "list",
"data": [
{
"id": "groq/openai/gpt-oss-20b",
"object": "model",
"owned_by": "groq",
"kind": "chat"
},
{
"id": "gemini/gemini-2.5-flash",
"object": "model",
"owned_by": "gemini",
"kind": "chat",
"supports_vision": true
},
{
"id": "ollama/bge-m3:latest",
"object": "model",
"owned_by": "ollama",
"kind": "embed"
},
{
"id": "combo/xcv",
"object": "model",
"owned_by": "combo"
}
]
}• Không cần Bearer token.
• Gọi định kỳ để sync model list với providers.json.
Xác thực
Gắn header này vào hầu hết request (trừ GET /models): Authorization: Bearer <token>
| Loại key | Khi nào dùng |
|---|---|
| Gateway key | Key do admin cấp — gateway tự map sang provider key trong config. |
| Provider key (BYOK) | Gửi thẳng key Groq, Gemini, DashScope, … — gateway forward nguyên vẹn. |
Định dạng model
Luôn dùng prefix/model-id trừ Ollama native (/api/chat). Field kind trong GET /models: chat, image, video, embed.
groq/openai/gpt-oss-20b gemini/gemini-2.5-flash alibabacloud/qwen-plus ← chat Qwen (Singapore) alibabacloud/qwen3-vl-plus ← vision alibabacloud/wan2.5-t2i-preview ← text-to-image (async) alibabacloud/wan2.6-t2v ← text-to-video (async) ollama/qwen3.5:4b ollama/bge-m3:latest ← kind: embed combo/xcv ← combo random pool Ollama native (/api/chat, /api/embed): qwen3.5:4b ← bare id, không prefix
API theo loại
Mỗi section gồm endpoint, request/response mẫu và cURL. Alibaba Cloud dùng prefix alibabacloud/ — chat qua OpenAI SDK, ảnh/video qua /dashscope/*.
Models
Liệt kê model khả dụng — prefix, kind (chat / image / video / embed).
/api/v1/modelsLiệt kê models
Trả về danh sách model gateway đang expose. Dùng để populate dropdown client.
Response body
{
"object": "list",
"data": [
{
"id": "groq/openai/gpt-oss-20b",
"object": "model",
"owned_by": "groq",
"kind": "chat"
},
{
"id": "gemini/gemini-2.5-flash",
"object": "model",
"owned_by": "gemini",
"kind": "chat",
"supports_vision": true
},
{
"id": "ollama/bge-m3:latest",
"object": "model",
"owned_by": "ollama",
"kind": "embed"
},
{
"id": "combo/xcv",
"object": "model",
"owned_by": "combo"
}
]
}• Không cần Bearer token.
• Gọi định kỳ để sync model list với providers.json.
Chat & Text
Hội thoại văn bản — OpenAI-compatible và Ollama native.
/api/v1/chat/completionsChat completion (non-stream)
Endpoint chính — tương thích OpenAI SDK / LangChain / most AI clients.
Request body (JSON)
{
"model": "groq/openai/gpt-oss-20b",
"messages": [
{
"role": "system",
"content": "Bạn là trợ lý hữu ích."
},
{
"role": "user",
"content": "Hôm nay ngày mấy?"
}
],
"temperature": 0.7,
"max_tokens": 1024,
"stream": false
}Response body
{
"id": "chatcmpl-gateway-example",
"object": "chat.completion",
"created": 1710000000,
"model": "openai/gpt-oss-20b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hôm nay là thứ Năm, ngày 4 tháng 6 năm 2026."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 18,
"total_tokens": 60
}
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/chat/completions' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "groq/openai/gpt-oss-20b",
"messages": [
{
"role": "system",
"content": "Bạn là trợ lý hữu ích."
},
{
"role": "user",
"content": "Hôm nay ngày mấy?"
}
],
"temperature": 0.7,
"max_tokens": 1024,
"stream": false
}'• Response passthrough từ upstream khi x-gateway-response-mode: provider (mặc định).
• Combo trả thêm header X-Combo-Resolved.
/api/v1/chat/completionsChat streaming (OpenAI SSE)
stream: true — client nhận text/event-stream, mỗi chunk là data: {json}\n\n
Request body (JSON)
{
"model": "groq/openai/gpt-oss-20b",
"messages": [
{
"role": "system",
"content": "Bạn là trợ lý hữu ích."
},
{
"role": "user",
"content": "Hôm nay ngày mấy?"
}
],
"temperature": 0.7,
"max_tokens": 1024,
"stream": true
}Response body
data: {"id":"chatcmpl-stream","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Xin "},"finish_reason":null}]}
data: {"id":"chatcmpl-stream","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"chào!"},"finish_reason":null}]}
data: [DONE]
cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/chat/completions' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "groq/openai/gpt-oss-20b",
"messages": [
{
"role": "system",
"content": "Bạn là trợ lý hữu ích."
},
{
"role": "user",
"content": "Hôm nay ngày mấy?"
}
],
"temperature": 0.7,
"max_tokens": 1024,
"stream": true
}'• Dùng OpenAI SDK: stream: true tự parse SSE.
• Một số provider gửi reasoning trong delta.reasoning_content.
/api/v1/chat/completionsAlibaba Cloud chat (Qwen)
Model Studio Singapore — OpenAI-compatible chat qua gateway. Dùng prefix alibabacloud/ và gateway key hoặc DashScope API key (BYOK).
Request body (JSON)
{
"model": "alibabacloud/qwen-plus",
"messages": [
{
"role": "user",
"content": "Xin chào, giới thiệu ngắn về Qwen."
}
],
"stream": false
}Response body
{
"id": "chatcmpl-gateway-example",
"object": "chat.completion",
"created": 1710000000,
"model": "qwen-plus",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Xin chào! Tôi là Qwen, mô hình ngôn ngữ của Alibaba Cloud."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 18,
"total_tokens": 60
}
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/chat/completions' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "alibabacloud/qwen-plus",
"messages": [
{
"role": "user",
"content": "Xin chào, giới thiệu ngắn về Qwen."
}
],
"stream": false
}'• Upstream: dashscope-intl.aliyuncs.com/compatible-mode/v1 (Singapore / ap-southeast-1).
• Vision: alibabacloud/qwen3-vl-plus với image_url trong messages.
/api/chatOllama native chat
Bare model id — response Ollama gốc, không cần prefix ollama/.
Request body (JSON)
{
"model": "qwen3.5:4b",
"messages": [
{
"role": "user",
"content": "Giải thích ngắn gọn API gateway là gì?"
}
],
"stream": false,
"think": false
}Response body
{
"model": "qwen3.5:4b",
"created_at": "2026-06-04T10:00:00.000Z",
"message": {
"role": "assistant",
"content": "API gateway là cổng trung gian định tuyến request tới backend."
},
"done": true,
"done_reason": "stop",
"prompt_eval_count": 24,
"eval_count": 32
}cURL
curl --location --request POST 'https://ai.drabo.store/api/chat' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "qwen3.5:4b",
"messages": [
{
"role": "user",
"content": "Giải thích ngắn gọn API gateway là gì?"
}
],
"stream": false,
"think": false
}'/api/chatOllama stream (NDJSON)
Mỗi dòng là một JSON object — đọc từng line, không phải SSE.
Request body (JSON)
{
"model": "qwen3.5:4b",
"messages": [
{
"role": "user",
"content": "Giải thích ngắn gọn API gateway là gì?"
}
],
"stream": true,
"think": false
}Response body
{"model":"qwen3.5:4b","message":{"role":"assistant","content":"API "},"done":false}
{"model":"qwen3.5:4b","message":{"role":"assistant","content":""},"done":true,"done_reason":"stop"}cURL
curl --location --request POST 'https://ai.drabo.store/api/chat' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "qwen3.5:4b",
"messages": [
{
"role": "user",
"content": "Giải thích ngắn gọn API gateway là gì?"
}
],
"stream": true,
"think": false
}'• Đọc response.body theo từng dòng (split \n).
• Chunk cuối có done: true và done_reason.
/api/chatThink (extended reasoning)
think: true — Ollama trả message.thinking trước message.content. Nên bật stream.
Request body (JSON)
{
"model": "qwen3.5:4b",
"messages": [
{
"role": "user",
"content": "9.11 và 9.8, số nào lớn hơn?"
}
],
"stream": true,
"think": true
}Response body
{
"model": "qwen3.5:4b",
"created_at": "2026-06-04T10:00:01.000Z",
"message": {
"role": "assistant",
"thinking": "So sánh 9.11 và 9.8: 9.11 = 9.110, lớn hơn 9.8.",
"content": "9.11 lớn hơn 9.8."
},
"done": true,
"done_reason": "stop"
}cURL
curl --location --request POST 'https://ai.drabo.store/api/chat' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "qwen3.5:4b",
"messages": [
{
"role": "user",
"content": "9.11 và 9.8, số nào lớn hơn?"
}
],
"stream": true,
"think": true
}'• Chỉ forward khi provider api_type: ollama hoặc supports.think: true.
• Khi stream: thinking tokens đến trước trong message.thinking.
Vision (Image Understanding)
Gửi ảnh + câu hỏi → model trả lời text (multimodal chat).
/api/v1/chat/completionsVision — Image Understanding
Hiểu ảnh + trả lời text. OpenAI format image_url trong messages[].content.
Request body (JSON)
{
"model": "gemini/gemini-2.0-flash",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Mô tả ảnh bằng tiếng Việt."
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/photo.png"
}
}
]
}
],
"max_tokens": 1024,
"stream": false
}Response body
{
"id": "chatcmpl-gateway-example",
"object": "chat.completion",
"created": 1710000000,
"model": "openai/gpt-oss-20b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Ảnh có nền trong suốt với hình quả cam."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 18,
"total_tokens": 60
}
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/chat/completions' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gemini/gemini-2.0-flash",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Mô tả ảnh bằng tiếng Việt."
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/photo.png"
}
}
]
}
],
"max_tokens": 1024,
"stream": false
}'• Cần model kind chat + supports_vision.
• Ollama native: dùng POST /api/chat với images[] base64.
• Octotech (octotech/…): vision → streamGenerateContent/generateContent; x-gemini-cookie và x-gemini-auth tùy chọn.
• Octotech x-gemini-auth: anonymous | none | off (header tùy chọn, gateway forward lên upstream).
• Octotech native: gửi contents[].parts với inlineData.url (link) hoặc inlineData.data (base64) hoặc fileData.fileUri.
Text to Image
Prompt văn bản → sinh ảnh. OpenAI format hoặc DashScope Wan (async).
/api/v1/images/generationsText to Image (OpenAI format)
Văn bản → ảnh qua OpenAI Images API (/images/generations). Provider phải bật supports.images.
Request body (JSON)
{
"model": "openrouter/google/gemini-3.1-flash-image-preview",
"prompt": "Robot mascot, flat illustration",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}Response body
{
"created": 1710000000,
"data": [
{
"url": "https://cdn.example.com/generated/abc.png",
"revised_prompt": "Robot mascot, flat illustration"
}
]
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/images/generations' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "openrouter/google/gemini-3.1-flash-image-preview",
"prompt": "Robot mascot, flat illustration",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}'/api/v1/dashscope/text2image/image-synthesisText to Image (Wan / DashScope)
Văn bản → ảnh (async). Alibaba Wan — gateway tự thêm X-DashScope-Async. Poll task hoặc ?wait=120.
Request body (JSON)
{
"model": "alibabacloud/wan2.5-t2i-preview",
"input": {
"prompt": "A flower shop with exquisite windows and flowers on display"
},
"parameters": {
"size": "1024*1024",
"n": 1
}
}Response body
{
"output": {
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx",
"task_status": "PENDING"
},
"request_id": "9b5ca774-2bf4-4c3e-8c0f-xxxxxx"
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/dashscope/text2image/image-synthesis?wait=120' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "alibabacloud/wan2.5-t2i-preview",
"input": {
"prompt": "A flower shop with exquisite windows and flowers on display"
},
"parameters": {
"size": "1024*1024",
"n": 1
}
}'• Region Singapore (ap-southeast-1): dashscope-intl.aliyuncs.com.
• Thêm ?wait=120 để gateway poll tới khi SUCCEEDED (tối đa 600s).
Image Edit & Generation
Chỉnh sửa / tạo ảnh từ ảnh tham chiếu + prompt (Wan sync).
/api/v1/dashscope/multimodal-generation/generationImage Edit & Generation (Wan)
Chỉnh sửa / tạo ảnh từ ảnh tham chiếu (sync). wan2.6-image — có thể stream với X-DashScope-Sse: enable.
Request body (JSON)
{
"model": "alibabacloud/wan2.6-image",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "A cozy coffee shop interior, warm lighting, watercolor style"
}
]
}
]
},
"parameters": {
"n": 1,
"size": "1K",
"watermark": false
}
}Response body
{
"output": {
"choices": [
{
"message": {
"role": "assistant",
"content": [
{
"image": "https://dashscope-result.example/out.png"
}
]
}
}
]
},
"request_id": "9b5ca774-2bf4-4c3e-8c0f-xxxxxx"
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/dashscope/multimodal-generation/generation' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "alibabacloud/wan2.6-image",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "A cozy coffee shop interior, warm lighting, watercolor style"
}
]
}
]
},
"parameters": {
"n": 1,
"size": "1K",
"watermark": false
}
}'Text to Video
Prompt văn bản → video MP4 (async task, Alibaba Wan).
/api/v1/dashscope/video-generation/video-synthesisText to Video (Wan)
Văn bản → video MP4 (async). Model vd. wan2.6-t2v, wan2.5-t2v-preview. Gateway tự thêm X-DashScope-Async.
Request body (JSON)
{
"model": "alibabacloud/wan2.6-t2v",
"input": {
"prompt": "A cat walking on the beach at sunset, cinematic lighting"
},
"parameters": {
"size": "1920*1080",
"duration": 5
}
}Response body
{
"output": {
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx",
"task_status": "PENDING"
},
"request_id": "9b5ca774-2bf4-4c3e-8c0f-xxxxxx"
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/dashscope/video-generation/video-synthesis?wait=120' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "alibabacloud/wan2.6-t2v",
"input": {
"prompt": "A cat walking on the beach at sunset, cinematic lighting"
},
"parameters": {
"size": "1920*1080",
"duration": 5
}
}'• Thêm ?wait=120 để gateway poll tới khi hoàn tất.
• Task hợp lệ 24 giờ.
Image to Video
Ảnh khung đầu/cuối + prompt → video MP4 (async, wan2.7-i2v).
/api/v1/dashscope/video-generation/video-synthesisImage to Video (Wan)
Ảnh → video MP4 (async). wan2.7-i2v — first_frame / last_frame trong input.media.
Request body (JSON)
{
"model": "alibabacloud/wan2.7-i2v",
"input": {
"prompt": "A small black cat looks up at the sky curiously, cinematic camera rise",
"media": [
{
"type": "first_frame",
"url": "https://example.com/first-frame.png"
}
]
},
"parameters": {
"resolution": "720P"
}
}Response body
{
"output": {
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx",
"task_status": "PENDING"
},
"request_id": "9b5ca774-2bf4-4c3e-8c0f-xxxxxx"
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/dashscope/video-generation/video-synthesis' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "alibabacloud/wan2.7-i2v",
"input": {
"prompt": "A small black cat looks up at the sky curiously, cinematic camera rise",
"media": [
{
"type": "first_frame",
"url": "https://example.com/first-frame.png"
}
]
},
"parameters": {
"resolution": "720P"
}
}'Poll Async Task
Lấy kết quả sau khi tạo ảnh/video async — dùng task_id từ response POST.
/api/v1/dashscope/tasks/{task_id}Poll Async Task
Poll kết quả text-to-image / text-to-video / image-to-video. task_id hợp lệ 24h.
Response body
{
"output": {
"task_id": "38513c71-5190-48e1-9f3b-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx.mp4"
},
"request_id": "9b5ca774-2bf4-4c3e-8c0f-xxxxxx"
}Embeddings
Text → vector embedding (OpenAI format hoặc Ollama native).
/api/v1/embeddingsEmbedding (OpenAI format)
Model embed-only — không gọi chat với bge-m3.
Request body (JSON)
{
"model": "ollama/bge-m3:latest",
"input": "Xin chào Việt Nam"
}Response body
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [
0.012,
-0.034,
0.056
]
}
],
"model": "ollama/bge-m3:latest",
"usage": {
"prompt_tokens": 6,
"total_tokens": 6
}
}cURL
curl --location --request POST 'https://ai.drabo.store/api/v1/embeddings' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "ollama/bge-m3:latest",
"input": "Xin chào Việt Nam"
}'/api/embedEmbedding (Ollama native)
Passthrough response Ollama — embeddings[] thay vì data[].embedding.
Request body (JSON)
{
"model": "bge-m3:latest",
"input": "Xin chào Việt Nam"
}Response body
{
"model": "bge-m3:latest",
"embeddings": [
[
0.012,
-0.034,
0.056
]
],
"prompt_eval_count": 6
}cURL
curl --location --request POST 'https://ai.drabo.store/api/embed' \
--header 'Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "bge-m3:latest",
"input": "Xin chào Việt Nam"
}'Streaming
SSE (OpenAI) và NDJSON (Ollama native).
OpenAI SSE — POST /api/v1/chat/completions
Đặt stream: true. Response text/event-stream, mỗi chunk data: {...}, kết thúc data: [DONE].
Request
{
"model": "groq/openai/gpt-oss-20b",
"messages": [
{
"role": "system",
"content": "Bạn là trợ lý hữu ích."
},
{
"role": "user",
"content": "Hôm nay ngày mấy?"
}
],
"temperature": 0.7,
"max_tokens": 1024,
"stream": true
}Response chunks
data: {"id":"chatcmpl-stream","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Xin "},"finish_reason":null}]}
data: [DONE]
Ollama NDJSON — POST /api/chat
Mỗi dòng là một JSON. Ghép message.content đến khi done: true.
Request
{
"model": "qwen3.5:4b",
"messages": [
{
"role": "user",
"content": "Giải thích ngắn gọn API gateway là gì?"
}
],
"stream": true,
"think": false
}Response lines
{"model":"qwen3.5:4b","message":{"role":"assistant","content":"API "},"done":false}
{"model":"qwen3.5:4b","message":{"role":"assistant","thinking":"Đang so sánh…"},"done":false}
{"model":"qwen3.5:4b","message":{"role":"assistant","content":""},"done":true,"done_reason":"stop"}Think (extended reasoning)
Ollama native và model hỗ trợ thinking.
Bật think: true khi gọi POST /api/chat. Response tách message.thinking và message.content.
Request
{
"model": "qwen3.5:4b",
"messages": [
{
"role": "user",
"content": "9.11 và 9.8, số nào lớn hơn?"
}
],
"stream": true,
"think": true
}Response
{
"model": "qwen3.5:4b",
"created_at": "2026-06-04T10:00:01.000Z",
"message": {
"role": "assistant",
"thinking": "So sánh 9.11 và 9.8: 9.11 = 9.110, lớn hơn 9.8.",
"content": "9.11 lớn hơn 9.8."
},
"done": true,
"done_reason": "stop"
}- think chỉ có hiệu lực với Ollama native (/api/chat) hoặc provider có supports.think: true.
- Kết hợp stream: true + think: true để nhận thinking realtime trong message.thinking.
- Client OpenAI format có thể thấy reasoning_content trong choices[].delta khi provider hỗ trợ.
- Model embed (kind: embed) không dùng cho chat — chỉ /api/embed hoặc /api/v1/embeddings.
Response modes
Chọn định dạng response qua header x-gateway-response-mode. Mặc định là provider (passthrough upstream).
provider
Mặc định — passthrough response upstream (OpenAI JSON hoặc Ollama NDJSON).
Request header
x-gateway-response-mode: provider
Example response
{
"id": "chatcmpl-gateway-example",
"object": "chat.completion",
"created": 1710000000,
"model": "openai/gpt-oss-20b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hôm nay là thứ Năm, ngày 4 tháng 6 năm 2026."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 18,
"total_tokens": 60
}
}Headers
Chat headers
Authorization: Bearer YOUR_GATEWAY_OR_PROVIDER_KEY Content-Type: application/json x-gateway-response-mode: provider
| Header | Giá trị | Mô tả |
|---|---|---|
| Authorization | Bearer <token> | Bắt buộc (trừ GET /models) |
| Content-Type | application/json | POST body JSON |
| x-gateway-response-mode | provider | structured | ollama | Định dạng response |
| X-Combo-Resolved | (response) | Provider/model khi dùng combo |
Combo routes
Model combo/xcv — gateway chọn ngẫu nhiên provider trong pool. Header response: X-Combo-Resolved: groq/llama-3.3-70b-versatile
Mã lỗi thường gặp
Tất cả endpoints
Model mẫu
cc/claude-opus-4-7cc/claude-opus-4-6cc/claude-sonnet-4-6ag/gemini-3.1-pro-highag/gemini-3.1-pro-lowag/gemini-3-flashag/claude-sonnet-4-6ag/claude-opus-4-6-thinkingag/gpt-oss-120b-mediumgh/gpt-3.5-turbogh/gpt-4gh/gpt-4okr/claude-sonnet-4.5kr/claude-haiku-4.5qw/qwen3-coder-plusqw/qwen3-coder-flashqw/vision-modelqw/coder-modelgroq/openai/gpt-oss-20bgroq/llama-3.3-70b-versatilegroq/llama-3.1-8b-instantgroq/meta-llama/llama-4-scout-17b-16e-instructgroq/qwen/qwen3-32bgroq/openai/gpt-oss-120b/api/v1/modelsLiệt kê model — không cần Authorization.
/api/v1/chat/completionsChat OpenAI-compatible.
/api/chatOllama native — stream NDJSON, think.
/api/v1/images/generationsTạo ảnh OpenAI Images API.
/api/v1/dashscope/text2image/image-synthesisAlibaba Wan text-to-image (async task).
/api/v1/dashscope/video-generation/video-synthesisAlibaba Wan text/image-to-video (async task).
/api/v1/dashscope/multimodal-generation/generationWan2.6 image edit / generation (sync or stream).
/api/v1/dashscope/tasks/{task_id}Poll DashScope async task (image/video).
/api/v1/embeddingsEmbedding OpenAI format.
/api/embedOllama native embed.
Đã sẵn sàng? Copy base URL ở trên rồi nhờ admin cấp API key để gọi thử.