Skip to content

Authentication

All requests to protected endpoints must include an Authorization header with a Bearer token:

Authorization: Bearer <GATEWAY_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.

Terminal window
curl -X POST https://your-gateway.workers.dev/access/request-key

The response contains your key:

{
"key": "gw_..."
}

Store this key securely. Treat it like a password — do not commit it to source control.

Include the key in every request to a protected endpoint:

Terminal window
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" }] }'

Store your key in an environment variable and reference it in requests:

Terminal window
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" }] }'

The following endpoints do not require authentication:

EndpointMethodDescription
/healthGETProvider health status
/docsGETThis documentation site
/openapi.jsonGETOpenAPI specification

All /v1/* endpoints and /usage require a valid Bearer token.