{"record":{"id":"0399f803bc6edd5e","repo":"sgl-project/sglang","slug":"return-prompt-token-ids-is-not-supported-with-stre","errorCode":null,"errorMessage":"return_prompt_token_ids is not supported with streaming. Please set stream=false when using return_prompt_token_ids=true.","messagePattern":"return_prompt_token_ids is not supported with streaming\\. Please set stream=false when using return_prompt_token_ids=true\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"python/sglang/srt/entrypoints/openai/serving_chat.py","lineNumber":986,"sourceCode":"        request: ChatCompletionRequest,\n        raw_request: Request = None,\n    ) -> tuple[GenerateReqInput, ChatCompletionRequest]:\n        reasoning_effort = (\n            request.chat_template_kwargs.pop(\"reasoning_effort\", None)\n            if request.chat_template_kwargs\n            else None\n        )\n        if self.is_gpt_oss and reasoning_effort == \"none\":\n            raise ValueError(\n                f\"Harmony does not support reasoning effort {reasoning_effort}\"\n            )\n\n        if reasoning_effort is not None:\n            request.reasoning_effort = reasoning_effort\n\n        if request.stream:\n            if request.return_prompt_token_ids:\n                raise ValueError(\n                    \"return_prompt_token_ids is not supported with streaming. \"\n                    \"Please set stream=false when using return_prompt_token_ids=true.\"\n                )\n            if request.return_token_ids:\n                raise ValueError(\n                    \"return_token_ids is not supported with streaming on \"\n                    \"/v1/chat/completions. Please set stream=false when using \"\n                    \"return_token_ids=true.\"\n                )\n            if request.return_meta_info:\n                raise ValueError(\n                    \"return_meta_info is not supported with streaming. \"\n                    \"Please set stream=false when using return_meta_info=true.\"\n                )\n\n        is_multimodal = self.tokenizer_manager.model_config.is_multimodal\n\n        # Process messages and apply chat template","sourceCodeStart":968,"sourceCodeEnd":1004,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/entrypoints/openai/serving_chat.py#L968-L1004","documentation":"_convert_to_internal_request rejects stream=true combined with return_prompt_token_ids=true on /v1/chat/completions. Prompt token IDs are only returned in the non-streaming response object.","triggerScenarios":"POST /v1/chat/completions with {\"stream\": true, \"return_prompt_token_ids\": true}.","commonSituations":"Sharing one request-builder between streaming and non-streaming paths with debug flags always on; wanting token counts for streaming cost accounting.","solutions":["Set stream=false when you need prompt token IDs","Or drop return_prompt_token_ids for streaming and count tokens client-side via /tokenize"],"exampleFix":"// before\n{\"stream\": true, \"return_prompt_token_ids\": true}\n// after\n{\"stream\": false, \"return_prompt_token_ids\": true}","handlingStrategy":"validation","validationCode":"if body.get(\"stream\"):\n    body.pop(\"return_prompt_token_ids\", None)\n    body.pop(\"return_token_ids\", None)\n    body.pop(\"return_meta_info\", None)","typeGuard":"def stream_compat_ok(b): return not (b.get('stream') and b.get('return_prompt_token_ids'))","tryCatchPattern":null,"preventionTips":["Separate debug (non-streaming) and production (streaming) request builders"],"tags":["streaming","token-ids","openai-api","sglang"],"backgroundTag":"incompatible-request-flags","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}