> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-service-account.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Tools

> Use the OpenAITools to transcribe an audio file.

```python openai_tools.py theme={null}
"""
This example demonstrates how to use the OpenAITools to transcribe an audio file.
"""

import base64
from pathlib import Path

from agno.agent import Agent
from agno.run.agent import RunOutput
from agno.tools.openai import OpenAITools
from agno.utils.media import download_file, save_base64_data

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


# Example 1: Transcription
url = "https://agno-public.s3.amazonaws.com/demo_data/sample_conversation.wav"

local_audio_path = Path("tmp/sample_conversation.wav")

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    print(f"Downloading file to local path: {local_audio_path}")
    download_file(url, local_audio_path)

    transcription_agent = Agent(
        tools=[OpenAITools(transcription_model="gpt-4o-transcribe")],
        markdown=True,
    )
    transcription_agent.print_response(
        f"Transcribe the audio file for this file: {local_audio_path}"
    )

    # Example 2: Image Generation
    agent = Agent(
        tools=[OpenAITools(image_model="gpt-image-1")],
        markdown=True,
    )

    response = agent.run(
        "Generate an image of a sports car and tell me its color.", debug_mode=True
    )

    if isinstance(response, RunOutput):
        print("Agent response:", response.content)
        if response.images:
            image_base64 = base64.b64encode(response.images[0].content).decode("utf-8")
            save_base64_data(image_base64, "tmp/sports_car.png")
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `openai_tools.py`, then run:

    ```bash theme={null}
    python openai_tools.py
    ```
  </Step>
</Steps>

Full source: [cookbook/91\_tools/models/openai\_tools.py](https://github.com/agno-agi/agno/blob/main/cookbook/91_tools/models/openai_tools.py)
