litellm/terraform/provider/examples/model_additional_params.tf
Mateo Wang dfb949d437
fix(terraform)!: send additional_drop_params to the proxy instead of deleting the keys it names (#46782)
* fix(terraform): send additional_drop_params to the proxy instead of deleting the keys it names

litellm_model treated additional_drop_params in additional_litellm_params as a
provider-side delete list: it never sent the list and removed every key it named
from litellm_params, so vertex_location vanished and requests still carried
store. The list now goes to the proxy like any other JSON value, so the proxy
drops those params per request. Approach credited to #38345.

Fixes #38349

* fix(terraform)!: validate additional_drop_params and read it back from the proxy on refresh

* docs(terraform): note that a non-list additional_drop_params now fails the apply

* fix(terraform)!: check additional_drop_params at plan time and refresh listed keys and outside lists

* fix(terraform)!: show every listed key an older provider deleted in the upgrade plan and leave outside drop lists alone

Refresh no longer reads listed keys back from the proxy, which left a
plan diff that never cleared when a listed key was removed from config.
When the proxy has no stored list, the plan now shows the list and each
listed key the config sets as changes. A drop list set outside Terraform
on a model whose config has none stays out of the plan, and an empty
value now fails the plan

* fix(terraform): show a listed merge_reasoning_content_in_choices in the upgrade plan

The refresh now clears merge_reasoning_content_in_choices when it is listed and the proxy has no stored list, since an older provider deleted it, and no longer clears litellm_credential_name, which the older provider always sent
2026-10-16 02:24:47 +00:00

54 lines
2.2 KiB
HCL

provider "litellm" {
api_base = "https://your-litellm-proxy.com"
api_key = var.litellm_api_key
}
# Example: using additional_litellm_params to pass provider-specific options.
# Notes:
# - String values "true"/"false" will be coerced to booleans.
# - Numeric strings will be parsed to integer (if possible) otherwise float.
# - JSON strings (starting with [ or {) will be parsed as JSON objects/arrays.
# - Non-convertible strings remain strings.
# - "additional_drop_params" takes a JSON array of request parameters the proxy drops before calling the model provider.
resource "litellm_model" "with_additional" {
model_name = "custom-model"
custom_llm_provider = "openai"
model_api_key = var.openai_api_key
base_model = "gpt-4"
mode = "chat"
# Additional parameters not exposed as first-class arguments
additional_litellm_params = {
"use_fine_tune" = "true" # becomes boolean true
"max_context" = "16384" # becomes integer 16384
"temperature_scale" = "0.75" # becomes float 0.75
"experimental_feature" = "enabled" # stays string "enabled"
"complex_config" = "{\"nested\": {\"value\": 42}}" # parsed as JSON object
"additional_drop_params" = "[\"reasoning_effort\"]" # proxy drops reasoning_effort from requests
}
# Cost configuration (optional)
input_cost_per_million_tokens = 30.0
output_cost_per_million_tokens = 60.0
}
# Example: Azure model with parameter dropping
resource "litellm_model" "azure_with_drop_params" {
model_name = "gpt-5-mini-coder"
custom_llm_provider = "azure"
model_api_key = "your-azure-api-key"
model_api_base = "https://your-azure-endpoint.openai.azure.com/"
api_version = "2025-03-01-preview"
base_model = "gpt-5-mini"
tier = "paid"
mode = "completion"
# Have the proxy drop reasoning_effort from requests before they reach Azure
additional_litellm_params = {
"additional_drop_params" = "[\"reasoning_effort\"]"
}
input_cost_per_million_tokens = 0.25
output_cost_per_million_tokens = 2.00
}