API Documentation
Everything you need to integrate SilkGateway into your application.
Quick Start
Get started with SilkGateway in under a minute.
# 1. Get your API key at https://silkgateway.ai/register/
# 2. Make your first API call
curl https://api.silkgateway.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
Authentication
All API requests require an API key. Include it in the Authorization header:
Authorization: Bearer sk-your-api-key
You can also pass the key via:
X-Api-Keyheader?api_key=sk-your-keyquery parameter
Keep your API key secret. Never expose it in client-side code or public repositories.
Base URL
https://api.silkgateway.ai/v1
The API is fully compatible with the OpenAI API format. You can use it with any OpenAI-compatible client.
Create Chat Completion
POST
/v1/chat/completions
Create a chat completion. Supports both streaming and non-streaming modes.
Request Body
| Parameter | Type | Description |
|---|---|---|
| model required | string | Model ID (e.g., deepseek-chat, mimo-v2.5) |
| messages required | array | Array of message objects with role and content |
| stream | boolean | Enable streaming. Default: true |
| temperature | number | Sampling temperature (0-2). Default: 1 |
| max_tokens | integer | Maximum tokens to generate |
Example Request
curl https://api.silkgateway.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the Silk Road?"}
],
"temperature": 0.7,
"max_tokens": 500
}'
Response (non-streaming)
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "deepseek-v4-flash",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "The Silk Road was an ancient trade network..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 150,
"total_tokens": 175
}
}
Streaming
Set "stream": true to receive tokens as Server-Sent Events (SSE).
curl https://api.silkgateway.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-chat","messages":[{"role":"user","content":"Hello"}],"stream":true}'
Streaming Response
data: {"choices":[{"delta":{"content":"Hello"}}]}
data: {"choices":[{"delta":{"content":"!"}}]}
data: {"choices":[{"delta":{"content":" How"}}]}
data: [DONE]
List Models
GET
/v1/models
List all available models.
curl https://api.silkgateway.ai/v1/models \
-H "Authorization: Bearer sk-your-key"
Available Models
| Model ID | Provider | Input | Output |
|---|---|---|---|
| deepseek-chat | DeepSeek | $0.14/M | $0.28/M |
| deepseek-reasoner | DeepSeek | $0.55/M | $2.19/M |
| ark-code-latest | Volcengine | $0.11/M | $0.43/M |
| doubao-seed-2.0-pro | Volcengine | $0.11/M | $0.43/M |
| mimo-v2.5 | Xiaomi | $0.10/M | $0.30/M |
| mimo-v2.5-pro | Xiaomi | $0.10/M | $0.30/M |
Check Balance
GET
/v1/balance
Get your current account balance.
curl https://api.silkgateway.ai/v1/balance \
-H "Authorization: Bearer sk-your-key"
Response
{"balance": 10.50, "currency": "USD"}
Check Usage
GET
/v1/usage
Get monthly usage statistics.
curl https://api.silkgateway.ai/v1/usage?month=2026-07 \
-H "Authorization: Bearer sk-your-key"
Billing Details
GET
/v1/billing
Get detailed billing info including costs, quota, and model breakdown.
curl https://api.silkgateway.ai/v1/billing \
-H "Authorization: Bearer sk-your-key"
Response
{
"month": "2026-07",
"tier": "pro",
"usage": { "requests": 150, "totalTokens": 45000 },
"costs": { "subtotal": 0.0126, "discount": 0.00126, "total": 0.01134 },
"quota": { "free": 1000000, "used": 45000, "remaining": 955000 },
"balance": 10.50
}
Top Up Balance
POST
/v1/topup
Add funds to your account balance.
curl -X POST https://api.silkgateway.ai/v1/topup \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"amount": 25}'
Pricing
GET
/v1/pricing
Get current pricing for all models and tiers.
curl https://api.silkgateway.ai/v1/pricing