Terraform Provider for OpenAI - Manage projects and API keys

Hi everyone!

I’ve been developing a Terraform Provider for OpenAI that allows you to manage projects and generate API keys.

To get this to work, I had to use internal APIs and session tokens instead of the usual user and project API keys. If this method isn’t permitted, I’m more than willing to take it down. It would be fantastic if there’s an official API in the works. If anyone from OpenAI is reading this, please reach out—I’d love to collaborate!

There are many more resources planned, so stay tuned!

Check it out here:

1 Like

I’ve shipped v0.2.0 :rocket: . You can now create an API key with specific permissions:

# Create an API key for the default project
resource "openai_project_api_key" "example" {
  organization_id    = "org-000000000000000000000000"
  service_account_id = "my-service-account"
}

# Create an API key for a specific project
resource "openai_project_api_key" "example" {
  organization_id    = "org-000000000000000000000000"
  project_id         = "proj_000000000000000000000000"
  service_account_id = "my-service-account"
}

# Create a read-only API key
resource "openai_project_api_key" "example" {
  organization_id    = "org-000000000000000000000000"
  service_account_id = "my-service-account"
  read_only          = true
}

# Create an API key with specific permissions
resource "openai_project_api_key" "example" {
  organization_id    = "org-000000000000000000000000"
  service_account_id = "my-service-account"
  permissions {
    models             = "read"
    model_capabilities = "write"
  }
}

Docs: Terraform Registry

Welcome to suggestions for additional resources :slight_smile:

I also created a provider for openai and it’s had some significant use. over 22k downloads.
https://registry.terraform.io/providers/skyscrapr/openai/latest

  1. it would be awesome if Openai would take one of these projects and run it themselves.

  2. It would also be much better for us to collaborate and merge into one project. There are already a bunch of providers that have been created.