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

# OpenAI

> Generate Word, PowerPoint, Excel and PDF files from an agent with the OpenAI API (function calling) and in OpenAI Codex.

## API

```bash theme={null}
npm install openai @doconda/sdk
```

```ts theme={null}
import OpenAI from "openai"
import { Doconda } from "@doconda/sdk"

const openai = new OpenAI()
const docondaTools = new Doconda().tools()
const tools = docondaTools.map((t) => ({ type: "function" as const, function: { name: t.name, description: t.description, parameters: t.inputSchema } }))
const messages: any[] = [{ role: "user", content: "Write a memo for the team: the office is closed on Friday" }]

while (true) {
  const res = await openai.chat.completions.create({ model: "gpt-5", messages, tools })
  const message = res.choices[0]?.message
  if (!message) break
  messages.push(message)
  if (!message.tool_calls?.length) break
  for (const call of message.tool_calls) {
    if (call.type !== "function") continue
    const result = await docondaTools.find((t) => t.name === call.function.name)!.run(JSON.parse(call.function.arguments))
    messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(result) })
  }
}
```

With the [AI SDK](/en/agents/ai-sdk) it is the same with `openai("gpt-5")` from `@ai-sdk/openai`.

## OpenAI Codex

In `~/.codex/config.toml`:

```toml theme={null}
[mcp_servers.doconda]
command = "npx"
args = ["-y", "@doconda/mcp"]
env = { DOCONDA_API_KEY = "ak_eu_…" }
```

Codex can now create, review and edit documents: ask it, for example, "make an Excel file with this project's
costs".


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