DEVELOPERS / API

API reference

Fully OpenAI-compatible — existing apps migrate without code changes.

BASE URL
https://api.tokenschain.io/v1

Endpoints

MethodPathDescription
POST/v1/chat/completionsChat completions with SSE streaming.
POST/v1/completionsText completions (legacy-model compatible).
POST/v1/embeddingsText embeddings — supports bge, m3e and other open models.
GET/v1/modelsList available models and context lengths.
POST/v1/rerankPassage reranking, typically used in RAG pipelines.
GET/v1/usageInspect account usage and quota.

Sample request

curl https://api.tokenschain.io/v1/chat/completions \
  -H "Authorization: Bearer $TOKENSCHAIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v3",
    "stream": true,
    "messages": [
      {"role": "user", "content": "Introduce TokensChain in one sentence."}
    ]
  }'

Authentication

Every request must include Authorization: Bearer YOUR_API_KEY. Manage and rotate keys from the console under "API Keys".

Error codes

  • 401Authentication failed — invalid or expired API key
  • 429Rate limit hit — retry later or upgrade your plan
  • 500Server error — automatic fail-over to a backup cluster