Manage Gateway API Keys
Create, list, update, and delete AI Gateway API keys
https://api.edgee.app/v1/organizations/{orgId}/api_keysTry this endpoint
Configure your request, then run the curl command in your terminal.
Run in your terminal
Set EDGEE_CONSOLE_API_TOKEN to your personal Console API token in your terminal, then copy and run this command. Requests run against your live organization.
Fill in orgId above before running.
curl --include --no-buffer --globoff --request POST 'https://api.edgee.app/v1/organizations/{orgId}/api_keys' \
--header "Authorization: Bearer $EDGEE_CONSOLE_API_TOKEN" \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Development Client",
"type": "api"
}'Manage your AI Gateway API keys programmatically. Gateway API keys are used to authenticate requests to the Edgee AI Gateway API (https://edgee.io) for making LLM requests.
Request Body
namestringrequiredA descriptive name for this API key (e.g., "Production Backend", "Development Client")
typestringDefault: apiThe type of API key. Options: api (for Gateway requests) or coding_agent (for coding assistants)
ownershipstringDefault: personalFor type: "api", choose personal or service. Service keys are organization-owned
and admin-managed, without a human owner or seat. They survive creator offboarding.
Ownership cannot be changed after creation. Do not supply email, user_id,
coding_assistant, or integration when creating a service key.
coding_assistantstringRequired if type is coding_agent. Specifies which coding assistant this key is for.
Options: claude_code, claude_desktop, opencode, codex, codex_desktop, cursor, copilot, crush, codebuddy, pi, kimi, kilo
modelsarrayOptional list of model restrictions. If specified, this key can only access these models. Leave empty for no restrictions.
Example: ["anthropic/claude-opus-4-6", "openai/gpt-5.2"]
max_usageintegerOptional usage limit in USD for the period set by max_usage_period. If specified, this key stops working after reaching this cost threshold.
max_usage_periodstringDefault: monthlyThe window max_usage applies to. Options: daily, monthly, all_time. See Usage limits & budgets.
expires_in_daysintegerOptional expiration time in days from creation. Ordinary personal and service keys default to 90 days.
emailstringAssignee email for a coding-agent key. Not accepted for service keys.
compressionobjectPer-key token compression settings. Accepts an object with the
tool_result_trimming, tool_surface_reduction, and output_brevity booleans. A bare true is
accepted as a legacy shorthand for tool_result_trimming only.
fallbacksarrayOrdered list of models to try when the requested model's provider fails.
reroutesarrayOrdered list of models to serve instead of the requested model. When set, the requested model is never contacted.
byok_onlybooleanWhen true, the key may only use BYOK provider keys. Requests for models with no matching BYOK credentials are rejected.
Service keys inherit organization controls, not their creator's user or squad settings. Inherited per-member routing budgets and model-limit rules don't apply to them, since there is no member to count against; shared policies and key limits do. Usage is attributed to the organization and key, not the creator.
Response
objectstringThe object type (always "ai_gateway_api_key")
idstringUnique identifier for this API key
organization_idstringThe organization this key belongs to
namestringThe name of this API key
typestringThe type of API key ("api" or "coding_agent")
ownershipstringpersonal or service for ordinary Gateway API keys.
created_by_user_idstringServer-recorded creator of a service key. Audit metadata only, not runtime ownership.
created_by_emailstringCreator email recorded at service-key creation. Audit metadata only.
coding_assistantstringThe coding assistant this key is for (if type is "coding_agent")
modelsarrayList of model restrictions (if any)
max_usageintegerUsage limit in USD (if set)
max_usage_periodstringThe window max_usage applies to: daily, monthly, or all_time
activebooleanWhether this key is currently active
debug_modebooleanWhether debug mode is enabled for this key
created_atstringISO 8601 timestamp when the key was created
expires_atstringISO 8601 timestamp when the key will expire (if set)
last_used_atstringISO 8601 timestamp of the last usage (if ever used)
keystringThe secret returned by the one-time reveal endpoint or a successful rotation. The creation response contains metadata, not the secret.
Examples
Request examples
curl -X POST "https://api.edgee.app/v1/organizations/{orgId}/api_keys" \
-H "Authorization: Bearer <your_console_api_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Production Backend",
"type": "api",
"models": ["anthropic/claude-opus-4-6", "openai/gpt-5.2"],
"max_usage": 1000,
"max_usage_period": "monthly",
"expires_in_days": 90
}'
curl -X POST "https://api.edgee.app/v1/organizations/{orgId}/api_keys" \
-H "Authorization: Bearer <org_admin_console_api_token>" \
-H "Content-Type: application/json" \
-d '{"name":"Production Backend","type":"api","ownership":"service"}'
curl -X POST "https://api.edgee.app/v1/organizations/{orgId}/api_keys" \
-H "Authorization: Bearer <your_console_api_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Claude Code Development",
"type": "coding_agent",
"coding_assistant": "claude_code",
"email": "user@example.com"
}'
curl "https://api.edgee.app/v1/organizations/{orgId}/api_keys" \
-H "Authorization: Bearer <your_console_api_token>"
curl -X POST "https://api.edgee.app/v1/organizations/{orgId}/api_keys/{apiKeyId}" \
-H "Authorization: Bearer <your_console_api_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Production Backend - Updated",
"active": false
}'
curl -X DELETE "https://api.edgee.app/v1/organizations/{orgId}/api_keys/{apiKeyId}" \
-H "Authorization: Bearer <your_console_api_token>"
curl "https://api.edgee.app/v1/organizations/{orgId}/api_keys/{apiKeyId}/reveal" \
-H "Authorization: Bearer <your_console_api_token>"
curl -X POST "https://api.edgee.app/v1/organizations/{orgId}/api_keys/{apiKeyId}/roll" \
-H "Authorization: Bearer <org_admin_console_api_token>"
Response examples
{
"object": "ai_gateway_api_key",
"id": "key_abc123xyz",
"organization_id": "org_12345",
"name": "Production Backend",
"type": "api",
"models": ["anthropic/claude-opus-4-6", "openai/gpt-5.2"],
"max_usage": 1000,
"max_usage_period": "monthly",
"active": true,
"debug_mode": false,
"created_at": "2026-04-08T10:00:00Z",
"expires_at": "2026-07-07T10:00:00Z",
"last_used_at": "2026-04-08T12:30:00Z"
}
Tips
- API Keys vs Console Tokens: Gateway API keys are used to authenticate requests to the Gateway API (
edgee.io), while Console tokens authenticate requests to the Console API (api.edgee.app) - Model Restrictions: Use the
modelsfield to restrict which models a key can access, useful for controlling access and managing costs - Usage Limits: Set
max_usagewith amax_usage_periodto cap spend per day, per month, or for the key's lifetime - Expiration: Use
expires_in_daysto automatically revoke keys after a set period for security rotation - Key Visibility: Create the key, then call the reveal endpoint once and save the secret securely. A service key cannot be revealed again without rotation.
- Service Rotation: An organization admin can call
/rollto replace the secret, keeping the key ID, settings, and usage history. The replacement is returned once, expiry renews for 90 days, and the previous credential is revoked without a grace period.
Next Steps
- Learn how to authenticate to the Gateway API
- Explore Chat Completions to make LLM requests
- Set up alerts to monitor costs associated with your API keys