terraform-provider-onyx/docs/resources/llm_provider.md
An Onyx LLM provider (OpenAI, Anthropic, Azure, Bedrock, ...) with its enabled models. model_configurations is the full list of record: models omitted from it are removed server-side on apply, and removing the model that is currently the deployment default fails validation — repoint the default first. api_key and custom_config are masked by the API on read, so out-of-band changes to them cannot be detected as drift.
resource "onyx_llm_provider" "openai" {
name = "openai-prod"
provider_type = "openai"
# api_key is kept in Terraform state. To keep the key out of state, swap in
# the write-only pair instead (needs Terraform 1.11 or later):
# api_key_wo = var.openai_api_key
# api_key_wo_version = 1
api_key = var.openai_api_key
# The complete set of enabled models: anything omitted here is
# removed from the provider on apply.
model_configurations = [
{ name = "gpt-5" },
{
name = "gpt-5-mini"
custom_display_name = "GPT-5 Mini (cheap tier)"
},
{
name = "gpt-5-nano"
is_visible = false
},
]
}
model_configurations (Attributes Set) The complete set of models enabled on this provider. Applies replace the server-side list with exactly this set. (see below for nested schema)provider_type (String) LiteLLM provider key, e.g. openai, anthropic, azure, bedrock, vertex_ai, ollama. Must be lowercase.NOTE: Write-only arguments are supported in Terraform 1.11 and later.
api_base (String) Custom API base URL (e.g. for Azure or self-hosted gateways).api_key (String, Sensitive) Provider API key. The Onyx API masks this on read, so Terraform cannot detect out-of-band changes; the configured value is authoritative. Prefer api_key_wo, which keeps the value out of state entirely; the two cannot be set together.api_key_wo (String, Sensitive, Write-only) Provider API key, held only in configuration. Terraform sends it on every apply and stores nothing, so the key never reaches state. Pair it with api_key_wo_version to rotate it. Needs Terraform 1.11 or later.api_key_wo_version (Number) Rotation counter for api_key_wo. Terraform never stores a write-only value and so cannot tell that the secret changed; raise this number to make the next apply send the current one. Do not derive it from the secret itself — unlike the secret, this number is kept in state.api_version (String) API version (Azure).custom_config (Map of String, Sensitive) Provider-specific config key/values (e.g. Vertex service-account JSON, Bedrock credentials). Masked on read like api_key. Prefer custom_config_wo, which keeps the value out of state entirely; the two cannot be set together.custom_config_wo (Map of String, Sensitive, Write-only) Provider-specific config key/values, held only in configuration. Terraform sends them on every apply and stores nothing, so they never reach state. Pair with custom_config_wo_version to rotate them. Needs Terraform 1.11 or later.custom_config_wo_version (Number) Rotation counter for custom_config_wo. Terraform never stores a write-only value and so cannot tell that the secret changed; raise this number to make the next apply send the current one. Do not derive it from the secret itself — unlike the secret, this number is kept in state.deployment_name (String) Deployment name (Azure).force_delete (Boolean) Allow destroying this provider even while it holds the deployment default model. Defaults to false, where such a destroy fails.groups (Set of Number) User group ids the provider is restricted to (EE).is_auto_mode (Boolean) Onyx Auto mode: the model list is managed by Onyx. When enabled, the server owns model_configurations: Terraform stops drift-checking the list, and updates re-assert the server's current models instead of the configured ones, so registry-managed models are never removed.is_public (Boolean) Whether the provider is available to all users.name (String) Display name for the provider configuration.personas (Set of Number) Persona ids the provider is restricted to.id (String) Numeric provider id.<a id="nestedatt--model_configurations"></a>
model_configurationsRequired:
name (String) Model name as known to the provider, e.g. gpt-5-mini.Optional:
custom_display_name (String) Admin-specified display-name override.display_name (String) Source-API display name (dynamic providers such as OpenRouter/Ollama).is_visible (Boolean) Whether the model is selectable in the UI.max_input_tokens (Number) Override for the model's max input tokens; unset uses the model's known default.supports_image_input (Boolean) Override for image-input support; unset lets Onyx infer it.supports_reasoning (Boolean) Override for reasoning-model classification; unset lets Onyx infer it.Import is supported using the following syntax:
The terraform import command can be used, for example:
#!/bin/sh
# Import by numeric provider id. api_key/custom_config are masked by the
# API and stay null until set in configuration.
terraform import onyx_llm_provider.openai 3