Hi everyone!
I’ve been developing a Terraform Provider for OpenAI that allows you to manage projects, service accounts, and generate API keys.
It utilizes the official Administration APIs and requires an OpenAI Admin Key to use.
Check it out here:
1 Like
I’ve shipped v0.2.0 . 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
rich.w
June 19, 2024, 11:12am
3
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
it would be awesome if Openai would take one of these projects and run it themselves.
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.
Just a heads up, the provider has been updated (v0.3.0) to use the latest Administration APIs!
Check it out: Terraform Registry .
# Configure the OpenAI provider
provider "openai" {
admin_key = "sk-admin-0000000000000000000000000000000000000000"
}
# Create a project
resource "openai_project" "example" {
name = "Example Project"
}
# Create a service account for the project
resource "openai_project_service_account" "example" {
project_id = openai_project.example.id
name = "my-service-account"
}
# Output the API key for the service account
output "service_account_api_key" {
sensitive = true
value = openai_project_service_account.example.api_key
}