SGLang Provider: Run OpenClaw with OpenAI-Compatible Self-Hosted Server
This page explains how to use SGLang to serve open-weight models via an OpenAI-compatible API and connect OpenClaw to it. It is intended for users who want to run a self-hosted model server with automatic model discovery.
Read this when
- You want to run OpenClaw against a local SGLang server
- You want OpenAI-compatible /v1 endpoints with your own models
SGLang exposes open-weight models through an OpenAI-compatible HTTP API. OpenClaw connects to SGLang via the openai-completions provider family, with automatic discovery of available models.
| Property | Value |
|---|---|
| Provider id | sglang |
| Plugin | bundled, enabledByDefault: true |
| Auth env var | SGLANG_API_KEY (any non-empty value if server has no auth) |
| Onboarding flag | --auth-choice sglang |
| API | OpenAI-compatible (openai-completions) |
| Default base URL | http://127.0.0.1:30000/v1 |
| Default model placeholder | sglang/Qwen/Qwen3-8B |
| Streaming usage | Yes (supportsStreamingUsage: true) |
| Pricing | Marked external-free (modelPricing.external: false) |
OpenClaw also auto-discovers available models from SGLang when you opt in with SGLANG_API_KEY. Use sglang/* in agents.defaults.models to keep discovery dynamic when you also configure a custom SGLang base URL. See Model discovery (implicit provider) below.
Getting started
Start SGLang
Start SGLang with an OpenAI-compatible server. Your base URL must expose /v1 endpoints (for example /v1/models, /v1/chat/completions). SGLang typically runs on:
http://127.0.0.1:30000/v1
Set an API key
Any value is acceptable if no authentication is configured on your server:
export SGLANG_API_KEY="sglang-local"
Run onboarding or set a model directly
openclaw onboard
Or set up the model manually:
{
agents: {
defaults: {
model: { primary: "sglang/your-model-id" },
},
},
}
Model discovery (implicit provider)
When SGLANG_API_KEY is set (or an auth profile exists) and you do not define models.providers.sglang, OpenClaw queries:
GET http://127.0.0.1:30000/v1/models
and maps the returned IDs into model entries.
Note
If you set
models.providers.sglangexplicitly, OpenClaw uses your declared models by default. Add"sglang/*": {}toagents.defaults.modelswhen you want OpenClaw to query that configured provider's/modelsendpoint and include all advertised SGLang models.
Explicit configuration (manual models)
Use explicit configuration when:
- SGLang runs on a different host or port.
- You want to pin
contextWindowormaxTokensvalues. - Your server requires a real API key (or you want to control headers).
{
models: {
providers: {
sglang: {
baseUrl: "http://127.0.0.1:30000/v1",
apiKey: "${SGLANG_API_KEY}",
api: "openai-completions",
models: [
{
id: "your-model-id",
name: "Local SGLang Model",
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 128000,
maxTokens: 8192,
},
],
},
},
},
}
Advanced configuration
Proxy-style behavior
SGLang is treated as a proxy-style OpenAI-compatible /v1 backend, not a native OpenAI endpoint.
| Behavior | SGLang |
|---|---|
| OpenAI-only request shaping | Not applied |
service_tier, Responses store, prompt-cache hints | Not sent |
| Reasoning-compat payload shaping | Not applied |
Hidden attribution headers (originator, version, User-Agent) | Not injected on custom SGLang base URLs |
Troubleshooting
Server not reachable
Confirm the server is running and responding:
curl http://127.0.0.1:30000/v1/models
Auth errors
If requests fail with auth errors, set a real SGLANG_API_KEY that matches your server configuration, or configure the provider explicitly under models.providers.sglang.
Tip
If you run SGLang without authentication, any non-empty value for
SGLANG_API_KEYis enough to opt in to model discovery.
Related
-
Model selection, Choosing providers, model refs, and failover behavior.
-
Configuration reference, Full config schema including provider entries.