TensorRT-LLM icon indicating copy to clipboard operation
TensorRT-LLM copied to clipboard

[Bug]: trtllm-serve /v1/chat/completions rejects the standard OpenAI field safety_identifier with 400

Open Sonica-B opened this issue 1 month ago • 0 comments

System Info

TensorRT-LLM main @ 61dba71bb0, trtllm-serve OpenAI-compatible server (tensorrt_llm/serve/openai_protocol.py). This is a request-schema bug, so it does not depend on the model or GPU. I reproduced it at the schema level on CPU (Python 3.11, pydantic 2.14.1); no GPU involved.

Reproduction

curl -s localhost:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "Qwen/Qwen3-0.6B",
  "messages": [{"role": "user", "content": "hi"}],
  "safety_identifier": "user-7f3a9c"
}'

or with the OpenAI Python client: client.chat.completions.create(..., safety_identifier="user-7f3a9c").

At the schema level:

from tensorrt_llm.serve.openai_protocol import ChatCompletionRequest

ChatCompletionRequest.model_validate_json(
    '{"model": "m", "messages": [{"role": "user", "content": "hi"}], "safety_identifier": "user-7f3a9c"}')

Expected behavior

The request is served. safety_identifier is part of OpenAI's Chat Completions request body. The OpenAI SDK documents user as "being replaced by safety_identifier and prompt_cache_key", so clients migrating off user send it on every request.

actual behavior

1 validation error for ChatCompletionRequest
{'type': 'extra_forbidden', 'loc': ('safety_identifier',), 'msg': 'Extra inputs are not permitted', 'input': 'user-7f3a9c'}

ChatCompletionRequest inherits extra="forbid" from OpenAIBaseModel and declares user but not safety_identifier.

additional notes

This is the counterpart of #20367 (prompt_cache_key, fix in review in #20368) for the other field that replaces user. user is accepted and ignored, and safety_identifier can be handled the same way: the server does no end-user abuse detection. I have a fix with a CPU unit test and the API-stability reference row ready, and will open the PR right after this issue.

Sonica-B avatar Oct 25 '26 09:10 Sonica-B