API Reference Documentation
Sanki API supports both OpenAI and Anthropic protocol formats. Choose the integration method that fits your needs.
Quick Start
Get started with the Sanki API in just three steps:
Base URLs
Sanki offers two protocol access methods. Choose the Base URL and auth method that matches your client:
https://api.sanki.ink/v1Suitable SDK: openai (Python/Node/Go)
Auth Method: Authorization: Bearer <key>
Main Endpoint: /v1/chat/completions
https://api.sanki.ink/v1Suitable SDK: @anthropic-ai/sdk / Claude Code
Auth Method: x-api-key: <key>
Main Endpoint: /v1/messages
Base URL Client Lookup Table
Different clients handle base_url differently: some use it as a complete prefix, while others append /v1 automatically. Using the wrong setting can cause double-prefix errors like /v1/v1/messages.
| Client | Base URL to Use | Note |
|---|---|---|
| OpenAI Python/Node SDK | https://api.sanki.ink/v1 | SDK treats base_url as complete prefix, needs /v1 |
| Anthropic Python/Node SDK | https://api.sanki.ink/v1 | Same as above, needs /v1 |
| Claude Code (ANTHROPIC_BASE_URL) | https://api.sanki.ink/v1 | Without /v1; Claude Code auto-appends /v1/messages |
| Hermes Agent (custom_providers) | https://api.sanki.ink | Without /v1; Hermes auto-appends /v1/messages |
| curl | https://api.sanki.ink/v1/chat/completions | Full URL including /v1 and specific endpoint |
Try It in One Minute
curl -X POST "https://api.sanki.ink/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-M3",
"messages": [
{"role": "user", "content": "Hello, Sanki!"}
]
}'curl -X POST "https://api.sanki.ink/v1/messages" \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, Sanki!"}
]
}'Authentication
Use different auth headers depending on the protocol. Create and manage your API Key on the API Keys page.
API Key Format Specification
The platform currently uses sk- prefixed, 64-character API Keys (prefix sk- + 61-char base62 random string):
sk-yt1zAiMnFWCH3OwAfwXZEMGRnIgLq1mxkxxUSlDaHgq3jOGTlSJUc6TPUuMzo
└sk─── 61 char base62 (A-Z a-z 0-9) ───────────────────────┘⚠ Security Notice: The full key is displayed only once upon creation and cannot be viewed again after closing the panel. Copy or download the .txt backup immediately. The list shows only the first 12-character prefix (e.g., sk-yt1zAiMnF) for identification, not authentication.
⛔ Old Keys Deprecated: Legacy sk-sanki-* format (35-character) keys have all been forcibly revoked. Please regenerate new sk- prefixed keys.
OpenAI Protocol Authentication
Authorization: Bearer YOUR_API_KEYApplies to /v1/chat/completions, /v1/models, and other OpenAI-compatible endpoints.
Anthropic Protocol Authentication
x-api-key: YOUR_API_KEY
anthropic-version: 2023-06-01Chat Completions (OpenAI)
Standard OpenAI-compatible Chat Completions endpoint. Given a list of conversation messages, the model returns a response.
/v1/chat/completionsRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID, e.g., gpt-4o, claude-sonnet-4-6, gemini-2.5-pro |
| messages | array | Yes | Message list, each containing role (system/user/assistant/tool) and content |
| temperature | number | No | Sampling temperature 0-2, default 1. Higher values produce more randomness. |
| top_p | number | No | Nucleus sampling parameter 0-1, default 1 |
| max_tokens | integer | No | Maximum number of tokens to generate |
| stream | boolean | No | Enable SSE streaming responses, default false |
| tools | array | No | List of function calling tool definitions |
Request Example
curl -X POST "https://api.sanki.ink/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-M3",
"messages": [
{"role": "system", "content": "你是专业的 AI 助手"},
{"role": "user", "content": "解释量子计算"}
],
"temperature": 0.7,
"max_tokens": 1024
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.sanki.ink/v1",
api_key="YOUR_API_KEY"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)Response Format
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "MiniMax-M3",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 9,
"total_tokens": 19
}
}Messages (Anthropic)
Anthropic Messages API compatible endpoint. Supports direct integration with tools like Claude Code via /v1/messages.
/v1/messagesChoose the Base URL by client
https://api.sanki.ink/v1Anthropic SDK (Python / TypeScript) — the SDK appends /messages automaticallyhttps://api.sanki.inkClaude Code — appends /v1/messages automatically; use the root pathRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID, e.g., gpt-4o, claude-sonnet-4-6, gemini-2.5-pro |
| messages | array | Yes | Message list, each containing role (user/assistant) and content |
| max_tokens | integer | Yes | Maximum number of tokens to generate |
| system | string | array | No | System prompt, can be a string or array of content blocks |
| temperature | number | No | Sampling temperature 0-1, default 1 |
| top_p | number | No | Nucleus sampling parameter 0-1, default 1 |
| tools | array | No | List of function calling tool definitions |
Request Example
curl -X POST "https://api.sanki.ink/v1/messages" \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"max_tokens": 1024,
"system": "你是专业的 AI 助手",
"messages": [
{"role": "user", "content": "解释量子计算"}
]
}'from anthropic import Anthropic
client = Anthropic(
base_url="https://api.sanki.ink/v1",
api_key="YOUR_API_KEY"
)
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="你是专业的 AI 助手",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.content[0].text)Response Format
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"model": "deepseek-v4-pro",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"usage": {
"input_tokens": 10,
"output_tokens": 9
}
}Responses API
OpenAI Responses API 兼容端点,支持字符串和数组两种 input 格式。
/v1/responsesRequest Example
curl -X POST "https://api.sanki.ink/v1/responses" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"input": "解释量子计算的基本原理",
"max_output_tokens": 1024
}'Image Generation
支持 DALL·E、Wan 等图片生成模型,返回生成图片的 URL。
/v1/images/generationsRequest Example
curl -X POST "https://api.sanki.ink/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-4-0-250828",
"prompt": "a cat sitting on a cloud",
"n": 1,
"size": "1024x1024"
}'Response Format
{
"created": 1720000000,
"data": [
{
"url": "https://...",
"revised_prompt": "A detailed illustration of..."
}
]
}Video Generation
支持 Kling、Wan 等视频生成模型。视频生成是异步任务,提交后返回 task_id,通过查询接口获取结果。
/v1/videos/generationsRequest Example
curl -X POST "https://api.sanki.ink/v1/videos/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-v1",
"prompt": "a sunset over the ocean with waves",
"duration": 5,
"size": "1920x1080"
}'{
"task_id": "task_abc123",
"status": "processing",
"message": "Video generation started"
}/v1/videos/:task_id查询视频任务状态和结果。
curl "https://api.sanki.ink/v1/videos/task_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"{
"task_id": "task_abc123",
"status": "completed",
"video_url": "https://...",
"duration": 5,
"size": "1920x1080"
}Streaming (SSE)
Both protocols support Server-Sent Events (SSE) streaming. Enable by setting the corresponding parameters:
OpenAI Streaming
Set stream: true to receive data: prefixed SSE events.
curl -X POST "https://api.sanki.ink/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-M3",
"messages": [{"role": "user", "content": "讲个故事"}],
"stream": true
}'data: {"choices":[{"delta":{"content":"前"}}]}
data: {"choices":[{"delta":{},"finish_reason":"stop"}]}
data: [DONE]
Models
/v1/modelsList all available models and their information. Authentication header required.
curl "https://api.sanki.ink/v1/models" \
-H "Authorization: Bearer YOUR_API_KEY"Error Codes
| Parameter | Type | Required | Description |
|---|---|---|---|
| 400 | Bad Request | No | Bad Request — missing required fields or invalid format |
| 401 | Unauthorized | No | Unauthorized — API Key is invalid or expired |
| 402 | Payment Required | No | Payment Required — insufficient balance, please recharge and retry |
| 403 | Forbidden | No | Forbidden — no permission to access this resource |
| 404 | Not Found | No | Not Found — resource does not exist |
| 429 | Too Many Requests | No | Too Many Requests — rate limit exceeded, please retry later |
| 500 | Internal Server Error | No | Internal Server Error — please retry later or contact support |
| 503 | Service Unavailable | No | Service Unavailable — upstream model may be overloaded |
Error Response Example
{
"error": {
"type": "insufficient_quota",
"message": "余额不足,当前余额 ¥0.50,本次调用需要 ¥0.15",
"code": 402
}
}Rate Limits
To ensure platform stability, the Sanki API enforces rate limits. A 429 status code is returned when limits are exceeded.
RPM = Requests Per Minute, TPM = Tokens Per Minute. Upgrade your plan for higher limits.
SDKs
The Sanki API is fully compatible with the official OpenAI / Anthropic SDKs. Simply change the base_url to get started.
Python (OpenAI SDK)
pip install openaifrom openai import OpenAI
client = OpenAI(
base_url="https://api.sanki.ink/v1",
api_key="YOUR_API_KEY"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)Node.js (OpenAI SDK)
npm install openaiimport OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.sanki.ink/v1',
apiKey: 'YOUR_API_KEY',
});
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(response.choices[0].message.content);Python (Anthropic SDK)
pip install anthropicfrom anthropic import Anthropic
client = Anthropic(
base_url="https://api.sanki.ink/v1",
api_key="YOUR_API_KEY"
)
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.content[0].text)Claude Code Configuration
To use Sanki with Claude Code, set the environment variables to point to the Sanki API:
export ANTHROPIC_BASE_URL="https://api.sanki.ink/v1"
export ANTHROPIC_API_KEY="YOUR_SANKI_API_KEY"Go (go-openai)
go get github.com/sashabaranov/go-openaipackage main
import (
"context"
"fmt"
"github.com/sashabaranov/go-openai"
)
func main() {
config := openai.DefaultConfig("YOUR_API_KEY")
config.BaseURL = "https://api.sanki.ink/v1"
client := openai.NewClientWithConfig(config)
resp, err := client.CreateChatCompletion(context.Background(), openai.ChatCompletionRequest{
Model: "deepseek-v4-pro",
Messages: []openai.ChatCompletionMessage{
{Role: "user", Content: "Hello!"},
},
})
if err != nil {
panic(err)
}
fmt.Println(resp.Choices[0].Message.Content)
}Changelog
- 新增图片生成 API (/v1/images/generations)
- 新增视频生成 API (/v1/videos/generations)
- 新增 Responses API (/v1/responses)
- 新增计量规则体系(8 维 token + 图片/视频)
- 销售价设置:支持按维度独立加价
- 计量计价全链路优化
- 生产环境深度优化
- 断路器机制完善
- 协议框架零转换原则落地
- 新增 Gemini 协议入口
- API Key upgraded to 64 characters (sk- + 61 char base62)
- Fixed base_url double /v1 concatenation issue, added client lookup table
- User Center API Key panel: show/hide toggle, multiple copy, download .txt backup
- Legacy sk-sanki-* 35-char keys have been forcibly revoked
- Added Anthropic Messages API inbound endpoint /v1/messages
- Claude Code direct integration support
- Updated multi-protocol API documentation
- New unified API gateway launched
- OpenAI-compatible protocol support
- Added Model Square and Rankings
- Improved trilingual i18n support
- Platform officially launched
- Basic Chat Completions endpoint
- API Key management and usage statistics
Still have questions? Visit the Console to get your API Key, or check out the Model Square to explore available models.
