Recomendation: 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
1

Create an account + Generate an API Key

Log into www.helicone.ai or create an account. Once you have an account, you can generate an API key.

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.
client = OpenAI(
  api_key="[AZURE_OPENAI_API_KEY]",
  base_url="https://oai.hconeai.com/openai/deployments/[DEPLOYMENT]",
  default_headers={
      "Helicone-OpenAI-Api-Base": "https://[AZURE_DOMAIN].openai.azure.com",
      "Helicone-Auth": "Bearer [HELICONE_API_KEY]",
      "api-key": "[AZURE_OPENAI_API_KEY]",
  },
  default_query={
    "api-version": "[API_VERSION]"
  }
)

Package Integration

1

Create an account + Generate an API Key

Log into www.helicone.ai or create an account. Once you have an account, you can generate an API key.

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,
)