Back to Llama Index

Setup OpenAI Agent

llama-index-integrations/tools/llama-index-tools-elevenlabs/examples/elevenlabs_speech.ipynb

0.14.21743 B
Original Source

Prerequisites

Make sure you have installed the following two packages

llama-index-agent-openai
llama-index-tools-elevenlabs
python
# Setup OpenAI Agent
import os

os.environ["OPENAI_API_KEY"] = "your-key"
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
python
from llama_index.tools.elevenlabs import ElevenLabsToolSpec

speech_tool = ElevenLabsToolSpec(api_key="your-key")

agent = FunctionAgent(
    tools=[*speech_tool.to_tool_list()],
    llm=OpenAI(model="gpt-4.1"),
)
print(
    await agent.run(
        'Get the list of available voices, select ONLY the first voice, and use it to create speech from the text "Hello world!" saving to "speech.wav"'
    )
)