SGLang Provider Setup for OpenClaw Self-Hosted Servers
Learn how OpenClaw connects to a self-hosted SGLang server through the OpenAI-compatible openai-completions provider family. Covers provider id, auth env var, default base URL, and 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 HTTP API that is compatible with OpenAI. To reach it, OpenClaw uses the openai-completions provider family, which finds the models that are available on its own.
| 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) |
Model discovery can also run automatically: turn it on with SGLANG_API_KEY, and OpenClaw will auto-discover the models SGLang offers. If a custom SGLang base URL is configured as well and you want discovery to stay dynamic, put sglang/* in agents.defaults.models. The section Model discovery (implicit provider) below covers this.
Getting started
Start SGLang
Start SGLang with a server that speaks the OpenAI-compatible protocol. The base URL you point at must serve
/v1 endpoints (/v1/models and /v1/chat/completions are examples). Typical hosts for SGLang are:
http://127.0.0.1:30000/v1
Set an API key
When your server has no auth configured, any value is accepted:
export SGLANG_API_KEY="sglang-local"
Run onboarding or set a model directly
openclaw onboard --auth-choice sglang
The model can also be set up by hand:
{
agents: {
defaults: {
model: { primary: "sglang/your-model-id" },
},
},
}
Model discovery (implicit provider)
Provided that SGLANG_API_KEY is set (or an auth profile exists) and models.providers.sglang is not defined by you, the following is queried by OpenClaw:
GET http://127.0.0.1:30000/v1/models
The IDs that come back are then turned into model entries.
Note
When
models.providers.sglangis set explicitly, the models you declared are what OpenClaw uses by default. To have OpenClaw query the/modelsendpoint of that configured provider and pull in every SGLang model it advertises, add"sglang/*": {}toagents.defaults.models.
Explicit configuration (manual models)
Explicit config is the right choice when:
- SGLang listens on another host or port.
- You need
contextWindow/maxTokensvalues pinned. - A real API key is required by your server, or you want control over 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
OpenClaw treats SGLang as a proxy-style OpenAI-compatible /v1 backend rather than 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
Check that the server is up and answering:
curl http://127.0.0.1:30000/v1/models
Auth errors
Should requests come back with auth errors, supply a real SGLANG_API_KEY that agrees with your server's configuration, or set the provider up explicitly under models.providers.sglang.
Tip
Running SGLang without authentication still lets you opt in to model discovery: any non-empty value for
SGLANG_API_KEYwill do.
Related
-
Model selection, How to pick providers, model refs, and failover behavior.
-
Configuration reference, The complete config schema, provider entries included.