Guides
Authentication
Learn how to authenticate your API requests with TOKI.
API Key Authentication
All model API requests require authentication using an API key. Include your key in the Authorization header, using the same format as the OpenAI API:
Authorization: Bearer YOUR_API_KEYCreating API Keys
You can create and manage API keys in the TOKI console:
- Sign in and open the API Keys page.
- Click Create Key.
- Set the key name, supplier, quota, and expiration.
- Copy the key after it is created and store it securely.
The full API key may only be shown when it is created. Copy it immediately and store it securely using environment variables or a secret manager.
Key Best Practices
| Practice | Description |
|---|---|
| Use environment variables | Never hardcode keys in source code |
| Rotate regularly | Rotate keys every 90 days |
| Use scoped keys | Create separate keys for different environments |
| Monitor usage | Track Token balance and key usage in the console |
OpenAI SDK Authentication
When using the official OpenAI SDK, set apiKey to your TOKI API key and point baseURL to TOKI:
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: 'https://www.tokiai.ai/v1',
apiKey: process.env.TOKI_API_KEY,
});Common Authentication Errors
| Case | How to handle it |
|---|---|
Missing Authorization header | Check that the header includes the Bearer prefix. |
| Invalid or disabled API key | Confirm the key status in the console or create a new key. |
| Expired key | Update the expiration or create a new API key. |
| Insufficient quota | Check account Token balance and key-level quota limits. |