sgl-project/sglang · error · HTTPException
An input image is required for mesh generation
Error message
An input image is required for mesh generation
What it means
The mesh generation endpoint requires an input image; if after processing the request no input_path was produced, it returns HTTP 422. This guards the core invariant that mesh generation is image-conditioned.
Source
Thrown at python/sglang/multimodal_gen/runtime/entrypoints/openai/mesh_api.py:208
body = {}
try:
payload: Dict[str, Any] = dict(body or {})
if payload.get("input_image"):
img_src = payload.pop("input_image")
uploads_dir = os.path.join("outputs", "uploads")
os.makedirs(uploads_dir, exist_ok=True)
input_path = await save_image_to_path(
img_src,
os.path.join(uploads_dir, f"{request_id}_input_image"),
)
req = MeshGenerationsRequest(**payload)
except Exception as e:
raise HTTPException(status_code=400, detail=f"Invalid request body: {e}")
if not input_path:
raise HTTPException(
status_code=422,
detail="An input image is required for mesh generation",
)
sampling_params = _build_sampling_params_from_request(request_id, req, input_path)
job = _mesh_job_from_sampling(request_id, req, sampling_params)
await MESH_STORE.upsert(request_id, job)
batch = prepare_request(
server_args=server_args,
sampling_params=sampling_params,
)
asyncio.create_task(_dispatch_job_async(request_id, batch))
return MeshResponse(**job)
@router.get("", response_model=MeshListResponse)View on GitHub (pinned to 0132848349)
Solutions
- Attach the input image as the expected multipart file field (or provide a valid image source in JSON)
- Confirm the field name matches what the endpoint expects (img/img_src/image)
- If testing with curl, use -F to send the file as multipart form-data
Example fix
// before
curl -X POST url -H 'Content-Type: application/json' -d '{"prompt":"mesh"}'
// after
curl -X POST url -F "image=@input.png" -F "prompt=generate 3d mesh" Defensive patterns
Strategy: validation
Validate before calling
has_image = file is not None or body.get('image') is not None
assert has_image, 'mesh generation requires an image' Try / catch
if resp.status_code == 422: attach the image file and retry
Prevention
- Always attach the image file with the expected field name
- Treat 422 as a client bug, not transient
When it happens
Trigger: Calling the mesh generations endpoint without any image: no multipart file part and no valid image source in the JSON payload.
Common situations: Client sends only a prompt JSON body; form-data field named 'image' missing or empty; sending the image under an unexpected field name so the server never reads it.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Failed to process image source: {str(e)}
- Invalid request body: {e}
- Mesh not found
- Mesh has been uploaded to cloud storage. Please use the clou
- Generation is still in-progress
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b8842e893c3cef29.
Report an issue: GitHub.