Skip to content

Azure Cognitive Account support #104

Closed as not planned
Closed as not planned
@brenwell

Description

@brenwell

Hello everyone.

I am trying to use this library with Azure's Cognitive OpenAi deployment. I am new to this stuff but after creating my openai resource and deployment it appears that the endpoint does not quite align with this libraries expectations. Is this an issue with me using the wrong type of resource or is this just something the lib doesn't support. Thanks :)

Here is my Terraform resource

resource "azurerm_resource_group" "oa-rg" {
  name     = "oa_rg"
  location = "francecentral"
}

resource "azurerm_cognitive_account" "openai" {
  name                = "openai"
  location            = azurerm_resource_group.oa-rg.location
  resource_group_name = azurerm_resource_group.oa-rg.name
  kind                = "OpenAI"
  sku_name            = "S0"
}

resource "azurerm_cognitive_deployment" "openai_gpt_4" {
  name                 = "openai-gpt-4"
  cognitive_account_id = azurerm_cognitive_account.openai.id

  model {
    format  = "OpenAI"
    name    = "gpt-4"
    version = "0613"
  }

  sku {
    name = "Standard"
  }
}

this results in the following endpoint

azure_openai_endpoint = "https://francecentral.api.cognitive.microsoft.com/"

This is my application code

package resource

import (
	"github.com/openai/openai-go"
	"github.com/openai/openai-go/azure"
)

func InitOpenai() *openai.Client {
	const azureOpenAIEndpoint = "https://francecentral.api.cognitive.microsoft.com"
	const azureOpenAIAPIVersion = "2024-08-01-preview"

	client := openai.NewClient(
		azure.WithEndpoint(azureOpenAIEndpoint, azureOpenAIAPIVersion),
		azure.WithAPIKey("<masked>"),
	)

	return client
}

This returns

"ChatCompletion error: POST \"https://francecentral.api.cognitive.microsoft.com/openai/chat/completions?api-version=2024-08-01-preview\": 404 Not Found 
{\"error\":
{\"code\":\"DeploymentNotFound\", 
\"message\":\"The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.\"}}\n",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions