transitive-bullshit / agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.
https://agentic.so
MIT License
16.27k stars 2.13k forks source link

Incorrect API key error with proxyAPI #478

Closed DrakoHyena closed 1 year ago

DrakoHyena commented 1 year ago

Verify latest release

Verify webapp is working

Environment details

Node 19 NPM 8.19.2

Describe the Bug

This code which is exampled on the docs returns this error when running

import {ChatGPTUnofficialProxyAPI} from 'chatgpt'
import Authenticator from "openai-authenticator";

async function example() {
    const auth = new Authenticator()
    await auth.login("<valid acc email>", "<valid acc pass>")

    const api = new ChatGPTUnofficialProxyAPI({
        accessToken: auth
    })

    const res = await api.sendMessage('Hello World!')
    console.log(res.text)
}

example()
file:///C:/Users/ayden/Downloads/Programs/chatgpt-djs/node_modules/chatgpt/build/index.js:55
    const error = new ChatGPTError(msg, { cause: res });
                  ^

ChatGPTError: ChatGPT error 401: {"detail":{"message":"Incorrect API key provided: [object ***ect]. You can find your API key at https://platform.openai.com/account/api-keys.","type":"invalid_request_error","param":null,"code":"invalid_api_key"}}
DrakoHyena commented 1 year ago

Solved. This is an issue with openai-authenticator. Perhaps the readme of this project should be updated?

transitive-bullshit commented 1 year ago

@DrakoHyena what error did you run into with openai-authenticator? cc @acheong08 who's the author

acheong08 commented 1 year ago

The JS version of openai-authenticator isn't mine.

acheong08 commented 1 year ago

But this doesn't look like a suspension unlike

transitive-bullshit commented 1 year ago

Thanks @acheong08

For now, I strongly recommend switching to using the official API via ChatGPTAPI.

acheong08 commented 1 year ago

I just checked and the Python version is working. No API change with authentication