Skip to main content
The OpenRouter Terraform provider lets you manage OpenRouter as infrastructure-as-code. Define platform configuration in code, review changes before applying them, detect drift, and import resources that already exist.

Installation

Add the provider to your Terraform configuration and run terraform init:

Authentication

Authenticate with an OpenRouter Management API key, which starts with sk-or-mgmt-.... Management keys administer resources and cannot spend inference credits. Pass the key to the provider through api_key, for example with a Terraform variable or another secret-management workflow.

Example

This example creates a workspace, an API key assigned to that workspace, and a guardrail:

What it manages

The provider supports the lifecycle of OpenRouter platform resources, including:
  • API keys and workspace configuration
  • Guardrails and spending limits
  • BYOK provider credentials
  • Observability destinations
  • SCIM group mappings
Terraform tracks these resources in state so plans can show configuration drift before you apply a change. Existing resources can be imported into Terraform-managed state.

Resources and data sources

The provider currently includes six managed resources:
  • openrouter_api_key
  • openrouter_byok_key
  • openrouter_guardrail
  • openrouter_observability_destination
  • openrouter_scim_group_mapping
  • openrouter_workspace
It also includes data sources for looking up resources and platform information, including API keys, BYOK keys, credits, guardrails, models, observability destinations, presets, providers, SCIM mappings, and workspaces. For the complete resource and data-source reference, see the Terraform Registry documentation. The provider source is available on GitHub.