---
title: "create llm_gateway_key"
method: POST
path: "/llm_gateway_keys"
tags: ["LlmGatewayKeys"]
---

# create llm_gateway_key

`POST /llm_gateway_keys`

## Request

- Base URL: `https://api.aptible.com`
- URL: `https://api.aptible.com/llm_gateway_keys`
- Auth: API key in header `Authorization`

Creates a key for an organization. The secret token is returned in this response
only and cannot be retrieved afterwards.

## Query parameters

- `no_embed` boolean

## Headers

- `Prefer` 'no_sensitive_extras=true'

## Request body

- CreateLlmGatewayKeyRequest
  - `handle` string, required: Handle for the key, unique within the organization
  - `note` string: Note about the key, up to 256 characters
  - `spend_limit` number: Spend limit in USD for this key. Must not exceed the organization's spend_limit. Omit it, or send null, for a key with no limit of its own.
  - `organization_id` string: The organization to create the key in. Required unless the caller belongs to exactly one organization, in which case it is inferred from the token.

## Response `201`

created

- LlmGatewayKey
  - `id` integer, required: Database ID of the LLM Gateway Key
  - `_type` string, required
  - `handle` string, required: User-provided handle for the key (unique within the organization)
  - `note` string, required: User-provided note
  - `spend_limit` string, required: Spend limit in USD for this key (decimal, serialized as string). Null means the key has no limit of its own. Never exceeds the organization's spend_limit: lowering that lowers any key that was above it.
  - `organization_id` string, required: The organization this key belongs to
  - `created_at` string, dateTime, required
  - `updated_at` string, dateTime, required
  - `gateway_url` string, required: Customer-facing LLM Gateway endpoint URL
  - `token_prefix` string, required: The first characters of the key's token, safe to display and enough to tell keys apart
  - `created_by` object, required: User who created the key
  - `revoked_at` string, dateTime, required: Timestamp when the key was revoked
  - `revoked_by` object, required: User who revoked the key
  - `status` string, required: Key status (ACTIVE or REVOKED)
  - `token` string: Secret API key value (only present on creation)
  - `_links` LlmGatewayKeyLinks
    - `operations` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri
    - `self` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri

## Other responses

- `403`: organization not enrolled, or the caller has not accepted the LLM usage agreement
- `422`: invalid handle or spend_limit
- `default`: Error response. Often a 4xx or 5xx status code

## Changes

- **2026-10-20** `ba72edfe0324`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/aptible/apis/aptible-api-v1/changes/llm_gateway_keys/post.md)

---

[API](https://skmtc.dev/aptible/apis/aptible-api-v1.md) - [All operations](https://skmtc.dev/aptible/apis/aptible-api-v1/llms.txt) - [OpenAPI document](https://skmtc.dev/aptible/apis/aptible-api-v1/revisions/a21f6b1bc6fe?raw)
