Skip to main content
This guide will help you launch an SGLang server and send your first requests using both the OpenAI-compatible API and the native SGLang API.

Prerequisites

1

Install SGLang

First, install SGLang using pip or uv:
See the Installation Guide for other installation methods.
2

Verify Installation

Launch Your First Server

1

Start the SGLang server

Launch a server with a small model for testing:
The server will download the model from Hugging Face on first launch. Set the HF_TOKEN environment variable if you need to access gated models:
2

Wait for the server to be ready

Look for the following message in the logs:

Send Your First Request

Using OpenAI-Compatible API

SGLang provides OpenAI-compatible endpoints, making it easy to integrate with existing applications.
Expected Output:

Using Native SGLang API

The native SGLang API provides a more Pythonic interface with advanced features.
Expected Output:

Complete Working Example

Here’s a full end-to-end example you can run:
1

Create a Python script

Save this as quickstart.py:
quickstart.py
2

Ensure the server is running

3

Run the example

API Endpoints

SGLang provides several API endpoints:

Sampling Parameters

Control generation behavior with these common parameters:
See Sampling Parameters for the complete list.

Common Use Cases

Troubleshooting

Out of memory error:
CUDA errors:
  • Verify GPU availability: nvidia-smi
  • Check CUDA version: nvcc --version
  • Ensure PyTorch can see GPUs: python -c "import torch; print(torch.cuda.is_available())"
  • Use tensor parallelism for multi-GPU: --tp 2
  • Enable FP8 quantization: --quantization fp8
  • Reduce context length: --context-length 4096
  • See Performance Tuning for optimization
  • Ensure server is running: check for “Uvicorn running” message
  • Verify port is not in use: lsof -i :30000
  • Check firewall settings
  • Use correct host/port in client

Next Steps

Server Arguments

Learn about all available server configuration options

Sampling Parameters

Control generation behavior with sampling parameters

Model Support

Browse supported models and architectures

Production Deployment

Deploy SGLang in production with monitoring