Skip to main content
POST
/
v1
/
organizations
/
{orgId}
/
api_keys
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,
    "expires_in_days": 90
  }'
{
  "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,
  "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",
  "key": "ek_live_abc123xyz..."
}
Manage your AI Gateway API keys programmatically. Gateway API keys are used to authenticate requests to the Edgee AI Gateway API (https://api.edgee.ai) for making LLM requests.
These endpoints manage Gateway API keys for the AI Gateway API (api.edgee.ai), not the Console API tokens. Do not confuse these two systems.

Request Body

name
string
required
A descriptive name for this API key (e.g., “Production Backend”, “Development Client”)
type
string
default:"api"
The type of API key. Options: api (for Gateway requests) or coding_agent (for coding assistants)
coding_assistant
string
Required if type is coding_agent. Specifies which coding assistant this key is for.Options: claude_code, opencode, codex
models
array
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_usage
integer
Optional monthly usage limit in USD. If specified, this key will stop working after reaching this cost threshold.
expires_in_days
integer
Optional expiration time in days from creation. After this period, the key will stop working.
email
string
Optional email address associated with this key (for organization/billing tracking).

Response

object
string
The object type (always “ai_gateway_api_key”)
id
string
Unique identifier for this API key
organization_id
string
The organization this key belongs to
name
string
The name of this API key
type
string
The type of API key (“api” or “coding_agent”)
coding_assistant
string
The coding assistant this key is for (if type is “coding_agent”)
models
array
List of model restrictions (if any)
max_usage
integer
Monthly usage limit in USD (if set)
active
boolean
Whether this key is currently active
debug_mode
boolean
Whether debug mode is enabled for this key
created_at
string
ISO 8601 timestamp when the key was created
expires_at
string
ISO 8601 timestamp when the key will expire (if set)
last_used_at
string
ISO 8601 timestamp of the last usage (if ever used)
key
string
The actual API key (only shown once at creation or when using the reveal endpoint)

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,
    "expires_in_days": 90
  }'
{
  "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,
  "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",
  "key": "ek_live_abc123xyz..."
}

Tips

  • API Keys vs Console Tokens: Gateway API keys are used to authenticate requests to the Gateway API (api.edgee.ai), 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 to automatically disable a key after spending a certain amount
  • Expiration: Use expires_in_days to automatically revoke keys after a set period for security rotation
  • Key Visibility: Once created, the key is only shown once. Use the reveal endpoint if you need to see it again, but the key must already exist

Next Steps