DOCUMENTATION
Image input
Pass images with images= alongside the text context. The served model must be a vision-language model, such as Qwen/Qwen3.8-27B.
result = client.generate(
context="Read the attached photo of a restaurant receipt.",
images=["receipt.jpg"],
questions={
"first_item": {"type": "string", "maxLength": 40,
"instructions": "Name of the first line item, exactly as printed."},
"item_lines": {"type": "integer", "instructions": "How many line items are listed?"},
"subtotal": {"type": "number", "instructions": "Subtotal as a plain number."},
"discount": {"type": "number", "instructions": "Discount as a plain number."},
"paid_in_cash": {"type": "boolean", "instructions": "Was the bill paid in cash?"},
"discount_percent": {"type": "number", "depends_on": ["subtotal", "discount"],
"instructions": "Discount as a percentage of the subtotal."},
},
)
depends_on. See the receipt example for the script and recorded results. Receipt from CORD v2, CC BY 4.0.Accepted images
images is a list. Each entry can be a local file path, an http(s) URL, a data: URI, raw bytes or a PIL image. Local files are read by the client, so the SGLang server does not need access to your filesystem.
Behavior
- Images come before the text in the first user turn, in list order.
- Every request in the call carries the images, across batch, sequential and DAG execution, permutations, numeric decoding and thinking. Images apply to one
generate()call only. - TypeLLM reads the image placeholder from the model's chat template. If the template does not render image content,
generate()raises an error before sending any request. - With thinking, the budget uses the server's prompt-token count, because each image expands to many tokens on the server.