Skip to content

Get Started with Sub2API ​

Welcome to Sub2API! This guide will help you make your first API call in minutes.

What is Sub2API? ​

Sub2API is a unified API gateway that provides access to leading AI models from OpenAI, Anthropic, Google, and other providers through a single, OpenAI-compatible endpoint.

Base URL ​

All API requests should be made to:

https://api.tokenlio.ai/v1

Three Steps to Your First API Call ​

1. Create Your Account ​

  1. Visit app.tokenlio.ai and sign up with your email
  2. Verify your email address
  3. You'll automatically be logged into your personal workspace

2. Top Up Your Balance ​

  1. Navigate to Billing in the console
  2. Click Top Up Balance
  3. Enter amount (minimum $10 USD)
  4. Complete payment via Stripe
  5. Your balance will be available immediately

3. Create an API Key ​

  1. Go to API Keys in the console
  2. Click Create New Key
  3. Give your key a descriptive name (e.g., "Development", "Production")
  4. Copy the key immediately - it will only be shown once
  5. Store it securely (environment variable, secrets manager, etc.)

Your First Request ​

Once you have your API key, you can make requests using any OpenAI-compatible client:

bash
curl https://api.tokenlio.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4-turbo",
    "messages": [
      {
        "role": "user",
        "content": "Hello! How are you?"
      }
    ]
  }'
python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.tokenlio.ai/v1"
)

response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[
        {"role": "user", "content": "Hello! How are you?"}
    ]
)

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

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.tokenlio.ai/v1',
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'gpt-4-turbo',
    messages: [
      { role: 'user', content: 'Hello! How are you?' }
    ],
  });

  console.log(response.choices[0].message.content);
}

main();

Check Your Usage ​

After making requests:

  1. Go to Usage in the console to see token consumption
  2. View Request Logs for detailed per-request information
  3. Check Billing for costs and remaining balance

Security Best Practices ​

  • Never commit API keys to version control
  • Store keys in environment variables or secrets managers
  • Use separate keys for development and production
  • Rotate keys regularly
  • Disable unused keys immediately

What's Next? ​

Need Help? ​

Access leading AI models through one unified API