RouterGetting Started

Your first inference request

1. Add credit and get an API key

There is no free tier: a request with your key is paid from your account’s credit.

  1. Sign up at id.tangle.tools and verify your email.
  2. Add a card and credit at id.tangle.tools/app/billing. Per-model rates are in GET /v1/models; see Credits & Pricing.
  3. Create an API key at id.tangle.tools/app/keys. Keys start with sk-tan-.

A key on an account without credit gets 402 payment_required.

2. Make a request

curl

curl -X POST "https://router.tangle.tools/v1/chat/completions" \
  -H "Authorization: Bearer sk-tan-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "What is Tangle?"}],
    "stream": false
  }'

Python (OpenAI SDK)

from openai import OpenAI
 
client = OpenAI(
    api_key="sk-tan-YOUR_KEY",
    base_url="https://router.tangle.tools/v1"
)
 
response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "What is Tangle?"}]
)
print(response.choices[0].message.content)

TypeScript (AI SDK)

import { generateText } from 'ai'
import { createOpenAI } from '@ai-sdk/openai'
 
const tangle = createOpenAI({
  apiKey: 'sk-tan-YOUR_KEY',
  baseURL: 'https://router.tangle.tools/v1',
})
 
const { text } = await generateText({
  model: tangle('openai/gpt-4o-mini'),
  prompt: 'What is Tangle?',
})

3. Check the response headers

Every response includes metadata headers:

X-Generation-Id: gen_01J5K7...       # Unique request ID
X-Tangle-Price-Input: 0.000003       # USD per input token
X-Tangle-Price-Output: 0.000015      # USD per output token
X-Tangle-Cache: MISS                 # Response cache status
X-RateLimit-Remaining: 59            # Requests left in window

Use the generation ID to look up request details later via GET /v1/generation.

4. Try different models

The model ID format is provider/model-name. GET /v1/models with your key lists the models it can call.

What’s next