Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle insufficient_quota error #23

Closed
soderluk opened this issue Mar 12, 2024 · 3 comments
Closed

Handle insufficient_quota error #23

soderluk opened this issue Mar 12, 2024 · 3 comments

Comments

@soderluk
Copy link
Contributor

If your OPENAI_API_KEY exceeds the quota, you'll only get an empty response from gpt.
The actual response from openai:

{
    "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"
    }
}

This error should be handled, and a message should be shown to the user that their quota has been exceeded. lib/ai.ts:258 is where the result is decoded into this message.

@mattvr
Copy link
Owner

mattvr commented Mar 12, 2024

Thanks @soderluk for debugging, just fixed in 0.3.9

@mattvr mattvr closed this as completed Mar 12, 2024
@soderluk
Copy link
Contributor Author

@mattvr Updated, tested, and still an empty response. I debugged some more, and the chunks is never filled, because frameEnd already is -1. We never get to the for-loop, where the error is thrown: for (const chunk of chunks). Also, it would be beneficial if the error that was returned from OpenAI would be shown, instead of "error found".

@mattvr
Copy link
Owner

mattvr commented Mar 13, 2024

Thanks again @soderluk

I tried to address again in the latest version 0.4.0. I'm not able to reproduce this specific error, so lmk if it's working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants