> ## Documentation Index
> Fetch the complete documentation index at: https://docs.helicone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure OpenAI

> Connect Helicone with Azure OpenAI, a cloud-based AI service. Monitor and optimize your AI applications using Azure's powerful models through a simple base_url configuration.

> [!WARNING]
>
> This integration method is maintained but no longer actively developed. For the best experience and latest features, use our new [AI Gateway](https://docs.helicone.ai/gateway/overview.md) with unified API access to 100+ models.

Helicone can be seamlessly integrated with your Azure-OpenAI deployment. This integration requires no additional code changes beyond importing the OpenAI package with Helicone.

> [!NOTE]
>
> **MODEL OVERRIDE**
>
> When using Azure, the model may sometimes display differently than expected. We have implemented a series of logic to parse out the model, but the returned body of the model can be inconsistent in most cases.
>
> `Helicone-Model-Override: [MODEL_NAME]`
>
> [ Click here to learn more about model override](https://docs.helicone.ai/helicone-headers/header-directory.md)

> [tab] Python
>
> > [!NOTE]
> >
> > Please ensure to include the 'api-version' in all of your requests.
>
> > [accordion] OpenAI v1+
> >
> > > [!NOTE]
> > >
> > > It is mandatory to include the 'api-key' in both locations.
> >
> > ```python theme={null}
> >   client = OpenAI(
> >     api_key="[AZURE_OPENAI_API_KEY]",
> >     base_url="https://oai.helicone.ai/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]"
> >     }
> > )
> > ```
>
> > [accordion] OpenAI \<v1
> >
> > **Modify the API base and add a Helicone-Auth header**
> >
> > ```python theme={null}
> > import openai
> >
> > openai.api_base = "https://oai.helicone.ai"
> > openai.api_key = "[AZURE_OPENAI_API_KEY]"
> > openai.api_version = "[API_VERSION]"
> > openai.api_type = "azure"
> >
> > # Create the completion request
> > openai.ChatCompletion.create(
> >     model="[DEPLOYMENT]",
> >     messages=[{"role": "User", "content": "Say hi!"}],
> >     headers={
> >         "Helicone-Auth": "Bearer [HELICONE_API_KEY]",
> >         "Helicone-OpenAI-Api-Base": "https://[AZURE_DOMAIN].openai.azure.com",
> >     }
> > )
> > ```
>
> Congratulations! Your Azure OpenAI requests are now configured to log results to Helicone.

> [tab] Node.js
>
> > [!NOTE]
> >
> > Please ensure to include the 'api-version' in all of your requests.
>
> > [accordion] OpenAI v4+
> >
> > ```typescript theme={null}
> > const openai = new OpenAI({
> >   baseURL: "https://oai.helicone.ai/openai/deployments/[DEPLOYMENTNAME]",
> >   defaultHeaders: {
> >     "Helicone-Auth": `Bearer [HELICONE_API_KEY]`,
> >     "Helicone-OpenAI-API-Base": "https://[AZURE_DOMAIN].openai.azure.com",
> >     "api-key": "[AZURE_API_KEY]",
> >   },
> >   defaultQuery: { "api-version": "[API_VERSION]" },
> > });
> > ```
>
> > [accordion] OpenAI \<v4
> >
> > ```typescript theme={null}
> > import { Configuration, OpenAIApi } from "openai";
> >
> > const configuration = new Configuration({
> >   apiKey: "[AZURE_OPENAI_API_KEY]",
> >   basePath: "https://oai.helicone.ai/openai/deployments/[DEPLOYMENT]",
> >   baseOptions: {
> >     headers: {
> >       "Helicone-Auth": `Bearer [HELICONE_API_KEY]`,
> >       "api-key": "[AZURE_OPENAI_API_KEY]",
> >       "Helicone-OpenAI-Api-Base": "https://[AZURE_DOMAIN].openai.azure.com",
> >     },
> >     params: {
> >       "api-version": "[API_VERSION]",
> >     },
> >   },
> > });
> >
> > const openai = new OpenAIApi(configuration);
> > ```

> [tab] Python w/package
>
> ```python theme={null}
> 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-4o-mini',
> messages = [{
>     'role': 'user',
>     'content': "Hello World!"
> }],
> max_tokens=30,
> )
>
> ```

> [tab] LangChain JS
>
> ```javascript theme={null}
> const model = new ChatOpenAI({
>   azureOpenAIApiKey: "[AZURE_OPENAI_API_KEY]",
>   azureOpenAIApiDeploymentName: "openai/deployments/gpt-4o-mini",
>   azureOpenAIApiVersion: "2023-03-15-preview",
>   azureOpenAIBasePath: "https://oai.helicone.ai",
>   configuration: {
>     organization: "[organization]",
>     baseOptions: {
>       headers: {
>         "Helicone-Auth": `Bearer ${heliconeApiKey}`,
>         "Helicone-OpenAI-Api-Base":
>           "https://[YOUR_AZURE_DOMAIN].openai.azure.com",
>       },
>     },
>   },
> });
> ```

> [tab] LangChain
>
> ```python theme={null}
> from langchain.chat_models import AzureChatOpenAI
> helicone_headers = {
>     "Helicone-Auth": f"Bearer {helicone_api_key}",
>     "Helicone-OpenAI-Api-Base":
>         "https://<model_name>.openai.azure.com/"
> }
> self.model = AzureChatOpenAI(
> openai_api_base="https://oai.helicone.ai",
> deployment_name="gpt-4o-mini",
> openai_api_key=<AZURE_OPENAI_API_KEY>,
> openai_api_version="2023-05-15",
> openai_api_type="azure",
> max_retries=max_retries,
> headers=helicone_headers,
> **kwargs,
> )
> ```

> [tab] cURL
>
> ```bash theme={null}
>   curl --request POST \
>   --url "https://oai.helicone.ai/openai/deployments/$DEPLOYMENT_NAME/chat/completions?api-version=$API_VERSION" \
>   --header "Helicone-Auth: Bearer $HELICONE_API_KEY" \
>   --header "Helicone-OpenAI-Api-Base: https://$AZURE_DOMAIN.openai.azure.com" \
>   --header "api-key: $AZURE_API_KEY" \
>   --header "content-type: application/json" \
>   --data '{
>     "messages": [
>       {
>         "role": "user",
>         "content": "Answer in one word"
>       }],
>     "max_tokens": 800,
>     "temperature": 1,
>     "model": "gpt-4o-mini-0613"
>   }'
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.