> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Terraform Quickstart

> Provision an Orq.ai project, enable a model, and mint a scoped API key in one apply.

This walkthrough provisions a small but realistic setup: a project, a model shared into it, a scoped API key for a backend service, and a monthly budget with an email alert.

## Prerequisites

* Terraform 1.5+ or OpenTofu
* An **Orq.ai** [Management Key](/docs/ai-studio/organization/management-keys) created with the `ALL` permission mode, exported as `ORQ_API_KEY` (a `RESTRICTED` key needs write grants for every resource managed here)

## Configuration

```hcl main.tf theme={"theme":{"light":"github-light","dark":"github-dark"}}
terraform {
  required_providers {
    orq = {
      source  = "orq-ai/orq"
      version = "~> 0.2"
    }
  }
}

provider "orq" {}

# A project to hold the workloads.
resource "orq_project" "production" {
  name        = "Production"
  description = "Primary production workloads"
}

# Enable a model from the catalog and share it with the project.
resource "orq_workspace_model" "gpt4o_mini" {
  model_id = "openai/gpt-4o-mini"
  sharing = {
    project_ids = [orq_project.production.id]
  }
}

# An API key scoped to the project for a backend service.
resource "orq_api_key" "backend" {
  name       = "backend-service"
  project_id = orq_project.production.id
}

# Email destination for budget alerts.
resource "orq_notifier" "finops" {
  display_name = "FinOps alerts"
  type         = "EMAIL"
  emails       = ["finops@example.com"]
}

# A monthly spend ceiling on the project, alerting at 80%.
resource "orq_budget" "production_monthly" {
  scope = {
    kind   = "PROJECT"
    target = orq_project.production.id
  }

  limits = {
    period = "MONTHLY"
    amount = 500 # USD
  }

  alerts {
    threshold_percent = 80
    notifier_ids      = [orq_notifier.finops.id]
  }
}

# The raw key token is returned once, on create, and stored in state as a
# sensitive value. Use an encrypted remote backend.
output "backend_api_key" {
  value     = orq_api_key.backend.token
  sensitive = true
}
```

## Apply

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
terraform init
terraform plan
terraform apply
```

The project, model grant, key, notifier, and budget appear in the dashboard immediately. Re-running `terraform plan` reports no changes: the provider reconciles server-side defaults, so applies stay clean.

## Import existing resources

Resources created in the dashboard can be adopted without recreating them:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
terraform import orq_project.production 019facd8-a60b-7a97-bd30-bf8e7280058a # project id
terraform import orq_workspace_model.gpt4o_mini openai/gpt-4o-mini
```

## Going further

The [full provider reference](https://registry.terraform.io/providers/orq-ai/orq/latest/docs) covers every attribute, including guardrail rules, LLM and Python **Evaluators**, model routing, custom and Bedrock models, and workspace settings. See [Supported resources](/reference/terraform/resources) for the complete list.
