Authentication
How to create and use API keys to authenticate with the Foza gateway
API Keys#
Every request to the Foza gateway must include a valid API key. Keys are created in the Console → API Keys section.
Creating a Key#
- Navigate to Console → API Keys
- Click New Key
- Enter a descriptive name (e.g., "Production", "Development")
- Click Create
- Copy the key immediately
Your API key is shown only once at creation time. Foza stores only a SHA-256 hash of the key for security. If you lose your key, you must create a new one.
Using Your Key#
Include the API key in the Authorization header as a Bearer token:
Authorization: Bearer sk-foza-xxxxxExample Request#
curl https://api.foza.ai/v1/chat/completions \ -H "Authorization: Bearer sk-foza-xxxxx" \ -H "Content-Type: application/json" \ -d '{"model": "openai/gpt-4o", "messages": [{"role": "user", "content": "Hi"}]}'
Quick Setup for Coding Tools#
The fastest way to configure OpenCode, Claude Code, or Codex CLI is to use the setup generator on the API key detail page. It uses the selected key and model subscriptions, then creates the correct command for your operating system.
Open the key detail page
Go to Console -> API Keys, then open the key you want to use. Confirm the key is Active and has the models you want to use.
Choose a setup tab
Use one of the tool tabs:
- OpenCode
- Claude Code
- Codex CLI
Select your operating system
Choose macOS / Linux or Windows. The generated command changes depending on the shell and config path for the selected operating system.
Assign models by workload
Pick the Foza model slug for each workload. The options come from the models connected to this API key.
For Claude Code, this is especially important because Foza model names include the provider prefix, such as anthropic/claude-sonnet-4.6. The generated command writes that exact model into Claude Code's config.
Create and run the setup command
Click Create setup command, copy the command, and run it in your terminal. The command configures the selected tool to use:
- the Foza gateway base URL
- this API key
- the selected model or workload-to-model mapping
For Claude Code, the generated config maps workload buckets to Foza model slugs:
ANTHROPIC_DEFAULT_HAIKU_MODELfor light tasksANTHROPIC_DEFAULT_SONNET_MODELfor daily useANTHROPIC_DEFAULT_OPUS_MODELfor hard tasks
Use the generated command as the source of truth. The integration docs explain what the command configures and include manual fallback snippets for advanced users.
Key Security#
| Feature | Detail |
|---|---|
| Storage | SHA-256 hashed — raw key is never stored |
| Prefix | All keys start with sk-foza- |
| Encryption | Provider upstream keys are AES-256-GCM encrypted |
| Auth | JWT access tokens with short TTL |
Key Management#
- Deactivate — Disable a key without deleting it
- Delete — Permanently remove a key
- Connected Models — View and manage which models are linked to each key
- Usage History — See request logs per key
You can create multiple keys for different environments (development, staging, production) and subscribe each to different models.