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

# How to make an OpenAI Agents SDK agent deliver files

> Wrap doconda.tools() in FunctionTool: your agent creates Word, PowerPoint, Excel or PDF files and replies with download links.

Install `openai-agents` and `doconda`, and wrap each tool from `doconda.tools()` in a `FunctionTool` (or connect the
remote MCP server with `MCPServerStreamableHttp`). The agent calls `create_document` and its final answer carries the
links to the Word, PowerPoint, Excel or PDF file it created.

## Steps

1. Put your OpenAI key in `OPENAI_API_KEY` and your Doconda key (dashboard → **API keys**) in `DOCONDA_API_KEY`.
2. Install the dependencies: `pip install openai-agents doconda`.
3. Convert the tools and run the agent:

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

from agents import Agent, FunctionTool, Runner
from doconda import Doconda


def as_function_tool(t):
    async def invoke(ctx, args: str):
        return json.dumps(await asyncio.to_thread(t.run, json.loads(args)))

    return FunctionTool(
        name=t.name,
        description=t.description,
        params_json_schema=t.input_schema,
        on_invoke_tool=invoke,
        strict_json_schema=False,
    )


agent = Agent(
    name="Documents",
    instructions="Create the documents the user asks for and return their links.",
    model="gpt-5",
    tools=[as_function_tool(t) for t in Doconda().tools()],
)

result = Runner.run_sync(agent, "Write a memo for the team: the office is closed on Friday")
print(result.final_output)
```

`strict_json_schema=False` because strict mode marks every field as required, and almost all of Doconda's are optional
(`prompt` or `markdown`, `style`, `name`…).

With MCP instead of `FunctionTool`, pass the remote server in `mcp_servers` and raise the per-call wait with
`client_session_timeout_seconds=300` (5 s by default): a document takes longer to be ready. The code is in the
[Agents SDK guide](/en/agents/openai-agents).

## What you get back

Each `create_document` call returns a short summary to the agent:

```json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
{
  "id": "doc_01JAB3…",
  "format": "docx",
  "status": "ready",
  "links": { "docx": "https://…", "pdf": "https://…" },
  "links_note": "Links expire in 5 minutes: call get_document for fresh ones."
}
```

* `format`: `docx`, `pdf`, `pptx`, `xlsx` or `artifact`. Word, PowerPoint and Excel files always come with their PDF.
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).
* Links expire after 5 minutes; the agent gets fresh ones with `get_document`.

## FAQ

<AccordionGroup>
  <Accordion title="Can the agent review or edit a user's file?">
    Yes. It has `upload_file`, `review_document` (fixes problems without touching the content) and `edit_document`
    (changes only what is asked).
  </Accordion>

  <Accordion title="Why does the tool take a while?">
    `create_document` waits until the document is ready. A simple document takes seconds; one at `standard` quality, a
    few minutes. See [quality levels](/en/guides/create).
  </Accordion>

  <Accordion title="How much does it cost?">
    Whatever the agent does counts as if you did it with the API: same project, same price. See
    [pricing](/en/guides/account#pricing).
  </Accordion>
</AccordionGroup>

## Keep reading

* [OpenAI Agents SDK](/en/agents/openai-agents): the full guide, also with local MCP.
* [Quickstart](/en/quickstart).


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