LLM API Integration Docs

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.

Authentication

All /v1 endpoints carry the API key in a request header:

Authorization: Bearer <sk-...>
For security the secret isshown only once, at creation time (the server only stores a SHA-256 hash). A key can be given a quota and an expiry and can be disabled or deleted at any time.
Available endpoints
MethodPathDescription
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)
The full model list and live unit prices are on the price list; passing a model that is not listed or does not exist returns 404 model_not_found。
Request examples

cURL

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
  }'

Python (official OpenAI SDK)

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)

Node.js

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);
streaming output (SSE)

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="")
Error codes
HTTPcodeMeaning and handling
400invalid_requestInvalid request body (for example a missing model / messages)
401invalid_api_keyThe key does not exist, has been disabled or has expired
402insufficient_balanceInsufficient balance. Top up in Wallet.
404model_not_foundThe model is not listed; see the price list
429rate_limit_exceededThe per-key, per-minute call limit was exceeded
502upstream_errorEvery upstream channel failed (not charged, safe to retry)
503no_available_channelThis model currently has no available channel

Key points

  • BaseURL:http://www.yziss.com/v1
  • Authentication:Bearer sk-...
  • Billing: by token usage, input and output priced separately
  • Streaming: SSE supported
  • Failures are never charged and channels are retried automatically