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#

  1. Navigate to Console → API Keys
  2. Click New Key
  3. Enter a descriptive name (e.g., "Production", "Development")
  4. Click Create
  5. 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-xxxxx

Example Request#

cURL
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.

1

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.

2

Choose a setup tab

Use one of the tool tabs:

  • OpenCode
  • Claude Code
  • Codex CLI
3

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.

4

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.

5

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_MODEL for light tasks
  • ANTHROPIC_DEFAULT_SONNET_MODEL for daily use
  • ANTHROPIC_DEFAULT_OPUS_MODEL for 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#

FeatureDetail
StorageSHA-256 hashed — raw key is never stored
PrefixAll keys start with sk-foza-
EncryptionProvider upstream keys are AES-256-GCM encrypted
AuthJWT 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.