Hi,
I am trying to run a Crew on CrewAI Enterprise, but the execution is failing with an error.
The Crew worked locally before being deployed via GitHub.
The LLM Connection was created and configured to use the Azure GPT-4o model (azure/gpt-4o).
I tested setting the environment variables in the project’s .env file, the deployment setup, and directly in CrewAI Enterprise’s environment variables, but none of these methods worked.
The error message is as follows:
Error Type:
AuthenticationError
Error Message:
litellm.AuthenticationError: AzureException AuthenticationError - Error code: 401 - {'statusCode': 401, 'message': 'Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com), or have expired.'}
I had a 401 issue (not using Enterprise) that was solved by:
going to the Azure Portal and selecting the Azure OpenAi Resource where the LLM is deployed
Scroll down and click Explore Azure AI Foundry Portal
On the far left menu bar within the Foundry:
Scroll down to Shared Resources
and click on Deployments
this will bring up a list of your model deployments , if not then there is the first problem.
If you see your deployment in the list then click on it and a summary window will come up showing your Endpoint on the right top where you can double check the correct endpoint and key are in your .env file. To the left of this same window , if you scroll down , look for model version - THIS IS NOT the API version required to be in the .env file. I made this mistake.
To find the API version click the Button at the top that says Open in Playground and then click View Code. Scroll down and you will see
Thanks for your replay but the API version is not an issue, you can use 2024-05-01-preview, or 2024-08-01-preview or even 2024-02-15-preview. I tested my credentials with cURL and works with any API Version. The issue is somewhere else. CrewAI Enterprise actually give warning message instructions if you use wrong env key name, the keys should be: AZURE_DEPLOYMENT_TARGET_URL, AZURE_API_KEY and AZURE_API_VERSION, I only don’t understand the model choice and in Azure we name it freely, but I named my model as it is in select option.
I tested following cURL and it works with every above mentioned API version:
curl -X POST “https://.openai.azure.com/openai/deployments//chat/completions?api-version=2023-05-15”
-H “Content-Type: application/json”
-H “api-key: ”
-d ‘{
“messages”: [
{
“role”: “system”,
“content”: “You are a helpful assistant who helps to create and improve prompts to generate images.”
},
{
“role”: “user”,
“content”: “Create a prompt for image generation based on the following content: <image_prompt>. Return only the prompt, nothing else.”
}
],
“max_tokens”: 100,
“temperature”: 0.7,
“top_p”: 1.0
}’