GPT models can be used with Azure’s OpenAI API.

Authentication

Set your AZURE_OPENAI_API_KEY and AZURE_OPENAI_ENDPOINT environment variables.

export AZURE_OPENAI_API_KEY=***
export AZURE_OPENAI_ENDPOINT=***
# Optional:
# export AZURE_OPENAI_API_VERSION=***
# export AZURE_DEPLOYMENT=***

Usage

Use AzureOpenAIChat with your Assistant:

from phi.assistant import Assistant
from phi.llm.azure import AzureOpenAIChat

assistant = Assistant(
    llm=AzureOpenAIChat(model="gpt-35-turbo"),
    description="You help people with their health and fitness goals.",
)
assistant.print_response("Share a quick healthy breakfast recipe.", markdown=True)

Params

name
str
default: "AzureOpenAIChat"

The name identifier for the assistant.

model
str
required

The specific model ID used for generating responses. This field is required.

api_key
str

The API key for authenticating requests to the Azure OpenAI service.

api_version
str
default: "2023-12-01-preview"

The version of the Azure OpenAI API to use.

azure_deployment
str

The deployment name or ID in Azure.

base_url
str

The base URL for making API requests to the Azure OpenAI service.

azure_ad_token
str

The Azure Active Directory token for authenticating requests.

azure_ad_token_provider
str

The provider for obtaining Azure Active Directory tokens.

openai_client
AzureOpenAIClient

An instance of AzureOpenAIClient provided for making API requests.