---
title: "Regenerate Key Fn"
method: POST
path: "/key/regenerate"
tags: ["key management"]
---

# Regenerate Key Fn

`POST /key/regenerate`

Regenerate an existing API key while optionally updating its parameters.

Parameters:
- key: str (path parameter) - The key to regenerate
- data: Optional[RegenerateKeyRequest] - Request body containing optional parameters to update
    - key: Optional[str] - The key to regenerate.
    - new_master_key: Optional[str] - The new master key to use, if key is the master key.
    - new_key: Optional[str] - The new key to use, if key is not the master key. If both set, new_master_key will be used.
    - key_alias: Optional[str] - User-friendly key alias
    - user_id: Optional[str] - User ID associated with key
    - team_id: Optional[str] - Team ID associated with key
    - models: Optional[list] - Model_name's a user is allowed to call
    - tags: Optional[List[str]] - Tags for organizing keys (Enterprise only)
    - spend: Optional[float] - Amount spent by key
    - max_budget: Optional[float] - Max budget for key
    - model_max_budget: Optional[Dict[str, BudgetConfig]] - Model-specific budgets {"gpt-4": {"budget_limit": 0.0005, "time_period": "30d"}}
    - budget_duration: Optional[str] - Budget reset period ("30d", "1h", etc.)
    - soft_budget: Optional[float] - Soft budget limit (warning vs. hard stop). Will trigger a slack alert when this soft budget is reached.
    - max_parallel_requests: Optional[int] - Rate limit for parallel requests
    - metadata: Optional[dict] - Metadata for key. Example {"team": "core-infra", "app": "app2"}
    - tpm_limit: Optional[int] - Tokens per minute limit
    - rpm_limit: Optional[int] - Requests per minute limit
    - model_rpm_limit: Optional[dict] - Model-specific RPM limits {"gpt-4": 100, "claude-v1": 200}
    - model_tpm_limit: Optional[dict] - Model-specific TPM limits {"gpt-4": 100000, "claude-v1": 200000}
    - allowed_cache_controls: Optional[list] - List of allowed cache control values
    - duration: Optional[str] - Key validity duration ("30d", "1h", etc.)
    - permissions: Optional[dict] - Key-specific permissions
    - guardrails: Optional[List[str]] - List of active guardrails for the key
    - blocked: Optional[bool] - Whether the key is blocked
    - grace_period: Optional[str] - Duration to keep old key valid after rotation (e.g. "24h", "2d"). Omitted = immediate revoke. Env: LITELLM_KEY_ROTATION_GRACE_PERIOD


Returns:
- GenerateKeyResponse containing the new key and its updated parameters

Example:
```bash
curl --location --request POST 'http://localhost:4000/key/sk-1234/regenerate'     --header 'Authorization: Bearer sk-1234'     --header 'Content-Type: application/json'     --data-raw '{
    "max_budget": 100,
    "metadata": {"team": "core-infra"},
    "models": ["gpt-4", "gpt-3.5-turbo"]
}'
```

Note: This is an Enterprise feature. It requires a premium license to use.

## Query parameters

- `key` string, nullable

## Headers

- `litellm-changed-by` string, nullable — The litellm-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability

## Request body

- RegenerateKeyRequest
  - `key_alias` string, nullable
  - `duration` string, nullable
  - `models` unknown[], nullable
    - unknown
  - `spend` number, nullable
  - `max_budget` number, nullable
  - `user_id` string, nullable
  - `team_id` string, nullable
  - `agent_id` string, nullable
  - `max_parallel_requests` integer, nullable
  - `metadata` object, nullable
  - `tpm_limit` integer, nullable
  - `rpm_limit` integer, nullable
  - `budget_duration` string, nullable
  - `allowed_cache_controls` unknown[], nullable
    - unknown
  - `config` object, nullable
  - `permissions` object, nullable
  - `model_max_budget` object, nullable
  - `model_rpm_limit` object, nullable
  - `model_tpm_limit` object, nullable
  - `guardrails` string[], nullable
  - `policies` string[], nullable
  - `prompts` string[], nullable
  - `blocked` boolean, nullable
  - `aliases` object, nullable
  - `object_permission` LiteLLMObjectPermissionBase
    - `mcp_servers` string[], nullable
    - `mcp_access_groups` string[], nullable
    - `mcp_tool_permissions` object, nullable
    - `vector_stores` string[], nullable
    - `agents` string[], nullable
    - `agent_access_groups` string[], nullable
    - `models` string[], nullable
  - `key` string, nullable
  - `budget_id` string, nullable
  - `tags` string[], nullable
  - `enforced_params` string[], nullable
  - `allowed_routes` unknown[], nullable
    - unknown
  - `allowed_passthrough_routes` unknown[], nullable
    - unknown
  - `allowed_vector_store_indexes` AllowedVectorStoreIndexItem[], nullable
    - `index_name` string, required
    - `index_permissions` string[], required
  - `rpm_limit_type` 'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic', nullable
  - `tpm_limit_type` 'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic', nullable
  - `router_settings` UpdateRouterConfig — Set of params that you can modify via `router.update_settings()`.
    - `routing_strategy_args` object, nullable
    - `routing_strategy` string, nullable
    - `model_group_retry_policy` object, nullable
    - `allowed_fails` integer, nullable
    - `cooldown_time` number, nullable
    - `num_retries` integer, nullable
    - `timeout` number, nullable
    - `max_retries` integer, nullable
    - `retry_after` number, nullable
    - `fallbacks` object[], nullable
    - `context_window_fallbacks` object[], nullable
    - `model_group_alias` object, nullable
  - `access_group_ids` string[], nullable
  - `soft_budget` number, nullable
  - `send_invite_email` boolean, nullable
  - `key_type` 'llm_api' | 'management' | 'read_only' | 'default' — Enum for key types that determine what routes a key can access
  - `auto_rotate` boolean, nullable — Whether this key should be automatically rotated
  - `rotation_interval` string, nullable — How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True
  - `organization_id` string, nullable
  - `project_id` string, nullable
  - `new_key` string, nullable
  - `new_master_key` string, nullable
  - `grace_period` string, nullable

## Response `200`

Successful Response

- GenerateKeyResponse
  - `key_alias` string, nullable
  - `duration` string, nullable
  - `models` unknown[], nullable
    - unknown
  - `spend` number, nullable
  - `max_budget` number, nullable
  - `user_id` string, nullable
  - `team_id` string, nullable
  - `agent_id` string, nullable
  - `max_parallel_requests` integer, nullable
  - `metadata` object, nullable
  - `tpm_limit` integer, nullable
  - `rpm_limit` integer, nullable
  - `budget_duration` string, nullable
  - `allowed_cache_controls` unknown[], nullable
    - unknown
  - `config` object, nullable
  - `permissions` object, nullable
  - `model_max_budget` object, nullable
  - `model_rpm_limit` object, nullable
  - `model_tpm_limit` object, nullable
  - `guardrails` string[], nullable
  - `policies` string[], nullable
  - `prompts` string[], nullable
  - `blocked` boolean, nullable
  - `aliases` object, nullable
  - `object_permission` LiteLLMObjectPermissionBase
    - `mcp_servers` string[], nullable
    - `mcp_access_groups` string[], nullable
    - `mcp_tool_permissions` object, nullable
    - `vector_stores` string[], nullable
    - `agents` string[], nullable
    - `agent_access_groups` string[], nullable
    - `models` string[], nullable
  - `key` string, required
  - `budget_id` string, nullable
  - `tags` string[], nullable
  - `enforced_params` string[], nullable
  - `allowed_routes` unknown[], nullable
    - unknown
  - `allowed_passthrough_routes` unknown[], nullable
    - unknown
  - `allowed_vector_store_indexes` AllowedVectorStoreIndexItem[], nullable
    - `index_name` string, required
    - `index_permissions` string[], required
  - `rpm_limit_type` 'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic', nullable
  - `tpm_limit_type` 'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic', nullable
  - `router_settings` UpdateRouterConfig — Set of params that you can modify via `router.update_settings()`.
    - `routing_strategy_args` object, nullable
    - `routing_strategy` string, nullable
    - `model_group_retry_policy` object, nullable
    - `allowed_fails` integer, nullable
    - `cooldown_time` number, nullable
    - `num_retries` integer, nullable
    - `timeout` number, nullable
    - `max_retries` integer, nullable
    - `retry_after` number, nullable
    - `fallbacks` object[], nullable
    - `context_window_fallbacks` object[], nullable
    - `model_group_alias` object, nullable
  - `access_group_ids` string[], nullable
  - `key_name` string, nullable
  - `expires` string, date-time, nullable
  - `token_id` string, nullable
  - `organization_id` string, nullable
  - `project_id` string, nullable
  - `litellm_budget_table` unknown
  - `token` string, nullable
  - `created_by` string, nullable
  - `updated_by` string, nullable
  - `created_at` string, date-time, nullable
  - `updated_at` string, date-time, nullable

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/sea-lion/apis/litellm-api.md) · [All operations](https://skmtc.net/sea-lion/apis/litellm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sea-lion/litellm-api/revisions/79928a3d37d3/schema)
