The Terraform Provider for OpenAI is a plugin built using the Terraform Plugin Framework.
NOTE: To use the OpenAI provider, set your OpenAI API key as the OPENAI_APIKEY
environment variable.
terraform {
required_providers {
openai = {
source = "registry.terraform.io/vravind1/openai"
version = "0.1.0". // use the appropriate version
}
}
}
data "openai_completion" "example" {
model = "text-davinci-003"
max_tokens = 16
prompt = "which is the best cloud provider?"
}
output "example_response" {
value = data.openai_completion.example.result
}
output "example_tokens" {
value = data.openai_completion.example.total_tokens
}
output "example_reason" {
value = data.openai_completion.example.finish_reason
}
More details on how to use this provider can be found on the Terraform Registry.