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.

PropertyValue
Provider idsglang
Pluginbundled, enabledByDefault: true
Auth env varSGLANG_API_KEY (any non-empty value if server has no auth)
Onboarding flag--auth-choice sglang
APIOpenAI-compatible (openai-completions)
Default base URLhttp://127.0.0.1:30000/v1
Default model placeholdersglang/Qwen/Qwen3-8B
Streaming usageYes (supportsStreamingUsage: true)
PricingMarked 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.sglang is set explicitly, the models you declared are what OpenClaw uses by default. To have OpenClaw query the /models endpoint of that configured provider and pull in every SGLang model it advertises, add "sglang/*": {} to agents.defaults.models.

Explicit configuration (manual models)

Explicit config is the right choice when:

  • SGLang listens on another host or port.
  • You need contextWindow/maxTokens values 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.

BehaviorSGLang
OpenAI-only request shapingNot applied
service_tier, Responses store, prompt-cache hintsNot sent
Reasoning-compat payload shapingNot 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_KEY will do.

594 words · updated Oct 25, 2026