Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
22.63k stars 2.11k forks source link

Azure env variables are ignored #2057

Open lucaregini opened 1 month ago

lucaregini commented 1 month ago

Issue

I have installed aider ( version aider 0.59.1) in Ubuntu. CPython 3.10.12

I followed the installation manual and exported the following variables:

export AZURE_API_KEY=mykey export AZURE_API_VERSION=2024-08-01-preview export AZURE_API_BASE=https://mybase.openai.azure.com/

aider still looks for an OPENAI key and I get this error message as soon as I try to do anything:

"Unexpected error: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable"

Version and model info

No response

izikeros commented 1 month ago

In the documentation: https://aider.chat/docs/llms/other.html there is mention that "other models" including Azure OpenAI are supported via LiteLLM and for Azure, there is AZURE_AI_API_KEY environmental variable expected. Not sure abut the rest (version, base).

paul-gauthier commented 1 month ago

Thanks for trying aider and filing this issue. This doc may be helpful:

https://aider.chat/docs/llms/azure.html

paul-gauthier commented 3 weeks ago

I'm labeling this issue as stale because it has been open for 2 weeks with no activity. If there are no additional comments, it will be closed in 7 days.

lucaregini commented 2 weeks ago

I have tried both AZURE_API_KEY and AZURE_AI_API_KEY and it still doesn't work. I do not know what further update I should provide. I clearly stated what are the variable exports I have used. One thing that I have noticed is that the versions available on Azure don't match the versions displayed by Aider in the informational message.

So for example on Azure I can distribute gpt4-o version 2024-08-01 and that doesn't match gpt-4o-2024-08-06 . The azure versions is also reflected in the Azure endpoints; this is the full endpoint for the gpt-4o model I distributed: https:/mybaseurl/openai/deployments/gpt-4o/chat/completions?api-version=2024-08-01-preview and I do not see how the various enviornment variables can be used to build this url.

Is the integration with azure models tested before each aider release?

daviddahl commented 1 week ago

This works for me with a deployment like:

AZURE_API_BASE=https://foo-bar-baz.openai.azure.com/openai/deployments/gpt-4o-foo/chat/completions?api-version=2024-08-01-preview

and starting aider like so:

aider --model azure/gpt-4o-2024-08-06
lucaregini commented 1 week ago

This works for me with a deployment like:

AZURE_API_BASE=https://foo-bar-baz.openai.azure.com/openai/deployments/gpt-4o-foo/chat/completions?api-version=2024-08-01-preview

and starting aider like so:

aider --model azure/gpt-4o-2024-08-06

Which KEY env variable did you valorize? AZURE_AI_API_KEY or AZURE_API_KEY? and how did you valorize the AZURE_API_VERSION variable?