Authentication & Tokens
All endpoints authenticate with a Bearer Token. Include your API token in the HTTP header of every request.
Header format
http
Authorization: Bearer sk-xxxxxxxxCreating a token
- Sign in to the console
- Open the Tokens page
- Click New Token, give it a name, and configure the options below:
| Option | Description |
|---|---|
| Name | A recognizable label, e.g. production, staging |
| Quota limit | The maximum quota this token may spend (unlimited if unset) |
| Expiry | When the token automatically becomes invalid (never, if unset) |
| Model group | Restrict this token to a specific group of models |
| IP restriction | Allow only specific IPs or subnets to use this token |
Token security
Security tips
- Do not hard-code tokens in front-end code or public repositories
- Do not commit tokens into configuration files
- If a token leaks, delete it in the console Tokens page immediately and create a new one
Recommended practice:
bash
# Pass the token via an environment variable
export IDREAME_API_KEY="sk-xxxxxxxx"python
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.idreame.ai/v1",
api_key=os.environ["IDREAME_API_KEY"],
)Token states
| State | Meaning |
|---|---|
| Active | Usable normally |
| Expired | Past the configured expiry time; recreate it |
| Disabled | Manually deactivated |
| Quota exhausted | Reached its quota limit; raise the limit or recreate it |
Managing multiple tokens
Create a separate token per project or environment so you can:
- Track API spend per project independently
- Revoke one project's access without affecting others
- Set different quota limits for different environments