Azure
The azureopenai provider is an interface to OpenAI through Azure. It behaves the same as the OpenAI provider.
Setup
First, set the AZURE_OPENAI_API_KEY environment variable.
Next, edit the promptfoo configuration file to point to the Azure provider.
azureopenai:chat:<deployment name>- uses the given deployment (for chat endpoints such as gpt-35-turbo, gpt-4)azureopenai:completion:<deployment name>- uses the given deployment (for completion endpoints such as gpt-35-instruct)
Also set the apiHost value to point to your endpoint:
providers:
- id: azureopenai:chat:deploymentNameHere
config:
apiHost: 'xxxxxxxx.openai.azure.com'
Additional config parameters are passed like so:
providers:
- id: azureopenai:chat:deploymentNameHere
config:
apiHost: 'xxxxxxxx.openai.azure.com'
temperature: 0.5
max_tokens: 1024
All other OpenAI provider environment variables and configuration properties are supported.
Model-graded tests
Model-graded assertions such as factuality or llm-rubric, use OpenAI by default. If you are using Azure, you must override the grader to point to your Azure deployment.
The easiest way to do this for all your test cases is to add the defaultTest property to your config:
defaultTest:
options:
provider:
id: azureopenai:chat:gpt-4-deployment-name
config:
apiHost: 'xxxxxxx.openai.azure.com'
However, you can also do this for individual assertions:
# ...
assert:
- type: llm-rubric
value: Do not mention that you are an AI or chat assistant
provider:
id: azureopenai:chat:xxxx
config:
apiHost: 'xxxxxxx.openai.azure.com'
Or individual tests:
# ...
tests:
- vars:
# ...
options:
provider:
id: azureopenai:chat:xxxx
config:
apiHost: 'xxxxxxx.openai.azure.com'
assert:
- type: llm-rubric
value: Do not mention that you are an AI or chat assistant
AI Services
You may also specify deployment_id and dataSources, used to integrate with the Azure AI Search API.
providers:
- id: azureopenai:chat:deploymentNameHere
config:
apiHost: 'xxxxxxxx.openai.azure.com'
deployment_id: 'abc123'
dataSources:
- type: AzureCognitiveSearch
parameters:
endpoint: '...'
key: '...'
indexName: '...'
(The inconsistency in naming convention between deployment_id and dataSources reflects the actual naming in the Azure API.)