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_keyandvertex_service_account_keyare 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 sendsapi_keyfrom your configuration, because Runlayer refuses to move a stored key to a new URL. Keep the key in the configuration, even withlifecycle { ignore_changes = [api_key] }. - Model access:
model_role_restrictionsmaps 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_keyorbase_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.
modelmust be one ofprovider_id’s models. It has no import: apply it with the values you want. Destroy clears the recommendation.
LLM gateway
- Usage rules:
scopeisorganization,team,group,user,agentsorvirtual_key, andsubject_idnames the team, group, user or virtual key.prioritybreaks 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 therunlayer_ai_providerthat serves its models. A rule withusage_rule_idbelongs to that usage rule’s override list, andcondition = "over_budget"applies it only once that budget is spent. - Virtual keys: the plaintext
keyis returned only when the key is created, so read it from the output then; it is null after an import. Setbudget_actionwhenever you setbudget_usd.
Import
Every resource exceptrunlayer_ai_provider_recommended_model imports by its ID:
Related docs
Terraform Provider
Provider setup, credentials, and the other resources
LLM providers
Which providers and models Runlayer supports