Back to Llama Index

Setup OpenAI Agent

llama-index-integrations/tools/llama-index-tools-brave-search/examples/brave_search.ipynb

0.14.21494 B
Original Source
python
# Setup OpenAI Agent
import os

os.environ["OPENAI_API_KEY"] = "sk-xxx"

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
python
from llama_index.tools.brave_search.base import BraveSearchToolSpec

brave_tool = BraveSearchToolSpec(api_key="your-api-key")
agent = FunctionAgent(
    tools=brave_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("whats the latest news about superconductors"))