# Change an AI provider key

```http
PATCH https://trydimmi.com/api/v1/ai/keys/{key}
```

## Authorization

Send an API token as `Authorization: Bearer <token>`.
The token needs: `ai:keys`.

## Path parameters

- `key` (string, required): Id of the AI provider key, starting with aik_, such as aik_01jx2m8k4t. Find it with GET /ai/keys.

## Body

- `api_key` (string): A new secret to replace the stored one; leave out to keep it.
- `base_url` (string): The address every request starts with, such as https://api.example.com.
- `config` (object): Provider settings, as an object that replaces the saved one. Keys dimmi reads: anthropic_version, max_tokens_field (text); supports_tools, supports_stream_usage, json_schema, prompt_cache (true or false); context_tokens, max_output_tokens (numbers). Such as {"supports_tools": false, "context_tokens": 32000}.
- `name` (string): The name of the key, at most 60 characters.

## Response 200 (OK)

- `data` (object, required)
  - `auth_type` (string, required): How the connection signs in to the provider: api_key, aws_iam, bedrock_api_key, none, managed or oauth.
  - `base_url` (string | null, required): The provider's address for this connection, for providers that need one. Null when the provider's default is used.
  - `created_at` (string, required): When it was created, as an RFC 3339 time, such as 2026-01-31T09:00:00Z.
  - `id` (string, required): The id of this record. Send it wherever an endpoint asks for this record; never use its name or title in its place.
  - `key_hint` (string | null, required): Dots and the last four characters of the stored key, such as ••••a1b2, to tell keys apart. Null when no key is stored.
  - `last_used_at` (string | null, required): When the connection was last used for a model call. Null when never.
  - `last_validated_at` (string | null, required): When the connection was last checked against the provider. Null when never.
  - `models` (string[] | null, required): Ids of the models the provider offered when the connection last validated. Empty when it listed none.
  - `models_count` (integer, required): How many models are in the models list.
  - `name` (string, required): The name the team gave this provider connection.
  - `object` (string, required): The kind of record this is, the same for every record of its kind, such as article.
  - `provider` (string, required): Which model provider this connects to, such as dimmi (built in), anthropic, openai, chatgpt or openai_compatible.
  - `region` (string | null, required): The provider region this connection uses, for providers that have regions. Null otherwise.
  - `source` (string, required): Where the connection came from: dashboard, api, env or system.
  - `status` (string, required): Whether the connection works: unverified (never checked), valid, invalid or error.
  - `status_reason` (string | null, required): A short safe explanation of the status, such as "never validated" or "connected". Null when there is none.
  - `updated_at` (string, required): When it last changed, as an RFC 3339 time, such as 2026-01-31T09:00:00Z.

## Response default (Error)

- `code` (string, required): Stable code for programs to tell errors apart, such as validation_failed or internal_error.
- `errors` (object): Each rejected field mapped to its messages. Only present when the input was invalid.
- `message` (string, required): What went wrong, in words safe to show a person.

## Example request

```bash
curl --request PATCH \
  --url 'https://trydimmi.com/api/v1/ai/keys/{key}' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "api_key": "<string>",
  "base_url": "https://example.com",
  "config": {
    "<key>": null
  },
  "name": "<string>"
}'
```

## Example response

```json
{
  "data": {
    "auth_type": "<string>",
    "base_url": "<string>",
    "created_at": "2026-11-01T09:30:00Z",
    "id": "<string>",
    "key_hint": "<string>",
    "last_used_at": "2026-11-01T09:30:00Z",
    "last_validated_at": "2026-11-01T09:30:00Z",
    "models": [
      "<string>"
    ],
    "models_count": 123,
    "name": "<string>",
    "object": "<string>",
    "provider": "<string>",
    "region": "<string>",
    "source": "<string>",
    "status": "<string>",
    "status_reason": "<string>",
    "updated_at": "2026-11-01T09:30:00Z"
  }
}
```

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
