> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokios.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Tokios exposes private local models through https://api.tokios.com using an outbound-only connector tunnel.
> Use 'connector' for the local tokios-connector process.
> Use 'deployment' for the public model name in the API model field.
> Use 'upstream model id' for the model served by Ollama, llama.cpp, vLLM, LM Studio, or another local backend.
> API keys use the prefix sk-tok-. Connector tokens use the prefix ct-tok-.

# Use an SGLang server from anywhere — safely

> Reach your SGLang OpenAI-compatible server from other machines, agents, or teammates without exposing its port — using an outbound-only connector and API key.

SGLang launches an OpenAI-compatible server, and Tokios forwards to **any** server that speaks the OpenAI Chat Completions API — so SGLang works as a generic OpenAI-compatible upstream. Keep SGLang on localhost and run the Tokios connector next to it: the connector dials out to `https://api.tokios.com`, and your tools, teammates, or agents call one authenticated endpoint from anywhere.

> [!NOTE]
>
> **Advanced runtime.** SGLang is a Python GPU server built for high-throughput serving, with more setup than a desktop tool. If you just want the easiest path, start with [Ollama](https://docs.tokios.com/guides/ollama-remote-access.md) or [LM Studio](https://docs.tokios.com/guides/lm-studio-remote-access.md).

> [!NOTE]
>
> SGLang exposes an OpenAI-compatible Chat Completions API, so it works with Tokios like any OpenAI-compatible server: the connector forwards to whatever `/v1` `BaseUrl` you set, regardless of which server implements that surface. Ollama, llama.cpp, vLLM, and LM Studio are the backends Tokios documents most closely (see [Supported backends](https://docs.tokios.com/setup/supported-backends.md)), but SGLang works the same way. If you hit a gap, it's likely in SGLang's OpenAI compatibility itself rather than in Tokios.

## The outbound-only way

**1. Run SGLang locally, as usual**

Keep SGLang on `127.0.0.1` — don't bind it wider than loopback. Launch its OpenAI-compatible server:

```bash theme={"theme":{"light":"github-light","dark":"css-variables"}}
python -m sglang.launch_server --model-path <path-or-repo-id> --port 30000
```

The default `--port` value and whether SGLang binds to `127.0.0.1` or `0.0.0.0` out of the box can vary by version — bind it to loopback explicitly if it doesn't already.

**2. Pair the Tokios connector**

Sign in at [tokios.com/console](https://tokios.com/console), open the **Setup** tab, and click **Start pairing**. Tokios shows a one-time **claim code** like `TKS-XXXX-XXXX`, valid for about 15 minutes.

On the machine running SGLang, run the install one-liner for your OS:

```powershell Windows theme={"theme":{"light":"github-light","dark":"css-variables"}}
irm https://tokios.com/downloads/install/windows | iex; tokios-install -Code 'TKS-XXXX-XXXX'
```

```bash macOS theme={"theme":{"light":"github-light","dark":"css-variables"}}
curl -fsSL https://tokios.com/downloads/install/macos | sh -s -- --code TKS-XXXX-XXXX
```

```bash Linux theme={"theme":{"light":"github-light","dark":"css-variables"}}
curl -fsSL https://tokios.com/downloads/install/linux | sh -s -- --code TKS-XXXX-XXXX
```

Already have `tokios-connector` installed? Pass the code directly instead:

```bash theme={"theme":{"light":"github-light","dark":"css-variables"}}
tokios-connector TKS-XXXX-XXXX
```

Back in the console, **approve** the device on the **Setup** or **Connectors** tab. The connector's token is delivered over the tunnel once approved — you never see it on screen or paste it into a file.

**3. Point the connector at SGLang's /v1 API**

SGLang's server speaks the same OpenAI Chat Completions surface Tokios expects. For the basic single-model path, the console's Setup wizard lets you enter the upstream manually — use `http://127.0.0.1:30000/v1`. If you're serving multiple models through a `tokios-connector.json` config, set the upstream `BaseUrl` explicitly, **including `/v1`**:

```json theme={"theme":{"light":"github-light","dark":"css-variables"}}
{
  "Upstream": {
    "BaseUrl": "http://127.0.0.1:30000/v1"
  }
}
```

See [Connector config](https://docs.tokios.com/reference/connector-config.md) for the full multi-model file format.

**4. Register a deployment**

In the [Models](https://tokios.com/console/models) tab, register the SGLang model and choose a **public name** — for example, `sglang-tunnel`. That public name, not SGLang's local model id, is what clients send in the `model` field.

**5. Create an API key**

In the [Keys](https://tokios.com/console/keys) tab, click **Create key**. Optionally scope it to specific deployments with model-name patterns (comma-separated globs, `*` for all). Copy the `sk-tok-…` key now — it's shown only once.

> [!TIP]
>
> SGLang has an `--api-key` launch option that requires a bearer token on requests to its own server. You can keep it as defense in depth on the loopback connection between the connector and SGLang, but it isn't what authenticates callers reaching you through Tokios — that's your `sk-tok-…` key. Check the exact flag syntax and whether it covers all SGLang endpoints or only `/v1` paths against your SGLang version.

## Use it from anywhere

Once you have a deployment name and an API key, any OpenAI- or Anthropic-compatible client can reach your SGLang model — from another machine, a teammate's laptop, or a hosted agent.

```bash curl theme={"theme":{"light":"github-light","dark":"css-variables"}}
curl https://api.tokios.com/v1/chat/completions \
  -H "Authorization: Bearer sk-tok-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sglang-tunnel",
    "stream": true,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
```

```python Python (OpenAI SDK) theme={"theme":{"light":"github-light","dark":"css-variables"}}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.tokios.com/v1",
    api_key="sk-tok-YOUR_KEY",
)

response = client.chat.completions.create(
    model="sglang-tunnel",
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")
```

```bash Claude Code theme={"theme":{"light":"github-light","dark":"css-variables"}}
export ANTHROPIC_BASE_URL=https://api.tokios.com
export ANTHROPIC_API_KEY=sk-tok-YOUR_KEY
claude --model sglang-tunnel
```

> [!TIP]
>
> The `model` field is always your registered **deployment** name (`sglang-tunnel` above), never SGLang's local model id. See [Use Claude Code](https://docs.tokios.com/guides/claude-code.md) for persisting the environment variables across sessions.

## FAQ

> [accordion] Is SGLang officially supported by Tokios?
>
> Ollama, llama.cpp, vLLM, and LM Studio are the backends Tokios documents most closely — see [Supported backends](https://docs.tokios.com/setup/supported-backends.md). But the connector doesn't inspect which server is behind the upstream — it forwards requests to whatever `BaseUrl` you configure, and SGLang's launch server speaks the same OpenAI Chat Completions surface those backends do, so it works the same way. If SGLang's OpenAI compatibility diverges from the others in some edge case, that's a SGLang-side detail rather than a Tokios one.

> [accordion] Does streaming work?
>
> Yes. Set `"stream": true` and Tokios returns standard server-sent events (SSE) in OpenAI or Anthropic format, depending on which API surface you called.

> [accordion] Can I serve more than one model through SGLang?
>
> Register additional deployments in the [Models](https://tokios.com/console/models) tab, or use a `tokios-connector.json` config file to define multiple upstreams and routes for a single connector — useful if you run more than one SGLang process. See [Connector config](https://docs.tokios.com/reference/connector-config.md).

> [accordion] Can I share access with teammates without exposing SGLang directly?
>
> Yes. Create a separate `sk-tok-…` key per teammate in the [Keys](https://tokios.com/console/keys) tab, and scope each key to only the deployments they need. Revoking a key stops it from authenticating immediately, so you can cut off access without touching SGLang or the connector.

## Your model never leaves your machine — your endpoint works everywhere

SGLang keeps doing exactly what it does today, on localhost, with no inbound ports and no endpoints exposed beyond `/v1`. The connector only dials out. Everything past that — auth, routing, streaming — is one endpoint you can call from any machine, teammate, or agent you choose to give a key to.

> [card] [Supported backends](https://docs.tokios.com/setup/supported-backends.md)
>
> See the full list of named backends and default upstream ports.

> [card] [API keys](https://docs.tokios.com/setup/api-keys.md)
>
> Create, scope, and rotate `sk-tok-…` keys for teammates and agents.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.