SGLang Provider: Self-Hosted OpenAI-Compatible Server

This page explains how to use OpenClaw with SGLang, a self-hosted server for open-weight models. It covers setup, authentication, and configuration for developers running local AI models.

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. The openai-completions provider family in OpenClaw handles connections to SGLang and automatically finds the models that are available.

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)

When you enable SGLANG_API_KEY, OpenClaw will auto-discover the models that SGLang serves. To keep discovery dynamic while also specifying a custom base URL for SGLang, set sglang/* inside agents.defaults.models. Refer to Model discovery (implicit provider) below.

Getting started

Start SGLang

Start SGLang with an OpenAI compatible server. Your base URL must expose /v1 endpoints, for instance /v1/models or /v1/chat/completions. SGLang is typically deployed on:

  • http://127.0.0.1:30000/v1

Set an API key

If your server has no authentication configured, any value is accepted:

export SGLANG_API_KEY="sglang-local"

Run onboarding or set a model directly

openclaw onboard

Alternatively, define the model manually:

{
  agents: {
    defaults: {
      model: { primary: "sglang/your-model-id" },
    },
  },
}

Model discovery (implicit provider)

When SGLANG_API_KEY is configured (or an auth profile is present) and models.providers.sglang is not set, OpenClaw sends requests to:

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

and turns the returned IDs into model entries.

Note

If models.providers.sglang is set explicitly, OpenClaw defaults to using the models you declared. To have OpenClaw also query the /models endpoint of that configured provider and incorporate every advertised SGLang model, add "sglang/*": {} to agents.defaults.models.

Explicit configuration (manual models)

Use explicit configuration when:

  • SGLang is running on a different host or port.
  • You need to fix contextWindow or maxTokens values.
  • Your server demands a real API key, or you want to control the 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 functions as a proxy style OpenAI compatible /v1 backend, not as 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

Make sure the server is active and answering requests:

curl http://127.0.0.1:30000/v1/models

Auth errors

If authentication errors occur, supply a valid SGLANG_API_KEY that matches your server's setup, or explicitly configure the provider under models.providers.sglang.

Tip

When SGLang is running without authentication, any non-empty SGLANG_API_KEY value is enough to enable model discovery.

553 words · updated Jul 27, 2026