gpt-engineer-org / gpt-engineer

Platform to experiment with the AI Software Engineer. Terminal based. NOTE: Very different from https://gptengineer.app
MIT License
52.25k stars 6.8k forks source link

Could not resolve authentication method. #1192

Open Zhou-Shilin opened 3 months ago

Zhou-Shilin commented 3 months ago

Policy and info

Expected Behavior

gpte works properly.

Current Behavior

I get an error after I try to run gpte. I am sure that I set the environment variables OPENAI_API_KEY and OPENAI_API_BASE.

>> gpte -m claude-3-5-sonnet-20240620 -i

Error while improving the project: "Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted"

>> echo %OPENAI_API_KEY%
sk-***********************************

>> echo %OPENAI_API_BASE%
https://api.chatanywhere.com.cn

Failure Information

Error message: Error while improving the project: "Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of theX-Api-KeyorAuthorizationheaders to be explicitly omitted"

Failure Logs

debug_log_file.txt

System Information

>> gpte --sysinfo
Usage: gpte [OPTIONS] [PROJECT_PATH]
Try 'gpte -h' for help.
╭─ Error ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ No such option: --sysinfo                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
captivus commented 3 months ago

Please pull the latest version of GPT-Engineer and feedback if you are still having the same issue.

Zhou-Shilin commented 3 months ago

I'm using version 0.3.1. This appears to be the latest version.

captivus commented 3 months ago

I assume you've installed using pip. Does running the latest development version resolve this for you?

https://github.com/gpt-engineer-org/gpt-engineer#install-gpt-engineer

captivus commented 3 months ago

@Zhou-Shilin actually, I think I see where the issue is. You need to set your ANTHROPIC_API_KEY environment variable, not the OPENAI_API_KEY environment variable, as you're trying to use Claude.

Zhou-Shilin commented 3 months ago

@captivus My situation is a bit strange: I'm using the Claude model in the openai request format. I used the one-api project to make models from 25 providers available in openai's request format (including GPT, Claude, Gemini, Moonshot, Minimax, etc.). So I'm using the openai api key here and using an api base built on oneapi. I have tested it and am convinced that claude's model is indeed called properly via openai's request format, see the picture. image

Zhou-Shilin commented 3 months ago

May I ask if you have any clue about this? @gpt-engineer-org

viborc commented 2 months ago

We'll need to check that in more detail.

@captivus can you take a look at this, given new comments from @Zhou-Shilin, please?