Terraform provider
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending
.mdto the page URL.
The official OpenAI Terraform provider lets you manage OpenAI organization resources with infrastructure as code. The provider uses the Administration API to manage projects, users, groups, roles, service accounts, certificates, rate limits, spend alerts, and related project settings.
This guide creates an OpenAI project. Continue to the use-case guides for project access, service accounts, operational limits, project controls, and imports.
Before you begin
You need:
- Terraform 1.0 or later. The import examples require Terraform 1.5 or later.
- An OpenAI organization with permission to create an Admin API key.
Administration API endpoints require Admin API keys, which don't work with non-administration OpenAI API endpoints. Store the key in an environment variable or a secrets manager. Don't commit it to your Terraform configuration or source control.
Configure the provider
Create a new directory and add a main.tf file with the following configuration:
terraform {
required_version = ">= 1.0"
required_providers {
openai = {
source = "openai/openai"
version = ">= 1.0.0"
}
}
}
provider "openai" {}
resource "openai_project" "example" {
name = "terraform-managed"
}
output "project_id" {
value = openai_project.example.project_id
}The version constraint allows provider version 1.0.0 and later. Review the provider releases before upgrading.
Set your Admin API key in the environment: