Azure OpenAI
Azure OpenAI Python Integration
Use Python to integrate Azure OpenAI with Helicone to log your Azure OpenAI usage.
Recomendation: Model Override
Click here to learn more about model override
When using Azure, the model displays differently than expected at times. We have implemented logic to parse out the model, but to guarantee your model is consistent, we highly recommend using model override:
Helicone-Model-Override: [MODEL_NAME]
Click here to learn more about model override
Proxy Integration (recommended)
1
2
Set HELICONE_API_KEY as an environment variable
export HELICONE_API_KEY=<your API key>
3
Modify the base path and add a Helicone-Auth header
It is mandatory to include the
apik-key
in both locations.Package Integration
1
2
Set HELICONE_API_KEY as an environment variable
export HELICONE_API_KEY=<your API key>
3
Install the Helicone package
pip install helicone
4
Modify OpenAI import to use Helicone
from helicone.openai_proxy import openai # replace `import openai` with this line
5
Configure your azure domain and you are ready to send your azure requests to Helicone.
from helicone.openai_proxy import openai
openai.api_type = "azure"
openai.api_base = "https://[YOUR_AZURE_DOMAIN].openai.azure.com"
openai.api_version = "2023-03-15-preview"
openai.api_key = YOUR_AZURE_API_KEY
response = openai.ChatCompletion.create(
engine = 'gpt-35-turbo',
messages = [{
'role': 'user',
'content': "Hello World!"
}],
max_tokens=15,
)