Update

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
  • 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)
  • 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}
  • 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
  • send_invite_email: Optional[bool] - Send invite email to user_id
  • guardrails: Optional[List[str]] - List of active guardrails for the key
  • 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).

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
Authorization
Header parameters
Body
key_aliasKey Alias
durationDuration
modelsModels
spendSpend
max_budgetMax Budget
user_idUser Id
team_idTeam Id
max_parallel_requestsMax Parallel Requests
metadataMetadata
tpm_limitTpm Limit
rpm_limitRpm Limit
budget_durationBudget Duration
allowed_cache_controlsAllowed Cache Controls
configConfig
permissionsPermissions
model_max_budgetModel Max Budget
model_rpm_limitModel Rpm Limit
model_tpm_limitModel Tpm Limit
guardrailsGuardrails
blockedBlocked
aliasesAliases
key*Key
budget_idBudget Id
tagsTags
enforced_paramsEnforced Params
temp_budget_increaseTemp Budget Increase
temp_budget_expiryTemp Budget Expiry
Response

Successful Response

Body
any
Request
const response = await fetch('/key/update', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "key": "text"
    }),
});
const data = await response.json();
Response
{
  "detail": [
    {
      "loc": [
        "text"
      ],
      "msg": "text",
      "type": "text"
    }
  ]
}