DOCS / GETTING STARTED

Token2Token API

One OpenAI-compatible API for official infrastructure and community GPUs. Change the base URL, choose a live model, and your existing integration works.

⌁ GitHub
Base URLhttps://api.tokens2tokens.com/v1

1. Authenticate

Create a key in the console and pass it as a Bearer token. Keys are shown once; store them in an environment variable and never ship them in browser code.

export TOKEN2TOKEN_API_KEY="t2t_..."

2. Make a request

Chat Completions supports non-streaming and Server-Sent Event responses.

curl https://api.tokens2tokens.com/v1/chat/completions \
  -H "Authorization: Bearer $TOKEN2TOKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "community/qwen2.5-7b",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

3. Discover live models

The catalog changes as community nodes connect. Query it at runtime instead of hard-coding availability.

curl https://api.tokens2tokens.com/v1/models

Credit selection

Set payment.credit to gold, indigo, or auto. Official providers require Gold. Community providers accept Gold and Indigo.

Two-credit economyGold is purchased and reaches every tier. Indigo is earned by providers—and every newly verified GPU receives 500 Indigo so the network can begin using shared compute immediately.

Provider routing

Use the provider object to constrain residency, price, verified entities, quantization, confidentiality, or sorting. confidential_compute only selects community nodes with verified, unexpired hardware attestation; ordinary engines and encrypted transport alone do not qualify. Official privacy is contractually governed.

"provider": {
  "sort": "balanced",
  "data_residency": ["TW"],
  "confidential_compute": false,
  "max_price": {"input": "1.00", "output": "3.00"},
  "allow_fallbacks": true
}

Streaming

Set stream: true. The API returns OpenAI-compatible data chunks and terminates with [DONE].

Supported local engines

The provider client detects Ollama through /api/tags and LM Studio, llama.cpp, and vLLM through /v1/models.