crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Support for Azure Open AI

Open BodapatiNirupamasai opened this issue 1 year ago • 1 comments

          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

BodapatiNirupamasai avatar Oct 02 '24 22:10 BodapatiNirupamasai

what is endpoint? and change invoking LLM to LiteLLM https://docs.litellm.ai/docs/providers/azure

voytas75 avatar Oct 03 '24 08:10 voytas75

401 clearly indicates API key vs endpoint issue and not crewAI

can confirm Azure OpenAi works on my machine

motobob avatar Oct 07 '24 16:10 motobob

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.!

mhd-jubair avatar Oct 10 '24 12:10 mhd-jubair

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

talrejanikhil avatar Oct 16 '24 13:10 talrejanikhil

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.

Friend09 avatar Oct 31 '24 21:10 Friend09

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.

github-actions[bot] avatar Dec 01 '24 12:12 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Dec 07 '24 12:12 github-actions[bot]

same issue here , what they mention in documentation for using azure openai with crew that is also not working

coolds23 avatar Apr 15 '25 10:04 coolds23