sgl-project/sglang · error · ValueError
At least one of text, input_ids, or image should be provided
Error message
At least one of text, input_ids, or image should be provided
What it means
normalize_batch_and_arguments requires at least one input modality: text, input_ids, or image_data. All three being None means there is nothing to tokenize/embed, so the request is rejected up front.
Source
Thrown at python/sglang/srt/managers/io_struct.py:1180
if isinstance(self.rid, list):
self.rid = [uuid.uuid4().hex for _ in range(len(self.rid))]
else:
self.rid = uuid.uuid4().hex
return self.rid
def _validate_rid_uniqueness(self):
"""Validate that request IDs within a batch are unique."""
if isinstance(self.rid, list) and len(set(self.rid)) != len(self.rid):
counts = Counter(self.rid)
duplicates = [rid for rid, count in counts.items() if count > 1]
raise ValueError(
f"Duplicate request IDs detected within the request: {duplicates}"
)
def normalize_batch_and_arguments(self):
# at least one of text, input_ids, or image should be provided
if self.text is None and self.input_ids is None and self.image_data is None:
raise ValueError(
"At least one of text, input_ids, or image should be provided"
)
# text and input_ids cannot be provided at the same time
if self.text is not None and self.input_ids is not None:
raise ValueError("text and input_ids cannot be provided at the same time")
# Derive the batch size
self.batch_size = 0
self.is_single = True
# check the batch size of text
if self.text is not None:
if isinstance(self.text, list):
self.batch_size += len(self.text)
self.is_single = False
else:
self.batch_size += 1View on GitHub (pinned to 0132848349)
Solutions
- Supply text='...', input_ids=[...], or image_data=[...]
- Debug why the prompt field is None before constructing the request
- For embed-only or multimodal calls, still include the text or image
Example fix
// before
req = GenerateReqInput(sampling_params={'temperature':0.7})
// after
req = GenerateReqInput(text='Hello', sampling_params={'temperature':0.7}) Defensive patterns
Strategy: validation
Validate before calling
assert text is not None or input_ids is not None or image_data is not None
Prevention
- Log and skip records with empty prompts before constructing requests
When it happens
Trigger: GenerateReqInput(sampling_params={...}) with no text/input_ids/image_data; a client sends JSON {} or only sampling fields; passing empty string via a variable that is actually None.
Common situations: Client bug where the prompt variable is None due to upstream extraction failure; building requests programmatically from possibly-empty records.
Related errors
- Unknown req_type: {req_type!r} (expected 'generate' or 'embe
- text and input_ids cannot be provided at the same time
- token_ids_logprob must be a flat list of integers.
- Unknown serve backend {name!r}. Available values: {available
- Multiple distributions register serve backend {name!r}: {pro
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/5bc0b7a3dca5e385.
Report an issue: GitHub.