latestOpenAPI 3.1.02026-08-236994571.1 MB

79928a3d37d3

key management

Regenerate Key Fn

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:

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.

post/key/{key}/regenerate

Path parameters

keystring nullable required

Headers

litellm-changed-bystring 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

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

key_aliasstring nullable
durationstring nullable
spendnumber nullable
max_budgetnumber nullable
user_idstring nullable
team_idstring nullable
agent_idstring nullable
max_parallel_requestsinteger nullable
metadataobject nullable
tpm_limitinteger nullable
rpm_limitinteger nullable
budget_durationstring nullable
configobject nullable
permissionsobject nullable
model_max_budgetobject nullable
model_rpm_limitobject nullable
model_tpm_limitobject nullable
guardrailsstring[] nullable
policiesstring[] nullable
promptsstring[] nullable
blockedboolean nullable
aliasesobject nullable
keystring nullable
budget_idstring nullable
tagsstring[] nullable
enforced_paramsstring[] nullable
rpm_limit_type'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic' nullable
tpm_limit_type'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic' nullable
access_group_idsstring[] nullable
soft_budgetnumber nullable
send_invite_emailboolean nullable
key_type'llm_api' | 'management' | 'read_only' | 'default'

Enum for key types that determine what routes a key can access

auto_rotateboolean nullable

Whether this key should be automatically rotated

rotation_intervalstring nullable

How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True

organization_idstring nullable
project_idstring nullable
new_keystring nullable
new_master_keystring nullable
grace_periodstring nullable

Response

Successful Response

key_aliasstring nullable
durationstring nullable
spendnumber nullable
max_budgetnumber nullable
user_idstring nullable
team_idstring nullable
agent_idstring nullable
max_parallel_requestsinteger nullable
metadataobject nullable
tpm_limitinteger nullable
rpm_limitinteger nullable
budget_durationstring nullable
configobject nullable
permissionsobject nullable
model_max_budgetobject nullable
model_rpm_limitobject nullable
model_tpm_limitobject nullable
guardrailsstring[] nullable
policiesstring[] nullable
promptsstring[] nullable
blockedboolean nullable
aliasesobject nullable
keystring required
budget_idstring nullable
tagsstring[] nullable
enforced_paramsstring[] nullable
rpm_limit_type'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic' nullable
tpm_limit_type'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic' nullable
access_group_idsstring[] nullable
key_namestring nullable
expiresstring date-time nullable
token_idstring nullable
organization_idstring nullable
project_idstring nullable
{"stackTrail":"components:schemas:GenerateKeyResponse:properties:litellm_budget_table:anyOf","oasType":"schema","type":"unknown","title":"Litellm Budget Table","nullable":true}
tokenstring nullable
created_bystring nullable
updated_bystring nullable
created_atstring date-time nullable
updated_atstring date-time nullable