Skip to content

Latest commit

 

History

History
148 lines (114 loc) · 3.98 KB

File metadata and controls

148 lines (114 loc) · 3.98 KB
title Quickstart
description Get started with TokenLab API in 2 minutes

Step 1: Start with Trial Credits

Sign up at [tokenlab.sh](https://tokenlab.sh) using your email, Gmail, or GitHub account. Your account starts with trial credits for the first small test requests. You do not need to top up before Quickstart. Go to **Dashboard → API Keys** and create a new key, or copy an existing one. Copy it securely because full keys are only shown once. Keep your API key secure. Never expose it in client-side code or public repositories.

Step 2: Install a Client

pip install openai
npm install openai
go get github.com/openai/openai-go/v3
composer require openai-php/client

Step 3: Make Your First Request

For most new integrations, start with Chat Completions on POST /v1/chat/completions.

curl https://api.tokenlab.sh/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "messages": [
      {"role": "user", "content": "What is the capital of France?"}
    ]
  }'
from openai import OpenAI

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

response = client.chat.completions.create(
    model="gpt-5.4",
    messages=[{"role": "user", "content": "What is the capital of France?"}]
)

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

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

const response = await client.chat.completions.create({
  model: 'gpt-5.4',
  messages: [{ role: 'user', content: 'What is the capital of France?' }],
});

console.log(response.choices[0].message.content);
Use `POST /v1/responses` only when you explicitly need Responses-specific behavior. Some Responses-only fields depend on the selected model and routed path.

Top Up for Production

The included trial credits are for the first small tests. Add credits in Dashboard → Billing only when you are ready for production usage or higher-volume testing.

Try Different Models

TokenLab supports hundreds of models. Change only the model field:

response = client.chat.completions.create(model="gpt-5.4", messages=[{"role": "user", "content": "Hello"}])
response = client.chat.completions.create(model="gpt-5-mini", messages=[{"role": "user", "content": "Hello"}])
response = client.chat.completions.create(model="claude-sonnet-4-6", messages=[{"role": "user", "content": "Hello"}])
response = client.chat.completions.create(model="gemini-3.5-flash", messages=[{"role": "user", "content": "Hello"}])
response = client.chat.completions.create(model="deepseek-r1", messages=[{"role": "user", "content": "Hello"}])

Enable Streaming

stream = client.chat.completions.create(
    model="gpt-5.4",
    messages=[{"role": "user", "content": "Tell me a short story."}],
    stream=True
)

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

What’s Next?

Learn about API key management and security. Use OpenAI-compatible `/v1` routes with existing OpenAI SDKs. Explore the full endpoint reference. Browse current model availability and pricing.