aider icon indicating copy to clipboard operation
aider copied to clipboard

Cannot use aider with Azure OpenAI / Gpt4o

Open JustSoftwareNPE opened this issue 2 years ago • 12 comments

Issue

After installing aider, I tried to configure it to use my existing gpt4o model in Azure, but I get the following error after any query:

litellm.APIError: AzureException APIError - Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}
Retry in 0.5 seconds.

Command line: aider --model azure/gpt-4o

Environment variables set: AZURE_API_BASE=https://xxxxxx-sweden-central.openai.azure.com/ AZURE_API_KEY=xxxxx AZURE_API_VERSION=2024-05-13

Version and model info

Aider V0.48.1 model azure/gpt-4o

JustSoftwareNPE avatar Aug 08 '24 14:08 JustSoftwareNPE

I saw the same error, but with a different API base. I'm trying to use our own Azure compatible API, but since the path doesn't end with /openai/deployments/..., the server returns a 404.

So in my case the problem is 1) with our API which provides an endpoint URL too different from Azure, and 2) with litellm which doesn't allow to customize the endpoint URL completely but always appends /openai/deployments/... to the base URL.

akaihola avatar Aug 08 '24 14:08 akaihola

Thanks for trying aider and filing this issue.

Sorry, it's going to be hard for me to debug details of your specific custom azure deployment.

This doc may be helpful:

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

paul-gauthier avatar Aug 08 '24 15:08 paul-gauthier

Thanks for trying aider and filing this issue.

Sorry, it's going to be hard for me to debug details of your specific custom azure deployment.

This doc may be helpful:

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

Hi, I have followed instructions in that link, and it did not change anything. I can supply you with working api key and details in private if that would be helpful ?

JustSoftwareNPE avatar Aug 08 '24 15:08 JustSoftwareNPE

works for me with below values.

export AZURE_API_KEY=xxx export AZURE_API_VERSION=2024-02-15-preview <- I found this value from Azure Open AI Studio's python sample code. export AZURE_API_BASE=https://xxxx.openai.azure.com aider --model azure/gpt-4o-jp <- use deploy name not listed.

RyosukeMondo avatar Aug 09 '24 11:08 RyosukeMondo

Sorry, I'm not able to personally debug your azure config with your credentials.

paul-gauthier avatar Aug 09 '24 18:08 paul-gauthier

I got into same issue. Likely you are using -preview as API_VERSION. Best way to find out is look at your deployment, or even press "code" while you are in azure openai playground and see in the endpoint you'll see your full version:

ENDPOINT = "https://myendpoint.openai.azure.com/openai/deployments/serdar-oai-deployment/chat/completions?api-version=2024-02-15-preview"

so my case was solved by export AZURE_API_VERSION=2024-02-15-preview

radres avatar Aug 15 '24 07:08 radres

I'm going to close this issue for now, but feel free to add a comment here and I will re-open or file a new issue any time.

paul-gauthier avatar Aug 19 '24 17:08 paul-gauthier

@JustSoftwareNPE did you manage to find a solution?

I get the same issue when trying to use Azure and Aider v0.74.2 with gpt-4o and gpt-4o-mini

Getting AzureException APIError 404 resource not found with: export AZURE_API_KEY=<key> export AZURE_API_VERSION=2024-07-18 export AZURE_API_BASE=https://xxx.openai.azure.com`

Same error with export AZURE_API_BASE=https://xxx.services.ai.azure.com/models`

T

JohnnyChenJiaHao avatar Mar 11 '25 13:03 JohnnyChenJiaHao

Hi,

It works for me with the following ENV setup.

AZURE_API_BASE=https://XXXXX.openai.azure.com AZURE_API_KEY=XXXXX AZURE_API_VERSION=2023-05-15

aider --list-models azure/ aider --model azure/gpt-4o

JustSoftwareNPE avatar Mar 11 '25 14:03 JustSoftwareNPE

Thanks for the quick reply!

Still no luck. I will make a new issue for help.

After matching api version correctly, i get bad request after cmd aider and entering an input: litellm.BadRequestError: AzureException BadRequestError - Error code: 400 - {'error': {'message': 'Unrecognized request argument supplied: reasoning_effort', 'type': 'invalid_request_error', 'param': None, 'code': None}}

With azure/gpt-4o and Aider v0.74.2: export AZURE_API_KEY=xxx export AZURE_API_VERSION=2025-01-01-preview export AZURE_API_BASE=https://xxx.openai.azure.com

Let me know if you have seen this before

JohnnyChenJiaHao avatar Mar 11 '25 16:03 JohnnyChenJiaHao

It appears that you're trying to send the reasoning_effort parameter to gpt-4o, which is a non-reasoning model.

Are you using the --reasoning-effort switch or setting it in the environment or yml conf file?

$ aider --reasoning-effort high --model gpt-4o --no-git
───────────────────────────────────────────────────────────────────────────────────────────────
Aider v0.76.2.dev0+g3cb6ec9d.d20250311
Main model: gpt-4o with diff edit format
Weak model: gpt-4o-mini
Git repo: none
Repo-map: disabled
───────────────────────────────────────────────────────────────────────────────────────────────
> hi


litellm.BadRequestError: OpenAIException - Error code: 400 - {'error': {'message':
'Unrecognized request argument supplied: reasoning_effort', 'type': 'invalid_request_error',
'param': None, 'code': None}}

paul-gauthier avatar Mar 11 '25 16:03 paul-gauthier

Hi @paul-gauthier that solved the problem. Thanks a bunch!

JohnnyChenJiaHao avatar Mar 12 '25 07:03 JohnnyChenJiaHao