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

[Bug]: 400 Bad Request #4597

Closed
gaye746560359 opened this issue May 4, 2024 · 10 comments
Closed

[Bug]: 400 Bad Request #4597

gaye746560359 opened this issue May 4, 2024 · 10 comments
Labels
bug Something isn't working stale

Comments

@gaye746560359
Copy link

Your current environment

使用docker run --gpus all -v D:\docker\huggingface:/root/.cache/huggingface --env "HUGGING_FACE_HUB_TOKEN=****************" -d -p 8000:8000 --ipc=host --name vllm vllm/vllm-openai:latest --model nvidia/Llama3-ChatQA-1.5-8B --api-key vllm-abc123456 --gpu-memory-utilization 0.9部署成功了server端

客户端运行下面的代码报错:
from openai import OpenAI

Set OpenAI's API key and API base to use vLLM's API server.

openai_api_key = "vllm-abc123456"
openai_api_base = "http://192.168.2.6:8000/v1"

client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)

chat_response = client.chat.completions.create(
model="nvidia/Llama3-ChatQA-1.5-8B",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Tell me a joke."},
],
extra_body = {
"guided_choice": ["positive", "negative"]
}
).choices[0].message.content
print("Chat response:", chat_response)

错误:
D:\docker\vllm\venv\Scripts\python.exe D:\docker\vllm\llm_client.py
Traceback (most recent call last):
File "D:\docker\vllm\llm_client.py", line 14, in
chat_response = client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai_utils_utils.py", line 277, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai\resources\chat\completions.py", line 579, in create
return self._post(
^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 1240, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 921, in request
return self._request(
^^^^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 1020, in _request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError:

<title>400 Bad Request</title>

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

🐛 Describe the bug

D:\docker\vllm\venv\Scripts\python.exe D:\docker\vllm\llm_client.py
Traceback (most recent call last):
File "D:\docker\vllm\llm_client.py", line 14, in
chat_response = client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai_utils_utils.py", line 277, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai\resources\chat\completions.py", line 579, in create
return self._post(
^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 1240, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 921, in request
return self._request(
^^^^^^^^^^^^^^
File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 1020, in _request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError:

<title>400 Bad Request</title>

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

@gaye746560359 gaye746560359 added the bug Something isn't working label May 4, 2024
@DarkLight1337
Copy link
Member

Have you tried using HTTPS instead of HTTP according to the error message?

- openai_api_base = "http://192.168.2.6:8000/v1"
+ openai_api_base = "https://192.168.2.6:8000/v1"

@gaye746560359
Copy link
Author

Have you tried using HTTPS instead of HTTP according to the error message?

- openai_api_base = "http://192.168.2.6:8000/v1"

+ openai_api_base = "https://192.168.2.6:8000/v1"

我是本地部署的,没有https只有http

@freespeech4ever
Copy link

freespeech4ever commented May 6, 2024

I'm seeing a 400 bad request with 0.4.2 (vllm.entrypoints.openai.api_server) that does not occur with 0.4.1 with nothing else changing.... It's strange because if I submit my normal test CURL request, it works fine, but my application using axios returns the 400... Reverting to 0.4.1 and everything works. This has to be a regression.

@freespeech4ever
Copy link

The issue I mentioned above still occurs with the latest, 0.5.0-post1. I'm stuck on 0.4.1 to have a functioning openai api server.

@dongxiaolong
Copy link

I'm seeing a 400 bad request with 0.4.2 (vllm.entrypoints.openai.api_server) that does not occur with 0.4.1 with nothing else changing.... It's strange because if I submit my normal test CURL request, it works fine, but my application using axios returns the 400... Reverting to 0.4.1 and everything works. This has to be a regression.

I encountered this issue as well. I think it's caused by the current default output being set to streaming. As long as you set 'stream': false, you should be able to get the correct response.

@freespeech4ever
Copy link

In my case, it was items in the messages array containing extra fields... date, and _id...
This is the core of the breaking change that occurred after 0.4.1. The API is extremely rigid now in validating the input.
I've worked around it in my app by stripping out the fields before submission, but not excited about that.

@lwdnxu
Copy link

lwdnxu commented Sep 4, 2024

same error , please fix

@DarkLight1337
Copy link
Member

DarkLight1337 commented Sep 4, 2024

In my case, it was items in the messages array containing extra fields... date, and _id... This is the core of the breaking change that occurred after 0.4.1. The API is extremely rigid now in validating the input. I've worked around it in my app by stripping out the fields before submission, but not excited about that.

This was an intentional change in response to #4339. Sorry for the late reply!

same error , please fix

Please provide more information about this.

Copy link

github-actions bot commented Dec 4, 2024

This issue has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this issue should remain open. Thank you!

@github-actions github-actions bot added the stale label Dec 4, 2024
Copy link

github-actions bot commented Jan 4, 2025

This issue has been automatically closed due to inactivity. Please feel free to reopen if you feel it is still relevant. Thank you!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

5 participants