支持 /v1/chat/completions、/v1/completions、/v1/responses、/v1/embeddings、/v1/images/generations、/v1/models
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-...")
r = client.chat.completions.create(model="deepseek-chat", messages=[{"role": "user", "content": "你好"}], stream=True)
for c in r:
print(c.choices[0].delta.content or "", end="") if c.choices else None
import anthropic
client = anthropic.Anthropic(base_url="http://localhost:8080", api_key="sk-...")
msg = client.messages.create(model="claude-sonnet-4-5", max_tokens=1024, messages=[{"role": "user", "content": "你好"}])
curl "http://localhost:8080/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: sk-..." -H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"你好"}]}]}'
curl http://localhost:8080/v1/images/generations -H "Authorization: Bearer sk-..." -H "Content-Type: application/json" \
-d '{"model":"flux-pro-1.1","prompt":"a cat in space","size":"1024x1024","n":1}'
| 状态码 | 含义 |
|---|---|
| 401 | Key 无效 / 已禁用 / 已过期 |
| 402 | 余额不足或 Key 额度用尽 |
| 403 | 无权使用该模型、IP 不在白名单或账户被禁用 |
| 404 | 模型不存在或未开放 |
| 429 | 请求过于频繁 |
| 502/503 | 上游暂时不可用(已自动尝试其它渠道,预扣已退回) |