intitni / CopilotForXcode

The first GitHub Copilot, Codeium and ChatGPT Xcode Source Editor Extension
https://copilotforxcode.intii.com
MIT License
7.85k stars 387 forks source link

[Bug]: Cannot validate OpenAI model with project key #573

Closed tgunr closed 2 months ago

tgunr commented 2 months ago

Before Reporting

What happened?

Tried to update my OpenAI model with a new project key and when testing get an error:

You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e.
Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your
browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/
account/api-keys.

I validated using

curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY"  -d '{
     "model": "gpt-4o-mini",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

Received an error:


        "message": "You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.",
        "type": "insufficient_quota",
        "param": null,
        "code": "insufficient_quota"
    }```

I added ```-H "OpenAI-Organization: $OPENAI_ORG ``` to the header and got valid response. 

Looks like you need to be able to specify the **OpenAI-Organization**.

### How to reproduce the bug.

It just happened!

### Relevant log output

_No response_

### macOS version

15.1 Beta (24B5035e)

### Xcode version

Version 16.1 beta (16B5001e)

### Copilot for Xcode version

0.34.0
intitni commented 2 months ago

You got the test error probably because you didn't select the key after adding it. The error you got from curl means your free plan is over.

intitni commented 2 months ago

Yes I think the other header fields are needed in some cases.

tgunr commented 2 months ago

I did select the proper key, OpenAI key is same as I used to validate. And my billing is current and up to date as indicated by the valid response I got once I specified the organization.

CleanShot 2024-09-03 at 08 01 11

aaqib7git commented 2 months ago

Hi,

I'm having the same issue. I ran out credits and I've topped up but I'm getting the error: You exceeded your current quota which isn't true.

I've tried creating an API key but having the same problem.

Thanks

intitni commented 2 months ago

Released in beta 2

intitni commented 2 months ago

@tgunr Hi, I noticed that you are already using the 0.34.0 beta. Does the latest beta work for you? You can set the organization ID in the model settings.

intitni commented 2 months ago

Released in 0.34.0

tgunr commented 2 months ago

Yes, now functional after. filling in ID's