Last active
June 4, 2023 01:19
-
-
Save seandavi/23837af9131afd1a99a25d06a8e6184e to your computer and use it in GitHub Desktop.
Terraform for setting up OpenAI APIs on Microsoft Azure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# <[email protected]>, 2023-06-02 | |
# | |
# Terraform for setting up GPT-4, GPT-3.5-turbo, and text-embedding-ada-002 | |
# endpoints. Note that not all models are available in all regions, so | |
# check before changing the region here, currently set to "southcentralus" | |
# | |
# Assumes az-cli authenticated (requires Azure subscription) and terraform | |
# available and installed | |
# | |
terraform { | |
required_providers { | |
azurerm = { | |
source = "hashicorp/azurerm" | |
} | |
} | |
} | |
# Configure the Microsoft Azure Provider | |
provider "azurerm" { | |
features {} | |
} | |
resource "azurerm_resource_group" "openai" { | |
name = "openai-rg" | |
location = "eastus" | |
} | |
resource "azurerm_cognitive_account" "openai" { | |
name = "openai-account" | |
location = azurerm_resource_group.openai.location | |
resource_group_name = azurerm_resource_group.openai.name | |
kind = "OpenAI" | |
sku_name = "S0" | |
} | |
resource "azurerm_cognitive_deployment" "embedding" { | |
name = "embedding" | |
cognitive_account_id = azurerm_cognitive_account.openai.id | |
model { | |
format = "OpenAI" | |
name = "text-embedding-ada-002" | |
version = "2" | |
} | |
scale { | |
type = "Standard" | |
} | |
} | |
resource "azurerm_cognitive_deployment" "gpt_35_turbo" { | |
name = "gpt-35-turbo" | |
cognitive_account_id = azurerm_cognitive_account.openai.id | |
model { | |
format = "OpenAI" | |
name = "gpt-35-turbo" | |
version = "0301" | |
} | |
scale { | |
type = "Standard" | |
} | |
} | |
resource "azurerm_cognitive_deployment" "gpt_4" { | |
name = "gpt-4" | |
cognitive_account_id = azurerm_cognitive_account.openai.id | |
model { | |
format = "OpenAI" | |
name = "gpt-4" | |
version = "0314" | |
} | |
scale { | |
type = "Standard" | |
} | |
} | |
resource "azurerm_cognitive_deployment" "gpt_4_32k" { | |
name = "gpt-4-32k" | |
cognitive_account_id = azurerm_cognitive_account.openai.id | |
model { | |
format = "OpenAI" | |
name = "gpt-4-32k" | |
version = "0314" | |
} | |
scale { | |
type = "Standard" | |
} | |
} | |
# write output blocks for each of the deployments | |
output "embedding" { | |
value = azurerm_cognitive_deployment.embedding.name | |
} | |
output "gpt_35_turbo" { | |
value = azurerm_cognitive_deployment.gpt_35_turbo.name | |
} | |
output "gpt_4" { | |
value = azurerm_cognitive_deployment.gpt_4.name | |
} | |
output "gpt_4_32k" { | |
value = azurerm_cognitive_deployment.gpt_4_32k.name | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment