Demo script agent_team.py has hideden dependency on open_ai

(phidata) william@beast61:~/phidata$ cat agent_team.py
from phi.agent import Agent
from phi.model.groq import Groq
from phi.tools.duckduckgo import DuckDuckGo
from phi.tools.yfinance import YFinanceTools

import os
os.environ[‘GROQ_API_KEY’] = “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”

web_agent = Agent(
name=“Web Agent”,
role=“Search the web for information”,
model=Groq(id=“llama-3.3-70b-versatile”),
tools=[DuckDuckGo()],
instructions=[“Always include sources”],
show_tool_calls=True,
markdown=True,
)

finance_agent = Agent(
name=“Finance Agent”,
role=“Get financial data”,
model=Groq(id=“llama-3.3-70b-versatile”),
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],
instructions=[“Use tables to display data”],
show_tool_calls=True,
markdown=True,
)

agent_team = Agent(
team=[web_agent, finance_agent],
instructions=[“Always include sources”, “Use tables to display data”],
show_tool_calls=True,
markdown=True,
)

agent_team.print_response(“Summarize analyst recommendations and share the latest news for NVDA”, stream=True)

(phidata) william@beast61:~/phidata$ python agent_team.py
ERROR OPENAI_API_KEY not set. Please set the OPENAI_API_KEY environment variable.
▰▰▰▱▱▱▱ Thinking…
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Summarize analyst recommendations and share the latest news for NVDA ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Traceback (most recent call last):
File “/home/william/phidata/agent_team.py”, line 36, in
agent_team.print_response(“Summarize analyst recommendations and share the latest news for NVDA”, stream=True)
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/agent/agent.py”, line 2825, in print_response
for resp in self.run(message=message, messages=messages, stream=True, **kwargs):
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/agent/agent.py”, line 1805, in _run
for model_response_chunk in self.model.response_stream(messages=messages_for_model):
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/model/openai/chat.py”, line 872, in response_stream
for response in self.invoke_stream(messages=messages):
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/model/openai/chat.py”, line 396, in invoke_stream
yield from self.get_client().chat.completions.create(
^^^^^^^^^^^^^^^^^
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/model/openai/chat.py”, line 173, in get_client
return OpenAIClient(**client_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/openai/_client.py”, line 110, in init
raise OpenAIError(
openai.OpenAIError: The api_key client option must be set eithe

Hi @WillR
Thanks for reaching out and for using Agno! I’ve looped in the right engineers to help with your question. We usually respond within 24 hours, but if this is urgent, just let us know, and we’ll do our best to prioritize it.
Appreciate your patience—we’ll get back to you soon! :smile:

Thanks Monali… Not urgent… :slight_smile:

tsunami post … fixed it. You need to correct the demo with this:

agent_team = Agent(
team=[web_agent, finance_agent],
model=Groq(id=“llama-3.3-70b-versatile”),
instructions=[“Always include sources”, “Use tables to display data”],
show_tool_calls=True,
markdown=True,
)

Hey @WillR! Your solution is correct. You have to mention the model in the team leader as well explicitly. Also, we have recently rebranded to Agno so I would recommend you to please upgrade to Agno. We have improved a lot on the performance front and also fixed our cookbooks.

hi manthanguptaa… thanks! ok where do i go ?

i think i found it… thanks!