AI gateway
7 endpoints at https://api.kosa8.com, sent with Authorization: Bearer $KOSA8_API_KEY. Generated from the API's own OpenAPI description, which a test holds to the router.
Provider keys stored for the AI gateway (last 4 characters only)#
GET
Responses/v1/ai/keysscope admin200401403
curl -s -X GET https://api.kosa8.com/v1/ai/keys \ -H "Authorization: Bearer $KOSA8_API_KEY"
Store the org's own provider key (sealed; never returned, never sent into a sandbox)#
PUT
Parameters/v1/ai/keys/{provider}scope adminproviderrequiredpath · stringOne of openai, anthropic, groq, mistral, deepseek, openrouter, google-ai-studio, workers-ai
keyrequiredstring—
200400401403
curl -s -X PUT https://api.kosa8.com/v1/ai/keys/$PROVIDER \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json
Remove a provider key#
DELETE
Parameters/v1/ai/keys/{provider}scope adminproviderrequiredpath · stringOne of openai, anthropic, groq, mistral, deepseek, openrouter, google-ai-studio, workers-ai
200401403404
curl -s -X DELETE https://api.kosa8.com/v1/ai/keys/$PROVIDER \ -H "Authorization: Bearer $KOSA8_API_KEY"
The AI gateway's settings, base URL and configured providers#
GET
Responses/v1/ai/settingsscope sandboxes:read200401403
curl -s -X GET https://api.kosa8.com/v1/ai/settings \ -H "Authorization: Bearer $KOSA8_API_KEY"
Change the AI gateway's settings#
PATCH
JSON body/v1/ai/settingsscope adminenabledboolean—
all_sandboxesbooleanPut the gateway in every new sandbox (ai_gateway: false opts one out)
cache_ttl_sintegerAI Gateway response cache; 0 is off Min 0. Max 86400.
rate_per_minintegerModel calls a minute for the org Min 1. Max 6000.
200400401403
curl -s -X PATCH https://api.kosa8.com/v1/ai/settings \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json
Model spend through the gateway: totals, by provider and model, by sandbox, recent calls#
GET
/v1/ai/usagescope sandboxes:readCost is AI Gateway's price for each call; the provider bills it to the org's own key, not kosa8.
Parametersmonthquery · string—
200401403
curl -s -X GET https://api.kosa8.com/v1/ai/usage \ -H "Authorization: Bearer $KOSA8_API_KEY"
A model call through the AI gateway, in the provider's own request shape#
POST
/v1/ai/gw/{provider}/{path}publicSend a sandbox's KOSA8_AI_TOKEN (or an API key with sandboxes:write) as the provider SDK's API key, as Authorization: Bearer or x-api-key. A sandbox created with ai_gateway: true has OPENAI_BASE_URL, ANTHROPIC_BASE_URL and the like set to this path already. The org's stored key for the provider is attached here; the call is logged, costed and tagged with the org and sandbox in Cloudflare AI Gateway.
Parametersproviderrequiredpath · stringOne of openai, anthropic, groq, mistral, deepseek, openrouter, google-ai-studio, workers-ai
pathrequiredpath · stringThe provider's API path, e.g. chat/completions (openai) or v1/messages (anthropic)
200400401402403404409413429502
curl -s -X POST https://api.kosa8.com/v1/ai/gw/$PROVIDER/$PATH