---
title: "POST /ai/providers"
method: POST
path: "/ai/providers"
tags: ["AI Gateway Admin"]
---

# POST /ai/providers

`POST /ai/providers`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/ai/providers`
- Auth: HTTP bearer

## Request body

- CreateProviderKeyRequest
  - `api_key` string, password: Provider API key. Optional only for self-hosted providers that run without authentication.
  - `base_url` string, nullable: Required for "openai_compatible", e.g. "http://10.0.0.5:8000/v1".
  - `capabilities` SelfHostedCapabilities, nullable: Capabilities an administrator declared for a self-hosted key. Requests needing an undeclared capability are refused before anything is sent.
    - `embeddings` boolean: The `/embeddings` endpoint.
    - `responses_api` boolean: The OpenAI Responses API (`/responses`).
    - `streaming` boolean: Streaming chat completions (`"stream": true`). Required by AI chat.
    - `tools` boolean: Function/tool calling in chat completions.
  - `default_model` string, nullable: Model id to pin for this provider (e.g. "gpt-6.2-sol"). Required for "openai_compatible": it must be one of the models the server lists (see `POST /ai/providers/discover`), and is used to verify the key.
  - `display_name` string, required
  - `provider` string, required: "openai", "anthropic", "xai", "gemini", "openrouter", or "openai_compatible" for a self-hosted OpenAI-compatible server.
  - `trust_private_address` boolean: Trust the exact private `ip:port` of `base_url` for this key only, without adding it to the instance-wide trusted private networks. Requires the `settings:write` permission; the base URL must use an IP address. Cloud metadata and link-local addresses can never be trusted.

## Response `201`

Provider key created

- ProviderKeyResponse
  - `api_key_masked` string, required: Masked API key (only last 4 chars visible)
  - `base_url` string, nullable
  - `capabilities` SelfHostedCapabilities, nullable: Capabilities an administrator declared for a self-hosted key. Requests needing an undeclared capability are refused before anything is sent.
    - `embeddings` boolean: The `/embeddings` endpoint.
    - `responses_api` boolean: The OpenAI Responses API (`/responses`).
    - `streaming` boolean: Streaming chat completions (`"stream": true`). Required by AI chat.
    - `tools` boolean: Function/tool calling in chat completions.
  - `created_at` string, required
  - `default_model` string, nullable: Model id this provider serves (NULL → per-provider default).
  - `display_name` string, required
  - `id` integer, required
  - `is_active` boolean, required
  - `provider` string, required
  - `trusted_private_address` string, nullable: Exact private `ip:port` this key may reach without that address being in the instance-wide trusted private networks. `None` when not set.
  - `trusted_private_address_set_at` string, nullable: When the per-key trust was set (ISO 8601).
  - `trusted_private_address_set_by` integer, nullable: User who set the per-key trust.
  - `updated_at` string, required

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Insufficient permissions

## Changes

- **2026-11-09** `12896146b193`: 3 breaking
  - removed the required property `extensions` from the response with the `400` status
  - removed the required property `extensions` from the response with the `401` status
  - removed the required property `extensions` from the response with the `403` status
- **2026-10-23** `7d41b820a372`: 1 breaking
  - the `api_key` request property format changed from no format to `password`
- **2026-10-23** `24af93ff5379`: 1 info
  - the `api_key` request property format was generalized from `password` to no format
- **2026-10-22** `842d42ed4659`: 1 breaking
  - the `api_key` request property format changed from no format to `password`
- **2026-10-22** `1a12a50b75ee`: 1 info
  - the `api_key` request property format was generalized from `password` to no format

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/ai/providers/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
