Authentication
Bearer Token Auth
Section titled “Bearer Token Auth”All requests to protected endpoints must include an Authorization header with a Bearer token:
Authorization: Bearer <GATEWAY_API_KEY>Obtaining an API Key
Section titled “Obtaining an API Key”Request a key by sending a POST to /access/request-key. No body is required — the gateway issues a key based on your IP and a server-side secret.
curl -X POST https://your-gateway.workers.dev/access/request-keyconst response = await fetch('https://your-gateway.workers.dev/access/request-key', { method: 'POST',});
const { key } = await response.json();console.log('Your API key:', key);The response contains your key:
{ "key": "gw_..."}Store this key securely. Treat it like a password — do not commit it to source control.
Using the Key
Section titled “Using the Key”Include the key in every request to a protected endpoint:
curl https://your-gateway.workers.dev/v1/chat/completions \ -H "Authorization: Bearer gw_..." \ -H "Content-Type: application/json" \ -d '{ "model": "auto", "messages": [{ "role": "user", "content": "Hi" }] }'Environment Variable Pattern
Section titled “Environment Variable Pattern”Store your key in an environment variable and reference it in requests:
export GATEWAY_API_KEY="gw_..."
curl https://your-gateway.workers.dev/v1/chat/completions \ -H "Authorization: Bearer $GATEWAY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "auto", "messages": [{ "role": "user", "content": "Hi" }] }'Public Endpoints
Section titled “Public Endpoints”The following endpoints do not require authentication:
| Endpoint | Method | Description |
|---|---|---|
/health | GET | Provider health status |
/docs | GET | This documentation site |
/openapi.json | GET | OpenAPI specification |
All /v1/* endpoints and /usage require a valid Bearer token.