Authentication

Authenticate every request with your API key.

All API requests require a valid API key sent in the Authorization header:

Bash
Authorization: Bearer YOUR_API_KEY

API keys can be created and managed from your dashboard. Each key is tied to your account's credit balance. You can create multiple keys for different projects.

Keep your API keys secret. Do not share them in client-side code, public repositories, or URLs.

Expiry and spend limit

When you create a key you can give it:

  • An expiry: 1 hour, 1 day, 3 days, 7 days, 1 month, or a date you choose. After it, the key returns 403 key_inactive with details.status: "EXPIRED".
  • A spend limit in credits: the most the key may spend over its lifetime. Each request holds its estimated cost up front; when that hold does not fit in what is left, the request returns 403 key_spend_limit_reached. You can raise or remove the limit at any time from the dashboard; what the key has already spent is kept.

A streamed request reserves its estimated cost up front. If its final cost is higher, the difference is still charged, so a key can end slightly above its limit.

A short-lived, capped key is the safe way to hand access to a teammate, a demo or a CI job.

Store your key in an environment variable and read it at runtime. Never hardcode it in source code.

Bash
# .env
TCHAVI_API_KEY="sk-tch-..."

# Node.js
const client = new Tchavi({ apiKey: process.env.TCHAVI_API_KEY });

# Python
import os
client = OpenAI(api_key=os.environ["TCHAVI_API_KEY"], base_url="...")

On this page