> ## 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

> Genera Word, PowerPoint, Excel y PDF desde un agente con Azure OpenAI o Azure AI Foundry.

Las credenciales salen de tu entorno, como en el resto de tu código. `model` es el nombre de tu **despliegue** en Azure.

## Con 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": "Redacta un informe trimestral de ventas en Word"}]

while True:
    message = client.chat.completions.create(model="mi-despliegue", 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()` lee `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_API_KEY` y `OPENAI_API_VERSION`. Con el [SDK de Python](/sdk/python).

## Con el 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("mi-despliegue"),
  tools,
  stopWhen: isStepCount(5),
  prompt: "Redacta un informe trimestral de ventas en Word",
})
```

`azure` lee `AZURE_RESOURCE_NAME` y `AZURE_API_KEY`.

## Azure AI Foundry

Cualquier despliegue de Foundry que admita llamada a funciones sirve igual: las herramientas son JSON Schema estándar.


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