Skip to main content
The Runlayer Terraform provider manages what admins set up in Settings → AI Providers and Settings → LLM Gateway: Each resource has a data source of the same name that reads one existing object.

What you need

  • Runlayer provider 1.17.0 or later. Earlier releases don’t have these resources.
  • An API key whose user may manage AI providers and LLM gateway settings, set up as in Terraform Provider. Admins can.
  • For usage rules, routing rules and virtual keys: the LLM gateway on for your workspace.

AI providers

  • Credentials: api_key and vertex_service_account_key are sensitive, and the API never returns them. Terraform sends what your configuration holds, so a key changed in the app isn’t detected as drift. After an import, the first apply sends the configured key once.
  • Changing base_url: the apply also sends api_key from your configuration, because Runlayer refuses to move a stored key to a new URL. Keep the key in the configuration, even with lifecycle { ignore_changes = [api_key] }.
  • Model access: model_role_restrictions maps a model to the role IDs that may select it. A model left out of the map is open to everyone. Terraform manages the whole map, so restrictions set in the app on other models are removed on the next apply.
  • Vertex AI: takes a service account key, a project and a region, and no api_key or base_url. Agents and the Runlayer Assistant don’t use it; see LLM providers for the models it serves and how to rotate its key.
  • Recommended model: an organization-wide setting, so declare it once. model must be one of provider_id’s models. It has no import: apply it with the values you want. Destroy clears the recommendation.

LLM gateway

  • Usage rules: scope is organization, team, group, user, agents or virtual_key, and subject_id names the team, group, user or virtual key. priority breaks ties between team and group rules that cover the same user. routing = "no_route" takes a scope out of the gateway.
  • Routing rules: the gateway tries rules by ascending position, and the first match wins. Setting a position never renumbers other rules. Every target and fallback must be a model on the AI providers card, so make a rule depend on the runlayer_ai_provider that serves its models. A rule with usage_rule_id belongs to that usage rule’s override list, and condition = "over_budget" applies it only once that budget is spent.
  • Virtual keys: the plaintext key is returned only when the key is created, so read it from the output then; it is null after an import. Set budget_action whenever you set budget_usd.

Import

Every resource except runlayer_ai_provider_recommended_model imports by its ID:
To bring many objects under Terraform and let it write their configuration, see Adopt Existing Resources.

Terraform Provider

Provider setup, credentials, and the other resources

LLM providers

Which providers and models Runlayer supports