> ## Documentation Index
> Fetch the complete documentation index at: https://www.edgee.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage Gateway API Keys

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

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.

> [!WARNING]
>
> These endpoints manage **Gateway API keys** for the AI Gateway API (`edgee.io`), 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`, `claude_desktop`, `opencode`, `codex`, `codex_desktop`, `cursor`, `copilot`, `crush`, `codebuddy`, `pi`, `kimi`, `kilo`

**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 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\_period** `string` (default: monthly)

The window `max_usage` applies to. Options: `daily`, `monthly`, `all_time`. See [Usage limits & budgets](https://www.edgee.ai/docs/features/usage-limits.md).

**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).

**compression** `object`

Per-key [token compression](https://www.edgee.ai/docs/features/token-compression.md) 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.

**fallbacks** `array`

Ordered list of models to try when the requested model's provider fails. See [Retry, Fallback & Reroute](https://www.edgee.ai/docs/features/retry-and-fallback.md).

**reroutes** `array`

Ordered list of models to serve **instead of** the requested model. When set, the requested model is never contacted. See [Reroute](https://www.edgee.ai/docs/features/retry-and-fallback.md#reroute).

**byok\_only** `boolean`

When true, the key may only use [BYOK](https://www.edgee.ai/docs/features/byok.md) provider keys. Requests for models with no matching BYOK credentials are rejected.

> [!NOTE]
>
> Settings resolve **organization > squad > key**. A value set at a higher scope overrides what you
> set here — see [how settings resolve](https://www.edgee.ai/docs/features/organization.md#understand-on-off-and-inherit).

## 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`

Usage limit in USD (if set)

**max\_usage\_period** `string`

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

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

```bash Create API Key theme={"dark"}
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
  }'
```

```bash Create Coding Agent Key theme={"dark"}
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"
  }'
```

```bash List All Keys theme={"dark"}
curl "https://api.edgee.app/v1/organizations/{orgId}/api_keys" \
  -H "Authorization: Bearer <your_console_api_token>"
```

```bash Update Key theme={"dark"}
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
  }'
```

```bash Delete Key theme={"dark"}
curl -X DELETE "https://api.edgee.app/v1/organizations/{orgId}/api_keys/{apiKeyId}" \
  -H "Authorization: Bearer <your_console_api_token>"
```

```bash Reveal Key theme={"dark"}
curl "https://api.edgee.app/v1/organizations/{orgId}/api_keys/{apiKeyId}/reveal" \
  -H "Authorization: Bearer <your_console_api_token>"
```

```json theme={"dark"}
{
  "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",
  "key": "ek_live_abc123xyz..."
}
```

## 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**: 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

* Learn how to [authenticate to the Gateway API](https://www.edgee.ai/docs/llm-router/api-reference/authentication.md)
* Explore [Chat Completions](https://www.edgee.ai/docs/llm-router/api-reference/chat-completion.md) to make LLM requests
* Set up [alerts](https://www.edgee.ai/docs/features/alerts.md) to monitor costs associated with your API keys


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.