API Documentation

Token Hub is OpenAI-compatible. Change your base URL and key — your existing code works.

Base URL: http://124.156.169.253/v1
Authentication: Send your API key in the Authorization header as a Bearer token.

Quick Start

# Set your credentials
export TOKENHUB_KEY="sk-th-your-key-here"

# Make your first request
curl http://124.156.169.253/v1/chat/completions \
  -H "Authorization: Bearer $TOKENHUB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-ai/DeepSeek-V3","messages":[{"role":"user","content":"Hello!"}]}'

Chat Completions

Endpoint: POST /v1/chat/completions

Identical to OpenAI's Chat Completions API. Supports streaming via SSE.

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g. deepseek-ai/DeepSeek-V3)
messagesarrayYesConversation messages with role and content
temperaturefloatNoSampling temperature (0-2, default 1)
max_tokensintNoMax tokens to generate
streambooleanNoSet to true for streaming response
top_pfloatNoNucleus sampling parameter

Streaming Example (Python)

import openai

client = openai.OpenAI(
  base_url="http://124.156.169.253/v1",
  api_key="sk-th-your-key-here"
)

stream = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  messages=[{"role":"user","content":"Hello!"}],
  stream=True
)
for chunk in stream:
  print(chunk.choices[0].delta.content or "", end="")

List Models

Endpoint: GET /v1/models

curl http://124.156.169.253/v1/models \
  -H "Authorization: Bearer $TOKENHUB_KEY"

Available Models

Model IDContextInput / 1MOutput / 1M
deepseek-ai/DeepSeek-V364K$1.40$2.80
deepseek-ai/DeepSeek-R164K$0.70$2.80
Qwen/Qwen2.5-7B-Instruct32K$0.35$0.35
Qwen/Qwen2.5-72B-Instruct32K$0.90$0.90
Qwen/Qwen2.5-14B-Instruct32K$0.50$0.50
THUDM/GLM-4-9B-041432K$0.40$0.40
deepseek-ai/DeepSeek-V3.264K$1.40$2.80

Error Codes

StatusMeaning
401Invalid or missing API key
429Quota exceeded — top up your balance
502Upstream connection error
Need help? Visit your dashboard to manage keys and monitor usage.