Azure OpenAI

Use Azure OpenAI models with PraisonAI Agents

Point an Agent at Azure OpenAI by setting your credentials and naming the model.

Diagram

Azure OpenAI with PraisonAI

📝 Agent

🔧 litellm

🌐 Azure OpenAI API

✅ Response

Quick Start

  1. Install
    bash
    pip install "praisonaiagents[llm]"
  2. Set credentials
    bash
    export AZURE_API_KEY=your-azure-key
    export AZURE_API_BASE=https://your-resource.openai.azure.com
    export AZURE_API_VERSION=2024-02-15-preview
  3. Run an agent
    python
    from praisonaiagents import Agent
    
    agent = Agent(
        instructions="You are a helpful assistant",
        model="azure/gpt-4",
    )
    
    agent.start("Hello!")

How it works

The azure/ prefix tells PraisonAI to route the request through litellm to Azure OpenAI, which reads AZURE_API_KEY, AZURE_API_BASE, AZURE_API_VERSION from your environment. See Provider Auto-Detection for how model strings are resolved.

Diagram
Azure OpenAI APIlitellmAgentUserAzure OpenAI APIlitellmAgentUseragent.start(“Hello!”)model=”azure/…”Request with your credentialsModel replyResponse

Common Patterns

Pick a different model

Keep the azure/ prefix and swap the rest for any model your Azure OpenAI account offers.

python
from praisonaiagents import Agent

agent = Agent(
    instructions="You are a helpful assistant",
    model="azure/gpt-4",
)

Tune the response with a config dict

Pass a dict to set temperature, token limits, or other options.

python
from praisonaiagents import Agent

agent = Agent(
    instructions="You write short, friendly answers",
    model={
        "model": "azure/gpt-4",
        "temperature": 0.3,
        "max_tokens": 500,
    },
)

agent.start("Give me three tips for better sleep.")

Best Practices

Prefer the shortest form

Start with model="azure/gpt-4" and nothing else. Add a config dict only when you need to tune temperature or limits.

Set the provider key once via env

Export AZURE_API_KEY, AZURE_API_BASE, AZURE_API_VERSION in your shell or .env file. Keep keys out of your code.

Keep model= canonical

Always use model=. The older llm= name still works but prints a deprecation warning. See Model Parameter.

Related