Create an API key and authenticate requests
How to create an API key per provider, where it goes in a request for each format, and how to check and protect it.
On this page
Every request to 5abeer carries an API key in a header. The key ties the request to your account and balance, and decides which models it can call.
One key per provider#
Each key works with one provider's models: a key for Claude models, another for GPT models, and so on. If you use a key to call a model from another provider, you get MODEL_PLATFORM_NOT_ALLOWED. Create a key for each provider you need; they all draw on the same balance.
Create a key#
Open the keys page#
In your dashboard open API → Keys.
Pick the provider and a name#
Press New key, pick the provider whose models you want, and give the key a name that says which project will use it.
Copy the key#
Copy the key and keep it in an environment variable or a password manager, not in a file inside the project.
Where the key goes in a request#
Each format has its usual header, and the official libraries set it for you:
- OpenAI format, that is Chat Completions and Responses: the
Authorizationheader, set to the wordBearerfollowed by the key. - Anthropic Messages format: the
x-api-keyheader, set to the key, plus theanthropic-versionheader. - Gemini format: the
x-goog-api-keyheader, set to the key.
The base URL for each format is in Base URLs.
Keep the key in an environment variable#
Every example in these docs reads the key from the KHABEER_API_KEY environment variable:
export KHABEER_API_KEY="YOUR_5ABEER_API_KEY"Check the key#
This request calls no model. With a valid key it returns the list of models; otherwise it returns an error code that names the problem.
curl https://api.5abeer.ai/v1/models \
-H "Authorization: Bearer $KHABEER_API_KEY"Control every key#
Control every key: a spend limit, an expiry date and an IP allow-list. Set them when you create the key, or later in its settings.
- When a key reaches its spend limit you get
API_KEY_QUOTA_EXHAUSTED; raise the limit in the key settings. - After the expiry date you get
API_KEY_EXPIRED; create a new key. - A disabled key returns
API_KEY_DISABLED.
Protect your key#
- Never put the key in code that runs in a browser or inside a phone app: any visitor can read it. Send requests from your server.
- Never commit the key to a code repository. Keep it in a
.envfile and add that file to.gitignore. - Use one key per project, so you can stop one key without affecting your other projects.
- If you think a key has leaked, disable it in the dashboard right away and create a new one.
Was this page helpful?