1

Create an account and generate an API key

Log into Helicone or create an account. Once you have an account, you can generate an API key here.
2

Set up your Helicone API key in your .env file

HELICONE_API_KEY=<YOUR_HELICONE_API_KEY>
AZURE_OPENAI_API_KEY=<YOUR_AZURE_OPENAI_API_KEY>
3

Modify the base URL path and set up authentication

To learn more about the differences between OpenAI and Azure OpenAI, review the OpenAI vs Azure OpenAI documentation.

Make sure to include the api-version in all of your requests.

from openai import AzureOpenAI
from dotenv import load_dotenv
import os

load_dotenv()

helicone_api_key = os.getenv("HELICONE_API_KEY")
azure_openai_api_key = os.getenv("AZURE_OPENAI_API_KEY")

client = AzureOpenAI(
    api_version="[API_VERSION]" # "2024-12-01-preview",
    azure_endpoint="https://[AZURE_DOMAIN].openai.azure.com/",
    api_key=azure_openai_api_key,
    default_headers={
        "Helicone-Auth": f"Bearer {helicone_api_key}",
        "Helicone-OpenAI-Api-Base": "https://[AZURE_DOMAIN].openai.azure.com",
        "Helicone-Model-Override": "[MODEL_NAME]", # gpt-4
        "api-key": azure_openai_api_key
    }
)
Recomendation: Model Override

When using Azure, the model displays differently than expected at times. We have implemented logic to parse out the model, but if you want 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
4

Start using Azure OpenAI with Helicone

response = azure_openai.chat.completions.create(
  model="[DEPLOYMENT]", # gpt-4
  messages=[{"role": "User", "content": "What is the meaning of life?"}]
)

print(response)
5

Verify your requests in Helicone

With the above setup, any calls to Azure OpenAI will automatically be logged and monitored by Helicone. Review them in your Helicone dashboard.