Skip to content

[Bug]: Error failed to send message HTTP 401, invalid_api_key #714

Closed

Description

@bozzy01

Contact Details

dancab@hey.com

What happened?

I am trying to get OpenAI to work inside a Docker container on my Raspberry Pi. My Google PaLM works fine and OpenAI works fine from my mac..

For some reason I am getting the error below. I have verified the .env file has the correct API key inside the container.

Other relevant details; On mac when I run it I get gear icons when changing models to look at some settings or import a .json for google PaLM. On Raspberry Pi I do not get that option on any of the models including google, but google does work with the .json key in the /api/data folder. I have Pi hole running outside of docker , so that is on port :80 not sure if that is causing an issue here. I also have homebridge running outside of docker.

NOTE: I removed the API Key fully with *'s in the output log below, but it does show the correct beginning and end of my key on my end.

Steps to Reproduce

  1. create a container with mongodb 4.4.18 on raspberry pi
  2. edit the .env and add your key
  3. run the container and try to use the openai model.

What browsers are you seeing the problem on?

Safari

Relevant log output

Error: Failed to send message. HTTP 401 - {
2023-07-27T20:04:34.654086535Z     "error": {
2023-07-27T20:04:34.654106183Z         "message": "Incorrect API key provided: \"sk-uvOH********************************************\". You can find your API key at https://platform.openai.com/account/api-keys.",
2023-07-27T20:04:34.654123183Z         "type": "invalid_request_error",
2023-07-27T20:04:34.654138738Z         "param": null,
2023-07-27T20:04:34.654153572Z         "code": "invalid_api_key"
2023-07-27T20:04:34.654168238Z     }
2023-07-27T20:04:34.654182627Z }
2023-07-27T20:04:34.654198238Z
2023-07-27T20:04:34.654212812Z     at onopen (/app/api/app/clients/ChatGPTClient.js:211:25)
2023-07-27T20:04:34.654227608Z     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-07-27T20:04:34.654249737Z     at async create (/app/node_modules/@waylaidwanderer/fetch-event-source/lib/cjs/fetch.cjs:56:17) {
2023-07-27T20:04:34.654264996Z   status: 401,
2023-07-27T20:04:34.654279700Z   json: {
2023-07-27T20:04:34.654294052Z     error: {
2023-07-27T20:04:34.654308515Z       message: 'Incorrect API key provided: "sk-uvOH********************************************". You can find your API key at https://platform.openai.com/account/api-keys.',
2023-07-27T20:04:34.654324237Z       type: 'invalid_request_error',
2023-07-27T20:04:34.654338551Z       param: null,
2023-07-27T20:04:34.654352903Z       code: 'invalid_api_key'
2023-07-27T20:04:34.654367255Z     }
2023-07-27T20:04:34.654381736Z   }
2023-07-27T20:04:34.654395903Z }
2023-07-27T20:04:34.661260893Z Error: Failed to send message. HTTP 401 - {
2023-07-27T20:04:34.661379299Z     "error": {
2023-07-27T20:04:34.661401391Z         "message": "Incorrect API key provided: \"sk-uvOH********************************************\". You can find your API key at https://platform.openai.com/account/api-keys.",
2023-07-27T20:04:34.661419372Z         "type": "invalid_request_error",
2023-07-27T20:04:34.661435335Z         "param": null,
2023-07-27T20:04:34.661472557Z         "code": "invalid_api_key"
2023-07-27T20:04:34.661511612Z     }
2023-07-27T20:04:34.661530427Z }
2023-07-27T20:04:34.661545019Z
2023-07-27T20:04:34.661559408Z     at onopen (/app/api/app/clients/ChatGPTClient.js:211:25)
2023-07-27T20:04:34.661597926Z     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-07-27T20:04:34.661614389Z     at async create (/app/node_modules/@waylaidwanderer/fetch-event-source/lib/cjs/fetch.cjs:56:17) {
2023-07-27T20:04:34.662468862Z   status: 401,
2023-07-27T20:04:34.662546195Z   json: {
2023-07-27T20:04:34.662563880Z     error: {
2023-07-27T20:04:34.662644861Z       message: 'Incorrect API key provided: "sk-uvOH********************************************". You can find your API key at https://platform.openai.com/account/api-keys.',
2023-07-27T20:04:34.662673157Z       type: 'invalid_request_error',
2023-07-27T20:04:34.662690231Z       param: null,
2023-07-27T20:04:34.662705656Z       code: 'invalid_api_key'
2023-07-27T20:04:34.662720823Z     }
2023-07-27T20:04:34.662785896Z   }
2023-07-27T20:04:34.662804878Z }

Screenshots

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. danny-avila commented on Jul 27, 2023

    @danny-avila
    Collaborator

    Do you have billing enabled for OpenAI API usage? It looks like the network request is successful but is being deemed invalid

  2. danny-avila commented on Jul 27, 2023

    @danny-avila
    Collaborator

    other relevant notes would be how you're running docker on the Pi, frontend screenshots before/after you send a message, that is, when are you getting the error?

  3. bozzy01 commented on Jul 28, 2023

    @bozzy01
    Author

    I double checked, I am setup for billing on OpenAPI. I can run LibreChat fine from my M1 Mac with the API Keys. I just checked and the API does work doing a curl Authorization API test from the container. So, the API itself does not appear to be the issue, but transmitting it to openai must be the problem.

    my docker-compose settings under api are:

    I changed 3080 to 3080:3080 so I can access LibreChat on the Raspberry Pi otherwise I could not access it.

    api: container_name: LibreChat ports: - 3080:3080 # Change it to 9000:3080 to use nginx depends_on: - mongodb image: librechat # Comment this & uncomment below to build from docker hub image build: # ^------ context: . # ^------ target: node # ^------v # image: ghcr.io/danny-avila/librechat:latest # Uncomment this & comment above to build from docker hub image restart: always extra_hosts: # if you are running APIs on docker you need access to, you will need to uncomment this line and next - "host.docker.internal:host-gateway" env_file: - .env environment: - HOST=0.0.0.0 - MONGO_URI=mongodb://mongodb:27017/LibreChat #- CHATGPT_REVERSE_PROXY=http://host.docker.internal:8080/api/conversation # if you are hosting your own chatgpt reverse proxy with docker #- OPENAI_REVERSE_PROXY=http://host.docker.internal:8070/v1/chat/completions # if you are hosting your own chatgpt reverse proxy with docker - MEILI_HOST=http://meilisearch:7700 - MEILI_HTTP_ADDR=meilisearch:7700 volumes: - /app/client/node_modules - ./api:/app/api - ./.env:/app/.env - ./.env.development:/app/.env.development - ./.env.production:/app/.env.production - /app/api/node_modules - ./images:/app/client/public/images

  4. locked and limited conversation to collaborators on Jul 28, 2023
  5. converted this issue into a discussion #725 on Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions