The YTokenHub gatewayFully compatible with the OpenAI API protocol: point the BaseURL at this site and the
/v1、API Key at a key created in the console, and your existing code works with any model without further changes.
All /v1 endpoints carry the API key in a request header:
| Method | Path | Description |
|---|---|---|
| POST | /v1/chat/completions | Chat completions, supporting stream=true (SSE streaming) and stream=false |
| GET | /v1/models | The list of currently callable models (also requires the API key) |
404 model_not_found。
curl http://www.yziss.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxx" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Hello"}],
"stream": false
}'
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxx",
base_url="http://www.yziss.com/v1",
)
resp = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
const resp = await fetch(
"http://www.yziss.com/v1/chat/completions",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer sk-xxxxxxxx",
},
body: JSON.stringify({
model: "deepseek-chat",
messages: [{ role: "user", content: "Hello" }],
}),
}
);
const data = await resp.json();
console.log(data.choices[0].message.content);
Pass stream=true and the gateway relays the SSE chunks through as they arrive, finishing with data: [DONE] ; upstreams speak the OpenAI, Anthropic and Gemini protocols, and the gateway normalises them all into OpenAI chunk format so the client never has to care about the vendor.
stream = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "write a short poem"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
| HTTP | code | Meaning and handling |
|---|---|---|
| 400 | invalid_request | Invalid request body (for example a missing model / messages) |
| 401 | invalid_api_key | The key does not exist, has been disabled or has expired |
| 402 | insufficient_balance | Insufficient balance. Top up in Wallet. |
| 404 | model_not_found | The model is not listed; see the price list |
| 429 | rate_limit_exceeded | The per-key, per-minute call limit was exceeded |
| 502 | upstream_error | Every upstream channel failed (not charged, safe to retry) |
| 503 | no_available_channel | This model currently has no available channel |
http://www.yziss.com/v1Bearer sk-...