Key Features
Intuitive Programming Model
The SGLang frontend uses Python decorators and a state-based programming model that feels natural for Python developers:Advanced Control Flow
Parallel Sampling: Fork execution to generate multiple responses in parallelExecution Modes
Single Execution: Run a single request and get resultsCore Concepts
State Object
The state object (s) is the central construct in SGLang functions. It maintains:
- The conversation history
- Generated variables and their values
- Role context (system, user, assistant)
- Images and video data for multimodal models
Variables
Generated text is automatically stored in named variables:Composition
SGLang functions can be composed and reused:Constrained Generation
SGLang supports various forms of constrained generation: Choice Selection: Choose from predefined optionsNext Steps
- Learn about the @sgl.function decorator
- Explore generation primitives like
gen(),select(), andimage() - Configure backend options for different LLM providers
