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

# Azure OpenAI

> Learn how to use Azure OpenAI models in Agno.

Use OpenAI models through Azure's infrastructure. Learn more [here](https://learn.microsoft.com/azure/ai-services/openai/overview).

Azure OpenAI provides access to OpenAI's models like `GPT-4o`, `o3-mini`, and more.

## Authentication

Navigate to Azure OpenAI on the [Azure Portal](https://portal.azure.com/) and create a service. Then, using the Azure AI Studio portal, create a deployment and set your environment variables:

<CodeGroup>
  ```bash Mac theme={null}
  export AZURE_OPENAI_API_KEY=***
  export AZURE_OPENAI_ENDPOINT=***  # Of the form https://<your-resource-name>.openai.azure.com/openai/deployments/<your-deployment-name>
  # Optional:
  # export AZURE_OPENAI_DEPLOYMENT=***
  ```

  ```bash Windows theme={null}
  setx AZURE_OPENAI_API_KEY ***  # Of the form https://<your-resource-name>.openai.azure.com/openai/deployments/<your-deployment-name>
  setx AZURE_OPENAI_ENDPOINT ***
  # Optional:
  # setx AZURE_OPENAI_DEPLOYMENT ***
  ```
</CodeGroup>

## Example

Use `AzureOpenAI` with your `Agent`:

<CodeGroup>
  ```python agent.py theme={null}
  from agno.agent import Agent
  from agno.models.azure import AzureOpenAI
  from os import getenv

  agent = Agent(
      model=AzureOpenAI(id="gpt-4o"),
      markdown=True
  )

  # Print the response on the terminal
  agent.print_response("Share a 2 sentence horror story.")
  ```
</CodeGroup>

## Prompt caching

Prompt caching will happen automatically using our `AzureOpenAI` model. You can read more about how OpenAI handle caching in [their docs](https://platform.openai.com/docs/guides/prompt-caching).

## Advanced Examples

View more examples [here](../examples/models/azure/openai).

## Parameters

<Snippet file="model-azure-openai-params.mdx" />

`AzureOpenAI` also supports the parameters of [OpenAI](/reference/models/openai).
