# Azure Integration

You can use GPTBoost with your Azure-OpenAI deployment, and it requires no additional code changes beyond replacing the `azure_endpoint` with the GPTBoost URL. Similar to communicating with OpenAI API, GPTBoost [acts as a proxy](/advanced/proxy-overview.md) between the client and your Azure OpenAI deployment.

To start, make sure you have an active Azure Subscription and that you've activated Azure OpenAI for it. If you haven't done this yet, check on how to [set up Azure OpenAI Services](#set-up-azure-openai-services).

In case, you already have your Azure deployments ready, you can proceed to [add an Azure Key to GPTBoost](#add-your-azure-key-to-gptboost).

#### Set up Azure OpenAI Services

Remember, you'll need Python version 3.7.1 or later to meet the minimum requirements.

1. Start by setting up your [Azure subscription](https://azure.microsoft.com/en-us/free/) - there's a free tier available.
2. Access to Azure OpenAI Services is granted through an application. Apply for access by filling out the form at <https://aka.ms/oai/access>. They'll ask you a few questions, and then you just need to wait for Microsoft to approve your request.&#x20;
3. Deploy the OpenAI model following the official [Azure documentation.](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model)&#x20;

#### Add your Azure Key to GPTBoost

Setting up the monitoring of your Azure OpenAI model statistics in GPTBoost is pretty straightforward.&#x20;

1. Head over to your GPTBoost account -> OpenAI API Keys.
2. Next, select Add Key.
3. For **Provider** choose Azure OpenAI from the drop-down menu.

<figure><img src="/files/BQYBtmjMsBCOAn4NZaI4" alt=""><figcaption></figcaption></figure>

4. Fill in your credentials. You'll need the **Azure OpenAI API Key,** the **API version** and **the Azure endpoint.** The Endpoint and Keys can be found in the Resource Management section of your Azure portal. More info on these credentials can be found [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart?tabs=command-line%2Cpython\&pivots=programming-language-python#retrieve-key-and-endpoint).

<figure><img src="/files/UZY8OXRgg50wqCat47QG" alt=""><figcaption><p>Adding an Azure OpenAi Key in GPTBoost</p></figcaption></figure>

#### Code Examples&#x20;

Once your Azure OpenAI deployment is set and the Azure Key is authorized in GTPBoost, you can start monitoring all requests by replacing the  `azure_endpoint` with the GPTBoost URL.&#x20;

{% tabs %}
{% tab title="Python" %}

```python
# This example is for v1+ of the openai: https://pypi.org/project/openai/
from openai import AzureOpenAI

client = AzureOpenAI(
    # Set GPTBoost API base URL for azure_endpoint
    azure_endpoint = "https://turbo.gptboost.io/v1",
    api_key = "AZURE_OPENAI_KEY",
    api_version = "2023-07-01-preview",
)

message = [
    {
        "role":"user",
        "content":'Write a tagline for an ice cream shop. '
    }
]

deployment_name="gpt-35-turbo-16k"

response = client.chat.completions.create(
    model=deployment_name, 
    messages=message
)

print(response.choices[0].message.content)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import { OpenAIClient, AzureKeyCredential } from "@azure/openai" ;

async function main(){

    const client = new OpenAIClient(
        // Set GPTBoost API base URL for azure_endpoint
        "https://turbo.gptboost.io/v1",
        new AzureKeyCredential("AZURE_OPENAI_KEY"),
        "2023-07-01-preview" //Azure API Version
        );
    
    const messages = [
        { role: "user", content: "Say 'Hello, World'" },
    ];

    
    const { id, created, choices, usage } = await client.getChatCompletions("gpt-35-turbo-16k", messages)
    
    for (const choice of choices) {
        console.log(choice.message.content);
    }
}

main().catch((err) => {
    console.error("The sample encountered an error:", err);
});
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gptboost.io/first-steps/azure-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
