Skip to content

SGLang

SGLang can serve open-source models via an OpenAI-compatible HTTP API. OpenClaw can connect to SGLang using the openai-completions API.

OpenClaw can also auto-discover available models from SGLang when you opt in with SGLANG_API_KEY (any value works if your server does not enforce auth) and you do not define an explicit models.providers.sglang entry.

  1. Start SGLang with an OpenAI-compatible server.

Your base URL should expose /v1 endpoints (for example /v1/models, /v1/chat/completions). SGLang commonly runs on:

  • http://127.0.0.1:30000/v1
  1. Opt in (any value works if no auth is configured):
Terminal window
export SGLANG_API_KEY="sglang-local"
  1. Run onboarding and choose SGLang, or set a model directly:
Terminal window
openclaw onboard
{
agents: {
defaults: {
model: { primary: "sglang/your-model-id" },
},
},
}

When SGLANG_API_KEY is set (or an auth profile exists) and you do not define models.providers.sglang, OpenClaw will query:

  • GET http://127.0.0.1:30000/v1/models

and convert the returned IDs into model entries.

If you set models.providers.sglang explicitly, auto-discovery is skipped and you must define models manually.

Use explicit config when:

  • SGLang runs on a different host/port.
  • You want to pin contextWindow/maxTokens values.
  • 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,
},
],
},
},
},
}
  • Check the server is reachable:
Terminal window
curl http://127.0.0.1:30000/v1/models
  • 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.

SGLang is treated as a proxy-style OpenAI-compatible /v1 backend, not a native OpenAI endpoint.

  • native OpenAI-only request shaping does not apply here
  • no service_tier, no Responses store, no prompt-cache hints, and no OpenAI reasoning-compat payload shaping
  • hidden OpenClaw attribution headers (originator, version, User-Agent) are not injected on custom SGLang base URLs