Back to Infisical

Create

docs/api-reference/endpoints/secret-rotations/litellm-api-key/create.mdx

0.162.23.4 KB
Original Source
<Note> Check out the configuration docs for [LiteLLM API Key Rotations](/documentation/platform/secret-rotation/litellm-api-key) to learn how to obtain the required parameters. </Note>

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

bash
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

json
{
  "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}"
    }
  }
}