---
title: "Store one of your model provider keys"
method: POST
path: "/api/v1/model-keys"
tags: ["model-gateway"]
---

# Store one of your model provider keys

`POST /api/v1/model-keys`

## Request

- Base URL: `https://worthune.com`
- URL: `https://worthune.com/api/v1/model-keys`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-Api-Key`

Sealed before storage (envelope encryption bound to your organization) and never returned. A baseUrl, required for openai-compatible and azure-openai, must be HTTPS on a public host.

## Request body

- object
  - `provider` 'anthropic' | 'gemini' | 'openai-compatible' | 'azure-openai', required
  - `label` string, required
  - `key` string, required
  - `baseUrl` string: e.g. https://api.openai.com/v1, a Kimi or self-hosted endpoint, or https://<resource>.openai.azure.com/openai/v1.

## Response `201`

Stored.

- object
  - `ok` unknown, required
  - `key` ModelKey, required
    - `id` integer, required
    - `provider` 'anthropic' | 'gemini' | 'openai-compatible' | 'azure-openai', required
    - `label` string, required
    - `baseUrl` string, nullable, required
    - `hint` string, required: The key's last four characters. The key itself is never returned.
    - `createdAt` string, date-time, required
    - `lastUsedAt` string, date-time, nullable, required
  - `note` string, required

## Other responses

- `400`: Malformed JSON, a body of the wrong shape, or a top-level field that fails its check.
- `401`: No key presented (Authorization: Bearer wk_… or X-Api-Key).
- `402`: Unrecognized or revoked API key.
- `403`: The key's role is below the operation's floor (viewer < developer < owner), the key predates organization support, or the plan lacks the feature. On a sandbox key, also: the cap of 5 active households on create and import, the cap of 1 active Lodestar mandate, and the white-label surfaces (tenant config, embed tokens) and narration or mapping drafts on Worthune's model (they run on your own: a model assigned at /api/v1/model-policy, or x-model-key), which the sandbox does not carry.
- `422`: Invalid provider, label, key shape or endpoint.
- `429`: Hourly per-org stateful quota, a per-route durable limit, or the 120 requests/minute per-IP burst backstop.
- `503`: Billing is not configured on this deployment; household resources are disabled rather than served without tenancy (production fail-closed).

---

[API](https://skmtc.dev/worthune/apis/worthune-api.md) · [All operations](https://skmtc.dev/worthune/apis/worthune-api/llms.txt) · [OpenAPI document](https://skmtc.dev/worthune/apis/worthune-api/revisions/9f2241072555?raw)
