Prerequisites
Before usingOpenAITools
, ensure you have the openai
library installed and your OpenAI API key configured.
-
Install the library:
-
Set your API key: Obtain your API key from OpenAI and set it as an environment variable.
Initialization
ImportOpenAITools
and add it to your Agent’s tool list.
Usage Examples
1. Transcribing Audio
This example demonstrates an agent that transcribes an audio file.transcription_agent.py
2. Generating Images
This example demonstrates an agent that generates an image based on a text prompt.image_generation_agent.py
3. Generating Speech
This example demonstrates an agent that generates speech from text.speech_synthesis_agent.py
View more examples here.
Customization
You can customize the underlying OpenAI models used for transcription, image generation, and TTS:Toolkit Params
Parameter | Type | Default | Description |
---|---|---|---|
api_key | str | None | OpenAI API key. Uses OPENAI_API_KEY env var if not provided |
enable_transcription | bool | True | Enable audio transcription functionality |
enable_image_generation | bool | True | Enable image generation functionality |
enable_speech_generation | bool | True | Enable speech generation functionality |
all | bool | False | Enable all tools when set to True |
transcription_model | str | whisper-1 | Model to use for audio transcription |
text_to_speech_voice | str | alloy | Voice to use for text-to-speech (alloy, echo, fable, onyx, nova, shimmer) |
text_to_speech_model | str | tts-1 | Model to use for text-to-speech (tts-1, tts-1-hd) |
text_to_speech_format | str | mp3 | Audio format for TTS output (mp3, opus, aac, flac, wav, pcm) |
image_model | str | dall-e-3 | Model to use for image generation |
image_quality | str | None | Quality setting for image generation |
image_size | str | None | Size setting for image generation |
image_style | str | None | Style setting for image generation (vivid, natural) |
Toolkit Functions
TheOpenAITools
toolkit provides the following functions:
Function | Description |
---|---|
transcribe_audio | Transcribes audio from a local file path or a public URL |
generate_image | Generates images based on a text prompt |
generate_speech | Synthesizes speech from text |
Developer Resources
- View Tools
- View OpenAI Transcription Guide
- View OpenAI Image Generation Guide
- View OpenAI Text-to-Speech Guide