Skip to main content
Check out the configuration docs for LiteLLM API Key Rotations to learn how to obtain the required parameters.
Creates a LiteLLM API Key secret rotation. Infisical will create and rotate API keys via your LiteLLM connection and write them to the specified secret path.

Request body

FieldTypeRequiredDescription
namestringYesA unique name for the rotation (max 100 characters).
projectIdstring (UUID)YesThe project ID.
connectionIdstring (UUID)YesID of the LiteLLM app connection (management-capable API key).
environmentstringYesEnvironment slug (e.g. dev, prod).
secretPathstringYesPath where the generated API key secret will be stored.
isAutoRotationEnabledbooleanYesWhether to rotate automatically on the schedule.
rotationIntervalnumberYesDays between rotations (e.g. 30).
rotateAtUtcobjectYesTime of day (UTC) to run rotation: { "hours", "minutes" }.
parameters.namestringYesName for the generated key in LiteLLM (max 100 characters). Infisical appends a timestamp to keep each key unique.
parameters.userIdstringNoLiteLLM user ID to associate the generated key with.
parameters.teamIdstringNoLiteLLM team ID to associate the generated key with.
parameters.modelsstring[]NoModel names the key is allowed to access. An empty list allows all models.
parameters.additionalOptionsstring (JSON)NoA JSON object of additional /key/generate options (e.g. max_budget, tpm_limit, rpm_limit, metadata).
secretsMapping.apiKeystringYesSecret key name to store the generated API key (e.g. LITELLM_API_KEY).
descriptionstringNoOptional description.

Sample request

curl --request POST \
  --url https://us.infisical.com/api/v2/secret-rotations/litellm-api-key \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <ACCESS_TOKEN>' \
  --data '{
    "name": "my-litellm-rotation",
    "projectId": "<project-id>",
    "description": "LiteLLM API key rotation",
    "connectionId": "<litellm-connection-id>",
    "environment": "dev",
    "secretPath": "/",
    "isAutoRotationEnabled": true,
    "rotationInterval": 30,
    "rotateAtUtc": { "hours": 0, "minutes": 0 },
    "parameters": {
      "name": "my-app-key",
      "userId": "<litellm-user-id>",
      "teamId": "<litellm-team-id>",
      "models": ["gpt-4o"],
      "additionalOptions": "{\"max_budget\": 100}"
    },
    "secretsMapping": {
      "apiKey": "LITELLM_API_KEY"
    }
  }'

Sample response

{
  "secretRotation": {
    "id": "<rotation-id>",
    "name": "my-litellm-rotation",
    "description": "LiteLLM API key rotation",
    "secretsMapping": { "apiKey": "LITELLM_API_KEY" },
    "isAutoRotationEnabled": true,
    "activeIndex": 0,
    "connectionId": "<litellm-connection-id>",
    "rotationInterval": 30,
    "rotateAtUtc": { "hours": 0, "minutes": 0 },
    "type": "litellm-api-key",
    "parameters": {
      "name": "my-app-key",
      "userId": "<litellm-user-id>",
      "teamId": "<litellm-team-id>",
      "models": ["gpt-4o"],
      "additionalOptions": "{\"max_budget\": 100}"
    }
  }
}