Skip to content

Edgee Demo Day · November 10

Register
Console API
Console API

Manage Gateway API Keys

Create, list, update, and delete AI Gateway API keys

POST/v1/organizations/{orgId}/api_keys
POSThttps://api.edgee.app/v1/organizations/{orgId}/api_keys

Try 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
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

namestringrequired

A descriptive name for this API key (e.g., "Production Backend", "Development Client")

typestringDefault: api

The type of API key. Options: api (for Gateway requests) or coding_agent (for coding assistants)

ownershipstringDefault: personal

For 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_assistantstring

Required 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

modelsarray

Optional 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_usageinteger

Optional 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: monthly

The window max_usage applies to. Options: daily, monthly, all_time. See Usage limits & budgets.

expires_in_daysinteger

Optional expiration time in days from creation. Ordinary personal and service keys default to 90 days.

emailstring

Assignee email for a coding-agent key. Not accepted for service keys.

compressionobject

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

fallbacksarray

Ordered list of models to try when the requested model's provider fails.

reroutesarray

Ordered list of models to serve instead of the requested model. When set, the requested model is never contacted.

byok_onlyboolean

When 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

objectstring

The object type (always "ai_gateway_api_key")

idstring

Unique identifier for this API key

organization_idstring

The organization this key belongs to

namestring

The name of this API key

typestring

The type of API key ("api" or "coding_agent")

ownershipstring

personal or service for ordinary Gateway API keys.

created_by_user_idstring

Server-recorded creator of a service key. Audit metadata only, not runtime ownership.

created_by_emailstring

Creator email recorded at service-key creation. Audit metadata only.

coding_assistantstring

The coding assistant this key is for (if type is "coding_agent")

modelsarray

List of model restrictions (if any)

max_usageinteger

Usage limit in USD (if set)

max_usage_periodstring

The window max_usage applies to: daily, monthly, or all_time

activeboolean

Whether this key is currently active

debug_modeboolean

Whether debug mode is enabled for this key

created_atstring

ISO 8601 timestamp when the key was created

expires_atstring

ISO 8601 timestamp when the key will expire (if set)

last_used_atstring

ISO 8601 timestamp of the last usage (if ever used)

keystring

The secret returned by the one-time reveal endpoint or a successful rotation. The creation response contains metadata, not the secret.

Examples

Request examples

Create API Key
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
  }'
Create Service Key
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"}'
Create Coding Agent Key
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"
  }'
List All Keys
curl "https://api.edgee.app/v1/organizations/{orgId}/api_keys" \
  -H "Authorization: Bearer <your_console_api_token>"
Update Key
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
  }'
Delete Key
curl -X DELETE "https://api.edgee.app/v1/organizations/{orgId}/api_keys/{apiKeyId}" \
  -H "Authorization: Bearer <your_console_api_token>"
Reveal Key
curl "https://api.edgee.app/v1/organizations/{orgId}/api_keys/{apiKeyId}/reveal" \
  -H "Authorization: Bearer <your_console_api_token>"
Rotate Service Key
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 models field to restrict which models a key can access, useful for controlling access and managing costs
  • Usage Limits: Set max_usage with a max_usage_period to cap spend per day, per month, or for the key's lifetime
  • Expiration: Use expires_in_days to 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 /roll to 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