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

# Azure OpenAI

> Generate Word, PowerPoint, Excel and PDF files from an Azure OpenAI or Azure AI Foundry agent.

Credentials come from your environment, as in the rest of your code. `model` is the name of your Azure **deployment**.

## With Python

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
pip install openai doconda
```

```python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import json

from doconda import Doconda
from openai import AzureOpenAI

client = AzureOpenAI()
tools = Doconda().tools()
specs = [{"type": "function", "function": {"name": t.name, "description": t.description, "parameters": t.input_schema}} for t in tools]
messages = [{"role": "user", "content": "Write a quarterly sales report in Word"}]

while True:
    message = client.chat.completions.create(model="my-deployment", messages=messages, tools=specs).choices[0].message
    messages.append(message)
    if not message.tool_calls:
        break
    for call in message.tool_calls:
        out = next(t for t in tools if t.name == call.function.name).run(json.loads(call.function.arguments))
        messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(out)})
```

`AzureOpenAI()` reads `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_API_KEY` and `OPENAI_API_VERSION`. With the [Python SDK](/en/sdk/python).

## With the AI SDK

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
npm install ai @ai-sdk/azure @doconda/sdk
```

```ts theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { azure } from "@ai-sdk/azure"
import { generateText, isStepCount, jsonSchema, tool } from "ai"
import { Doconda } from "@doconda/sdk"

const doconda = new Doconda()
const tools = Object.fromEntries(
  doconda.tools().map((t) => [
    t.name,
    tool({ description: t.description, inputSchema: jsonSchema(t.inputSchema), execute: (input) => t.run(input as Record<string, unknown>) }),
  ]),
)

const { text } = await generateText({
  model: azure("my-deployment"),
  tools,
  stopWhen: isStepCount(5),
  prompt: "Write a quarterly sales report in Word",
})
```

`azure` reads `AZURE_RESOURCE_NAME` and `AZURE_API_KEY`.

## Azure AI Foundry

Any Foundry deployment that supports function calling works the same: the tools are standard JSON Schema.


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