Issue with azure openai and flows and crew

I have several agents and creews in combination of crewai flows. below is how I defined my forecasting agent and all other agents are defined identical to this one with diffrent instructions and tools of course but I get an openai apy key whenever I hit the forecasting agent and not the other ones. why?

forecasting_agent = Agent(
role=“Forecasting Data Analyst”,
goal=(
"Perform time series forecasting on the data using the TimeSeriesForecastTool. "
“You must parse the user’s request to figure out the category, the horizon (in weeks), and target (Revenue or Quantity_Sold).”
),
backstory=“Expert in time series forecasting.”,
tools=[TimeSeriesForecastTool()],
llm=LLM(model=“azure/gpt-4o”),
)

the error:
pydantic_core._pydantic_core.ValidationError: 1 validation error for Crew
Value error, Please provide an OpenAI API key. You can get one at https://platform.openai.com/account/api-keys [type=value_error, input_value={‘chat_llm’: <crewai.llm…': True, ‘memory’: True}, input_type=dict]
For further information visit Redirecting...

The issue may stem based from how you pass the LLM object to the agent.

Without seeing how the others are defined it’s hard to say why this one fails.

I’d also check your indentation to make sure this agent is scoped as part of the class your building.

the one I explained above is identical to the others and below is more examples of the other ones. this only happens when the forecasting agent is invoked.

intent_agent = Agent(
role=“You are here to classify the user intent”,
goal=(
"Your goal is to use your reasoning to classify the user intent "

    ),
backstory="Expert in classifying users intent",
llm=LLM(model="azure/gpt-4o"),

)

forecasting_agent = Agent(
role=“Forecasting Data Analyst”,
goal=(
"Perform time series forecasting on the data using the TimeSeriesForecastTool. "
“You must parse the user’s request to figure out the category, the horizon (in weeks), and target (Revenue or Quantity_Sold).”
),
backstory=“Expert in time series forecasting”,
tools=[TimeSeriesForecastTool()],
llm=LLM(model=“azure/gpt-4o”), # or your chosen model
)

sql_agent = Agent(
role=“SQL Data Analyst”,
goal=(
"Interpret user queries into safe MS SQL queries, run them using the QuerySQLServerTool, "
“then produce a summarized result in markdown, plus a chart if relevant using CodeInterpreterTool.”
),
backstory=“You are an expert in T-SQL for Microsoft SQL Server, focusing on safe read-only queries.”,
tools=[
QuerySQLServerTool(),
CodeInterpreterTool()
],
llm=LLM(model=“azure/gpt-4o”),
)

conversational_agent = Agent(
role=“Conversational Agent”,
goal=“Respond politely and informatively to general conversational questions, greetings, or memory-related queries.”,
backstory=(
"You’re a helpful, friendly conversational assistant who answers general user questions, "
“greetings, or politely informs users when context or memory is unavailable.”
),
llm=LLM(model=“azure/gpt-4o”),
)

Thank you. I think I figure it out. i had the memory to true and by default it was using openai embeddings. I think a better error handing would have been helpful from crewai part.

1 Like

Thanks for reporting that!
I will look at it in the next few days..