Quick Start

5 min setup

Get up and running with TokenRouter in minutes. This guide will walk you through making your first API call.

Prerequisites

Before you begin
Make sure you have the following ready:
  • A TokenRouter account (sign up at tokenrouter.com)
  • At least one provider API key (OpenAI, Anthropic, Mistral, or Together.ai)
  • Basic knowledge of REST APIs

Step 1: Get Your API Key

First, you'll need to generate a TokenRouter API key from your dashboard.

1. Log in to your TokenRouter dashboard

2. Navigate to API Keys section

3. Click "Generate New Key"

4. Copy your API key (starts with `tr_`)

Important: Keep your API key secure and never expose it in client-side code. Store it as an environment variable.

Step 2: Configure Provider Keys

Add your provider API keys to enable intelligent routing across different models.

Supported Providers
Add keys for any providers you want to use

OpenAI

GPT-4, GPT-3.5 Turbo models

sk-...

Anthropic

Claude 3 Opus, Sonnet, Haiku

sk-ant-...

Mistral AI

Mistral Large, Medium, Small

...

Together.ai

Llama 2, Code Llama, others

...

Step 3: Make Your First Request

Now you're ready to make your first API call. Choose your preferred method below:

cURL Example
Make a request using cURL from your terminal
curl -X POST https://api.tokenrouter.com/route \
  -H "Authorization: Bearer tr_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Explain quantum computing in simple terms",
    "temperature": 0.7,
    "max_tokens": 1000
  }'

Expected Response

You'll receive a response in OpenAI-compatible format with additional TokenRouter metadata:

{
  "id": "tr_req_abc123",
  "object": "chat.completion",
  "created": 1699564800,
  "model": "gpt-4",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing is like having a super-powered calculator..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 150,
    "total_tokens": 162
  },
  "tokenrouter": {
    "selected_provider": "openai",
    "selected_model": "gpt-4",
    "routing_reason": "optimal_quality_cost_ratio",
    "cost_savings": "23%",
    "response_time_ms": 1250
  }
}

Next Steps

Learn Authentication
Understand API key management and security best practices
Explore API Reference
Dive deep into all available endpoints and parameters