latestOpenAPI 3.1.02026-08-197104501.1 MB

8fbaab4fc7c5

key management

Update Key Fn

Update an existing API key's parameters.

Parameters:

  • key: str - The key to update
  • 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
  • agent_id: Optional[str] - The agent id associated with the key.
  • organization_id: Optional[str] - The organization id of the key.
  • budget_id: Optional[str] - The budget id associated with the key. Created by calling /budget/new.
  • models: Optional[list] - Model_name's a user is allowed to call
  • tags: Optional[List[str]] - Tags for organizing keys (Enterprise only)
  • prompts: Optional[List[str]] - List of prompts that the key is allowed to use.
  • enforced_params: Optional[List[str]] - List of enforced params for the key (Enterprise only). Docs
  • 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] - [TODO] 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}
  • tpm_limit_type: Optional[str] - TPM rate limit type - "best_effort_throughput", "guaranteed_throughput", or "dynamic"
  • rpm_limit_type: Optional[str] - RPM rate limit type - "best_effort_throughput", "guaranteed_throughput", or "dynamic"
  • allowed_cache_controls: Optional[list] - List of allowed cache control values
  • duration: Optional[str] - Key validity duration ("30d", "1h", etc.), null to never expire, or "-1" to never expire (deprecated, use null)
  • permissions: Optional[dict] - Key-specific permissions
  • send_invite_email: Optional[bool] - Send invite email to user_id
  • guardrails: Optional[List[str]] - List of active guardrails for the key
  • policies: Optional[List[str]] - List of policy names to apply to the key. Policies define guardrails, conditions, and inheritance rules.
  • disable_global_guardrails: Optional[bool] - Whether to disable global guardrails for the key.
  • prompts: Optional[List[str]] - List of prompts that the key is allowed to use.
  • blocked: Optional[bool] - Whether the key is blocked
  • aliases: Optional[dict] - Model aliases for the key - Docs
  • config: Optional[dict] - [DEPRECATED PARAM] Key-specific config.
  • temp_budget_increase: Optional[float] - Temporary budget increase for the key (Enterprise only).
  • temp_budget_expiry: Optional[str] - Expiry time for the temporary budget increase (Enterprise only).
  • allowed_routes: Optional[list] - List of allowed routes for the key. Store the actual route or store a wildcard pattern for a set of routes. Example - ["/chat/completions", "/embeddings", "/keys/*"]
  • allowed_passthrough_routes: Optional[list] - List of allowed pass through routes for the key. Store the actual route or store a wildcard pattern for a set of routes. Example - ["/my-custom-endpoint"]. Use this instead of allowed_routes, if you just want to specify which pass through routes the key can access, without specifying the routes. If allowed_routes is specified, allowed_passthrough_routes is ignored.
  • prompts: Optional[List[str]] - List of allowed prompts for the key. If specified, the key will only be able to use these specific prompts.
  • object_permission: Optional[LiteLLM_ObjectPermissionBase] - key-specific object permission. Example - {"vector_stores": ["vector_store_1", "vector_store_2"], "agents": ["agent_1", "agent_2"], "agent_access_groups": ["dev_group"]}. IF null or {} then no object permission.
  • auto_rotate: Optional[bool] - Whether this key should be automatically rotated
  • rotation_interval: Optional[str] - How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True
  • allowed_vector_store_indexes: Optional[List[dict]] - List of allowed vector store indexes for the key. Example - [{"index_name": "my-index", "index_permissions": ["write", "read"]}]. If specified, the key will only be able to use these specific vector store indexes. Create index, using /v1/indexes endpoint.
  • router_settings: Optional[UpdateRouterConfig] - key-specific router settings. Example - {"model_group_retry_policy": {"max_retries": 5}}. IF null or {} then no router settings.
  • access_group_ids: Optional[List[str]] - List of access group IDs to associate with the key. Access groups define which models a key can access. Example - ["access_group_1", "access_group_2"].
  • budget_limits: Optional[list] - List of concurrent budget windows for the key. Each window specifies a budget_limit, time_period, and optional budget_duration. Example - [{"budget_limit": 10.0, "time_period": "1d"}, {"budget_limit": 50.0, "time_period": "7d"}].

Example:

curl --location 'http://0.0.0.0:4000/key/update'     --header 'Authorization: Bearer sk-1234'     --header 'Content-Type: application/json'     --data '{
    "key": "sk-1234",
    "key_alias": "my-key",
    "user_id": "user-1234",
    "team_id": "team-1234",
    "max_budget": 100,
    "metadata": {"any_key": "any-val"},
}'
post/key/update

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 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
temp_budget_increasenumber nullable
temp_budget_expirystring date-time nullable
auto_rotateboolean nullable
rotation_intervalstring nullable
organization_idstring nullable

Response

Successful Response

{"stackTrail":"paths:/key/update:post:responses:200:content:application/json:schema","oasType":"schema","type":"unknown"}