# Quick Start Guide

This guide walks you through the complete process of using Tokenlio, from registration to monitoring your usage.

## Prerequisites

- A valid email address
- A payment method (credit card via Stripe)
- Minimum $10 USD for initial top-up

## Step 1: Sign Up and Verify Email

1. Visit [api.tokenlio.ai](https://api.tokenlio.ai)
2. Click **Sign Up**
3. Enter your email and create a password
4. Check your email for the verification link
5. Click the link to verify your account
6. Log in to access your personal workspace

## Step 2: Top Up Your Balance

Tokenlio uses a prepaid, pay-as-you-go model. You need to add credit before making API calls.

1. Navigate to **Billing** in the left sidebar
2. Click **Top Up Balance**
3. Enter the amount (minimum $10 USD)
4. Click **Proceed to Payment**
5. Complete payment through Stripe
6. Your balance will be credited immediately

### Payment Notes

- We accept major credit cards via Stripe
- Minimum top-up: $10 USD
- All transactions are secure and encrypted
- You'll receive a receipt via email

## Step 3: Create an API Key

API keys authenticate your requests to Tokenlio.

1. Go to **API Keys** in the console
2. Click **Create New Key**
3. Enter a descriptive name:
   - `Development` for testing
   - `Production` for live applications
   - `Project Name` for specific projects
4. (Optional) Set quota limits
5. Click **Create**
6. **Copy the key immediately** - it will only be shown once
7. Store it securely

::: warning
Your API key will only be displayed once at creation. If you lose it, you'll need to create a new one.
:::

### Key Security

- Store keys in environment variables
- Never commit keys to version control
- Use different keys for development and production
- Disable or delete unused keys

## Step 4: Make Your First Request

Now you're ready to call the API!

### Using cURL

```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": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is Tokenlio?"}
    ]
  }'
```

### Using Python

First, install the OpenAI SDK:

```bash
pip install openai
```

Then use it with Tokenlio:

```python
from openai import OpenAI

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

# Make a request
response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is Tokenlio?"}
    ],
    temperature=0.7,
    max_tokens=150
)

print(response.choices[0].message.content)
```

### Using Node.js

First, install the OpenAI SDK:

```bash
npm install openai
```

Then use it with Tokenlio:

```javascript
import OpenAI from 'openai';

// Initialize client with Tokenlio
const client = new OpenAI({
  apiKey: process.env.TOKENLIO_KEY,
  baseURL: 'https://api.tokenlio.ai/v1',
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'gpt-4-turbo',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'What is Tokenlio?' }
    ],
    temperature: 0.7,
    max_tokens: 150,
  });

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

main();
```

### Streaming Responses

Tokenlio supports streaming for real-time token generation:

```python
stream = client.chat.completions.create(
    model="gpt-4-turbo",
    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="")
```

## Step 5: Monitor Your Usage

Track your API usage and costs in real-time.

### View Usage Summary

1. Go to **Usage** in the console
2. Select a time range (today, week, month, custom)
3. View:
   - Total requests
   - Tokens consumed (input/output)
   - Total cost
   - Breakdown by model

### Check Request Logs

1. Navigate to **Request Logs**
2. See detailed information for each request:
   - Timestamp
   - Model used
   - Token counts
   - Cost
   - Status (success/error)
   - Request ID (for support)

### Monitor Balance

Your current balance is always visible in the top bar. When balance runs low:

- You'll receive email notifications
- Requests will fail with insufficient balance errors
- Top up to resume service

## Step 6: Using with Teams (Optional)

If you're working with a team, create an organization workspace:

1. Click your profile in the top right
2. Select **Create Organization**
3. Name your organization
4. Top up the organization balance
5. Go to **Organization > Members**
6. Click **Invite Member**
7. Enter their email address
8. They'll receive an invitation link

### Organization Benefits

- **Shared billing**: One balance for the whole team
- **Centralized management**: Owner controls all settings
- **Individual keys**: Each member creates their own keys
- **Usage tracking**: See which keys consume what resources

Learn more in our [Team Collaboration Guide](#) (coming soon).

## Common Error Codes

| Code | Meaning | Solution |
|------|---------|----------|
| 401 | Invalid API key | Check your key is correct and active |
| 402 | Insufficient balance | Top up your account |
| 429 | Rate limit exceeded | Reduce request frequency or contact support |
| 500 | Server error | Retry or contact support |

## Best Practices

### Environment Setup

Create a `.env` file for your API key:

```bash
TOKENLIO_KEY=your_key_here
```

Load it in your application:

```python
# Python
import os
from dotenv import load_dotenv

load_dotenv()
api_key = os.getenv('TOKENLIO_KEY')
```

```javascript
// Node.js
import 'dotenv/config';
const apiKey = process.env.TOKENLIO_KEY;
```

### Error Handling

Always wrap API calls in error handling:

```python
from openai import OpenAI, OpenAIError

try:
    response = client.chat.completions.create(...)
except OpenAIError as e:
    print(f"API error: {e}")
    # Handle error (log, retry, alert, etc.)
```

### Rate Limiting

Be mindful of rate limits:

- Implement exponential backoff for retries
- Cache responses when possible
- Use streaming for long responses
- Monitor usage to avoid surprises

## Next Steps

Now that you're up and running:

- [Explore available models](https://api.tokenlio.ai/marketplace) and their pricing
- [Learn about authentication](/guide/authentication) in detail
- [Read the API reference](/api/chat) for advanced features
- [Review billing details](/guide/billing) to optimize costs

## Getting Help

If you encounter issues:

- Check the [FAQ](/support/faq) for common questions
- Review [error codes](#common-error-codes) above
- Email [support@tokenlio.ai](mailto:support@tokenlio.ai)
- Include your request ID for faster support
