[GH-ISSUE #358] [Bug] Colons in ChatGPT API key appear to break request #310

Open
opened 2026-11-07 17:43:18 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Nitrousoxide on GitHub (Mar 22, 2025).
Original GitHub issue: https://github.com/Physton/sd-webui-prompt-all-in-one/issues/358

Issue Feedback

  • I confirm that I have searched for a solution to this issue in the FAQ and couldn't find a solution.
  • I confirm that I have searched for this issue in the Issues list (including closed ones) and couldn't find a solution.
  • I confirm that I have read the Wiki and couldn't find a solution.

Describe the Issue

I am attempting to point the chatgpt function to a self-hosted LLM instead of the public chatgpt instances. I am using this proxy server to create an authentication front-end for the LLMs so that not just anyone can make api requests

It appears to follow the standard curl api request format for openai, with an example one like this entered into my terminal correctly returning a result:

curl -X POST -H "Authorization: Bearer user1:key1" http://localhost:8080/api/generate --data "{\"model\":\"llama3:latest\",\"prompt\": \"Once upon a time,\",\"stream\":false,\"temperature\": 0.3,\"max_tokens\": 1024}"

(obviously this is not the real user/key combo used for my request)

However, when I attempt to use my user/key combo in the gpt plugin I get a 404 error. If I surround the api key with single (or double) quotes I am seeing the request in the logs in my proxy server, and your plugin reports a 403, rather than a 404 error. However, it appears to be passing the key in that case with the surrounding quotes as part of the key. I would also note that my key does not contain any non-alphanumeric characters. I chose to exclude those to avoid possible syntax issues like this. The only non-alphanumeric character entered into the "api" field in your plugin is ":" to seperate the user and key.

As an example here's what the log looks like (with the keys obviously obfuscated)

2025-03-22 15:48:51.013606,rejected,'user1:key1',10.89.0.21,Denied,None,-1,Authentication failed
2025-03-22 15:49:09.075848,rejected,"""user1:key1""",10.89.0.21,Denied,None,-1,Authentication failed
2025-03-22 15:49:32.344321,rejected,'user1:key1',10.89.0.21,Denied,None,-1,Authentication failed

In short, it appears like certain characters in the API key will cause the entire curl request to 404, and that attempting to quote the api key to ensure a : isn't breaking the command in some way sends the api key with the quotes included.

Maybe this is a vary particular thing with this specific proxy server that uses the format user1:key1 which isn't the exact format for an api key that openai uses, but sanitizing the api key input so that other characters can be used as part of it for potentially a larger set of api providers may be a good addition.

Steps to Reproduce

Enter API key with format 'user1:key1'
Get 404 for chatgpt request

Screenshot or log

No response

OS

Linux

Browser

Firefox

Stable Diffusion WebUI version

f1.7.0-v1.10.1RC-latest-2145-g3640d0b4

Extension version

21654832

Python version

3.10.12

Gradio version

3.41.2

Originally created by @Nitrousoxide on GitHub (Mar 22, 2025). Original GitHub issue: https://github.com/Physton/sd-webui-prompt-all-in-one/issues/358 ### Issue Feedback - [x] I confirm that I have searched for a solution to this issue in the [FAQ](https://aiodoc.physton.com/FAQ.html) and couldn't find a solution. - [x] I confirm that I have searched for this issue in the [Issues](https://github.com/Physton/sd-webui-prompt-all-in-one/issues) list (including closed ones) and couldn't find a solution. - [x] I confirm that I have read the [Wiki](https://aiodoc.physton.com/) and couldn't find a solution. ### Describe the Issue I am attempting to point the chatgpt function to a self-hosted LLM instead of the public chatgpt instances. I am using this [proxy server](https://github.com/ParisNeo/ollama_proxy_server#) to create an authentication front-end for the LLMs so that not just anyone can make api requests It appears to follow the standard curl api request format for openai, with an example one like this entered into my terminal correctly returning a result: `curl -X POST -H "Authorization: Bearer user1:key1" http://localhost:8080/api/generate --data "{\"model\":\"llama3:latest\",\"prompt\": \"Once upon a time,\",\"stream\":false,\"temperature\": 0.3,\"max_tokens\": 1024}"` (obviously this is not the real user/key combo used for my request) However, when I attempt to use my user/key combo in the gpt plugin I get a 404 error. If I surround the api key with single (or double) quotes I am seeing the request in the logs in my proxy server, and your plugin reports a 403, rather than a 404 error. However, it appears to be passing the key in that case with the surrounding quotes as part of the key. I would also note that my key does not contain any non-alphanumeric characters. I chose to exclude those to avoid possible syntax issues like this. The only non-alphanumeric character entered into the "api" field in your plugin is ":" to seperate the user and key. As an example here's what the log looks like (with the keys obviously obfuscated) ``` 2025-03-22 15:48:51.013606,rejected,'user1:key1',10.89.0.21,Denied,None,-1,Authentication failed 2025-03-22 15:49:09.075848,rejected,"""user1:key1""",10.89.0.21,Denied,None,-1,Authentication failed 2025-03-22 15:49:32.344321,rejected,'user1:key1',10.89.0.21,Denied,None,-1,Authentication failed ``` In short, it appears like certain characters in the API key will cause the entire curl request to 404, and that attempting to quote the api key to ensure a : isn't breaking the command in some way sends the api key with the quotes included. Maybe this is a vary particular thing with this specific proxy server that uses the format `user1:key1` which isn't the exact format for an api key that openai uses, but sanitizing the api key input so that other characters can be used as part of it for potentially a larger set of api providers may be a good addition. ### Steps to Reproduce Enter API key with format 'user1:key1' Get 404 for chatgpt request ### Screenshot or log _No response_ ### OS Linux ### Browser Firefox ### Stable Diffusion WebUI version [f1.7.0-v1.10.1RC-latest-2145-g3640d0b4](https://github.com/Panchovix/stable-diffusion-webui-reForge/commit/3640d0b4d2c94cd4c183bf14dbaabcabee6a4db6) ### Extension version 21654832 ### Python version 3.10.12 ### Gradio version 3.41.2
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Physton/sd-webui-prompt-all-in-one#310
No description provided.