Quickstart Guide

Get up and running with Tokza.ai in under 5 minutes.

1. Get Your API Key

Sign up for a free account and generate your API key from the dashboard.

Your API Key
sk-tokza-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

2. Make Your First Request

Use any OpenAI-compatible SDK or make direct API calls.

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-tokza-your-api-key",
    base_url="https://api.tokza.ai/v1"
)

response = client.chat.completions.create(
    model="claude-opus-4.8",
    messages=[
        {"role": "user", "content": "Hello, world!"}
    ]
)

print(response.choices[0].message.content)
javascript
import OpenAI from 'openai';

const client = new OpenAI({
    apiKey: 'sk-tokza-your-api-key',
    baseURL: 'https://api.tokza.ai/v1'
});

const response = await client.chat.completions.create({
    model: 'claude-opus-4.8',
    messages: [
        { role: 'user', content: 'Hello, world!' }
    ]
});

console.log(response.choices[0].message.content);
bash
curl https://api.tokza.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-tokza-your-api-key" \
  -d '{
    "model": "claude-opus-4.8",
    "messages": [
      {"role": "user", "content": "Hello, world!"}
    ]
  }'
✓ That's it! You're now sending requests through Tokza at 50% lower cost.

Authentication

All API requests require authentication using your API key in the Authorization header.

Authorization: Bearer sk-tokza-your-api-key
Keep your API key secure! Never commit it to version control or expose it in client-side code.

Environment Variables

Store your API key in environment variables:

export TOKZA_API_KEY="sk-tokza-your-api-key"

Available Models

Access all major AI models through a single API endpoint.

Claude Family

  • claude-fable-5
  • claude-opus-4.8
  • claude-sonnet-4.6
  • claude-haiku-4.5

GPT Family

  • gpt-5.6-sol
  • gpt-5.5
  • gpt-5.6-terra
  • gpt-5.4
  • gpt-5.4-mini

Google Gemini

  • gemini-2.5-pro
  • gemini-2.5-flash
  • gemini-2.0-flash

Other Models

  • grok-4
  • grok-4-fast
  • deepseek-v4-flash
  • mistral-large-3

Chat Completions

Generate conversational responses from any supported model.

Request Format

{
  "model": "claude-opus-4.8",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What is machine learning?"}
  ],
  "temperature": 0.7,
  "max_tokens": 1000
}

Parameters

Parameter Type Description
model string ID of the model to use
messages array List of message objects with role and content
temperature number Sampling temperature (0-2). Default: 1
max_tokens integer Maximum tokens to generate

Streaming Responses

Stream tokens as they're generated for real-time applications.

python
stream = client.chat.completions.create(
    model="claude-opus-4.8",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Error Handling

Handle API errors gracefully with proper status codes.

Status Code Meaning
400 Bad Request - Invalid parameters
401 Unauthorized - Invalid API key
429 Rate Limit Exceeded
500 Internal Server Error
try:
    response = client.chat.completions.create(...)
except openai.AuthenticationError:
    print("Invalid API key")
except openai.RateLimitError:
    print("Rate limit exceeded")
except openai.APIError as e:
    print(f"API error: {e}")