{"record":{"id":"4a434d78a78f32cf","repo":"sgl-project/sglang","slug":"return-meta-info-is-not-supported-with-streaming","errorCode":null,"errorMessage":"return_meta_info is not supported with streaming. Please set stream=false when using return_meta_info=true.","messagePattern":"return_meta_info is not supported with streaming\\. Please set stream=false when using return_meta_info=true\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"python/sglang/srt/entrypoints/openai/serving_chat.py","lineNumber":997,"sourceCode":"            )\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\n        processed_messages = self._process_messages(request, is_multimodal)\n        # Build sampling parameters\n        sampling_params = request.to_sampling_params(\n            stop=processed_messages.stop,\n            model_generation_config=self.default_sampling_params,\n            tool_call_constraint=processed_messages.tool_call_constraint,\n            renderer_handles_response_format=self.chat_encoding_spec == \"kimi_k3\",\n        )\n\n        # Handle single vs multiple requests\n        if request.input_ids is not None:","sourceCodeStart":979,"sourceCodeEnd":1015,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/entrypoints/openai/serving_chat.py#L979-L1015","documentation":"return_meta_info=true is only supported for non-streaming /v1/chat/completions requests; meta info (finish details, usage internals, etc.) is attached to the complete GenerateOutput object. Streaming requests with this flag are rejected.","triggerScenarios":"POST /v1/chat/completions with {\"stream\": true, \"return_meta_info\": true}.","commonSituations":"Inspection/debug tooling built on the non-streaming API being switched to streaming; wanting per-chunk metadata like finish reason (which is already in SSE chunks).","solutions":["Set stream=false when you need meta_info","Or remove return_meta_info for streaming — finish_reason/usage still arrive via SSE events where supported"],"exampleFix":"// before\n{\"stream\": true, \"return_meta_info\": true}\n// after\n{\"stream\": false, \"return_meta_info\": true}","handlingStrategy":"validation","validationCode":"if body.get(\"stream\"):\n    body[\"return_meta_info\"] = False","typeGuard":"def stream_compat_ok(b): return not (b.get('stream') and b.get('return_meta_info'))","tryCatchPattern":null,"preventionTips":["Use SSE chunk metadata (finish_reason, usage events) instead of return_meta_info when streaming"],"tags":["streaming","meta-info","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"}