Overview
This guide walks you through the entire flow of getting started with SGLang:- Install SGLang
- Launch an inference server
- Send requests using cURL, OpenAI Python client, Python
requests, or the native SGLang API
Prerequisites
- Python: 3.10 or higher
- GPU: NVIDIA GPU with CUDA support (sm80 and above, e.g., A10, A100, L4, L40S, H100)
- OS: Linux (recommended)
For other platforms, see the dedicated guides for AMD GPUs, Intel Xeon CPUs, Google TPUs, NVIDIA Jetson, Ascend NPUs, and Intel XPU.
Installation
- Pip / uv (Recommended)
- From Source
- Docker
We recommend using uv for faster installation:
Launch a Server
Start the SGLang server with a model. Here we useqwen/qwen2.5-0.5b-instruct as a lightweight example:
The server is fired up and ready to roll! in the terminal output.
Once the server is running, API documentation is available at:
- Swagger UI:
http://localhost:30000/docs - ReDoc:
http://localhost:30000/redoc - OpenAPI Spec:
http://localhost:30000/openapi.json
The server automatically applies the chat template from the Hugging Face tokenizer. You can override it with
--chat-template when launching.Send Requests
SGLang is fully OpenAI API-compatible, so you can use the same tools and libraries you already know.Using cURL
Using OpenAI Python Client
Install the OpenAI Python library if you haven’t:Example
Streaming
Example
Using Python Requests
Example
Using the Native /generate API
SGLang also provides a native /generate endpoint for more flexibility.
Example
Streaming with /generate
Example
Offline Batch Inference (No Server)
SGLang also supports offline batch inference using theEngine class directly — no HTTP server required.
Example
Common Troubleshooting
CUDA_HOME not set
CUDA_HOME not set
Set the
CUDA_HOME environment variable to your CUDA install root:FlashInfer issues on sm75+ devices
FlashInfer issues on sm75+ devices
Switch to alternative backends by adding these flags when launching the server:
Reinstalling FlashInfer
Reinstalling FlashInfer
ptxas error on B300/GB300 (sm_103a)
ptxas error on B300/GB300 (sm_103a)
