1 Resources openai_connections
Forgejo Actions edited this page 2026-11-26 06:34:52 +00:00

openwebui_openai_connections (Resource)

Manages the list of OpenAI-compatible API connections for Open WebUI. This is a singleton resource; the full list is replaced on every apply.

Example Usage

# The resource owns the whole list. Every apply replaces it, so a connection
# added by hand in the web UI disappears on the next apply. List order sets
# request priority.
resource "openwebui_openai_connections" "example" {
  enabled = true

  connections = [
    {
      url       = "https://api.openai.com/v1"
      key       = var.openai_api_key
      prefix_id = "openai"
      model_ids = ["gpt-4o-mini"]
    },
    {
      url          = "https://example-resource.openai.azure.com/openai"
      key          = var.azure_openai_api_key
      api_provider = "azure"
      api_version  = "2024-02-01"
      prefix_id    = "azure"
    },
  ]
}

variable "openai_api_key" {
  type      = string
  sensitive = true
}

variable "azure_openai_api_key" {
  type      = string
  sensitive = true
}

Schema

Required

  • connections (Attributes List) Ordered list of OpenAI-compatible connection entries. Order determines request priority. (see below for nested schema)
  • enabled (Boolean) Global toggle for all OpenAI-compatible connections (ENABLE_OPENAI_API).

Read-Only

  • id (String) Identifier of this singleton resource. Always openai.

Nested Schema for connections

Required:

  • url (String) Base URL of the OpenAI-compatible endpoint, e.g. https://api.openai.com/v1.

Optional:

  • api_provider (String) Provider hint. Set to "azure" to enable Azure OpenAI mode.
  • api_type (String) API variant. Set to "responses" to use the Responses API; leave empty for Chat Completions.
  • api_version (String) Azure API version string, e.g. 2024-02-01. Required when api_provider = "azure".
  • auth_type (String) Authentication method: bearer (default), none, session, system_oauth, azure_ad, or microsoft_entra_id.
  • connection_type (String) Connection type label, e.g. external. Stored as-is; Open WebUI uses it for model tagging.
  • enable (Boolean) Whether this specific connection is active. Defaults to true.
  • headers_json (String, Sensitive) JSON object of custom HTTP headers sent to the endpoint, e.g. jsonencode({ X-Org = "acme" }).
  • key (String, Sensitive) API key or bearer token. Sensitive. Set to null or omit to leave empty.
  • model_ids (List of String) Allowlist of model IDs exposed from this connection. Empty list exposes all models.
  • prefix_id (String) String prepended to every model ID from this connection, e.g. openai. Empty string disables prefixing.
  • tags (List of String) Labels attached to models from this connection.

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# The OpenAI connection list is one configuration block, so this resource is a
# singleton. Import it under its fixed id, and every connection comes with it.
# The API may return the connection keys masked, so confirm them after the
# import.
terraform import openwebui_openai_connections.example openai