Support for Azure Open AI
I am trying to run the below code but somehow I am getting " Error code: 401 - {'error': {'message': 'Incorrect API key provided"
Could anyone help me with this?
from crewai import Agent from textwrap import dedent from tools import yt_tool from load_dotenv import load_dotenv from langchain_openai import AzureChatOpenAI import os
load_dotenv()
llm = AzureChatOpenAI(
azure_deployment="gpt-4",
api_version="2023-06-01-preview",
api_key=os.environ.get("key"),
azure_endpoint=os.environ.get("endpoint"),
)
researchAgent = Agent( role='Research Analsyt for Youtube Videos', goal='Search popular youtube videos to extract actionable insights for the topic {topic}', tools=[yt_tool], llm=llm, verbose= True, memory=True, allow_delegation=True, backstory=dedent("""You're a Research Analsyt at a large company. list 5 popular youtube videos on the {topic} as you're responsible for analyzing content in the youtube videos, providing insights and suggestions to the business."""), )
Originally posted by @BodapatiNirupamasai in https://github.com/crewAIInc/crewAI/issues/101#issuecomment-2389804994
what is endpoint? and change invoking LLM to LiteLLM https://docs.litellm.ai/docs/providers/azure
401 clearly indicates API key vs endpoint issue and not crewAI
can confirm Azure OpenAi works on my machine
Use LLM from crewai
from crewai import LLM
llm = LLM(
model = "<model>",
base_url = "<url>"
api_version = "<version>",
api_key = "<key>",
azure=True,
)
This should work.! I believe this is not a bug. Thanks.!
Use LLM from crewai
from crewai import LLM llm = LLM( model = "<model>", base_url = "<url>" api_version = "<version>", api_key = "<key>", azure=True, )This should work.! I believe this is not a bug. Thanks.!
This worked for me
from crewai import LLM
llm_crewai = LLM( api_key = "api_key", api_version = '2024-07-18', # this was the version for 4o mini I used model = 'azure/<model_name_goes_here>', base_url = 'https://<yourcompany.com>/coreapi/openai/v1', )
prefix azure/ to your model name. this approach worked for me.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
same issue here , what they mention in documentation for using azure openai with crew that is also not working