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

# vLLM

> Leiten Sie OpenAI-kompatible GoModel-Requests an einen oder mehrere vLLM-Server weiter, einschließlich Hugging-Face-Modell-IDs mit Schrägstrichen.

GoModel kommuniziert mit vLLM über dessen OpenAI-kompatiblen HTTP-Server.
Hugging-Face-Modell-IDs mit Schrägstrichen (z. B.
`meta-llama/Llama-3.1-8B-Instruct`) funktionieren – GoModel trennt Selektoren
mit Provider-Angabe nur am ersten Schrägstrich.

Starten Sie zuerst vLLM:

```bash theme={null}
vllm serve meta-llama/Llama-3.1-8B-Instruct
# --api-key token-abc123 ergänzen, wenn vLLM Bearer-Authentifizierung verlangen soll
```

## Konfigurieren

```bash theme={null}
VLLM_BASE_URL=http://host.docker.internal:8000/v1   # /v1 angeben
# VLLM_API_KEY=token-abc123                         # nur, wenn vLLM mit --api-key gestartet wurde
GOMODEL_MASTER_KEY=change-me
```

> [!NOTE]
>
> Diese Beispiele gehen davon aus, dass GoModel in Docker läuft und vLLM auf
> dem Host unter `localhost:8000` – daher `host.docker.internal`. Laufen beide
> im selben Docker-Netzwerk, verwenden Sie den Service-Namen von vLLM. Läuft
> GoModel direkt auf dem Host, verwenden Sie `http://localhost:8000/v1`.

## GoModel starten

```bash Docker (.env-Datei) theme={null}
docker run --rm -p 8080:8080 --env-file .env enterpilot/gomodel
```

```bash Docker (inline -e) theme={null}
docker run --rm -p 8080:8080 \
  -e GOMODEL_MASTER_KEY="change-me" \
  -e VLLM_BASE_URL="http://host.docker.internal:8000/v1" \
  enterpilot/gomodel
```

```bash Binary (make build) theme={null}
make build
./bin/gomodel
```

## Überprüfen

```bash curl theme={null}
curl -s http://localhost:8080/v1/chat/completions \
  -H "Authorization: Bearer change-me" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "vllm/meta-llama/Llama-3.1-8B-Instruct",
    "messages": [{"role": "user", "content": "Reply with exactly ok."}]
  }'
```

```python Python theme={null}
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8080/v1", api_key="change-me")

completion = client.chat.completions.create(
    model="vllm/meta-llama/Llama-3.1-8B-Instruct",
    messages=[{"role": "user", "content": "Reply with exactly ok."}],
)

print(completion.choices[0].message.content)
```

```javascript JavaScript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:8080/v1",
  apiKey: "change-me",
});

const completion = await client.chat.completions.create({
  model: "vllm/meta-llama/Llama-3.1-8B-Instruct",
  messages: [{ role: "user", content: "Reply with exactly ok." }],
});

console.log(completion.choices[0].message.content);
```

`GET /v1/models` gibt die Modell-IDs von vLLM mit dem Provider-Namen als
Präfix zurück, z. B. `vllm/meta-llama/Llama-3.1-8B-Instruct`.

## Mehrere vLLM-Instanzen

Verwenden Sie Umgebungsvariablen mit Suffix, um ohne YAML mehr als eine Instanz
zu registrieren:

```bash theme={null}
VLLM_BASE_URL=http://host.docker.internal:8000/v1
VLLM_TEST_BASE_URL=http://host.docker.internal:8001/v1
```

`VLLM_BASE_URL` registriert `vllm`. `VLLM_TEST_BASE_URL` registriert
`vllm-test` (das Suffix wird kleingeschrieben, Unterstriche werden zu
Bindestrichen).

## vLLM-Passthrough

Passthrough ist standardmäßig aktiviert. Verwenden Sie ihn für vLLM-spezifische
Endpunkte wie `/tokenize`, `/detokenize`, `/pooling`, `/rerank`:

```bash curl theme={null}
curl -s http://localhost:8080/p/vllm/tokenize \
  -H "Authorization: Bearer change-me" \
  -H "Content-Type: application/json" \
  -d '{"model": "meta-llama/Llama-3.1-8B-Instruct", "prompt": "Hello"}'
```

```python Python theme={null}
import httpx

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8080", api_key="change-me")
tokens = client.post(
    "/p/vllm/tokenize",
    cast_to=httpx.Response,
    body={
        "model": "meta-llama/Llama-3.1-8B-Instruct",
        "prompt": "Hello",
    },
)

print(tokens.json())
```

```javascript JavaScript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:8080",
  apiKey: "change-me",
});

const tokens = await client.post("/p/vllm/tokenize", {
  body: {
    model: "meta-llama/Llama-3.1-8B-Instruct",
    prompt: "Hello",
  },
});

console.log(tokens);
```

GoModel entfernt die Authentifizierungs-Header des Clients vor der
Weiterleitung und verwendet für Upstream-Requests `VLLM_API_KEY`, sofern
konfiguriert.

> [!NOTE]
>
> Passthrough-Routen sind unter `/p/vllm/...` auf den Provider-Typ bezogen. Um
> in einem Setup mit mehreren vLLM-Instanzen eine bestimmte benannte Instanz
> anzusprechen, verwenden Sie übersetzte `/v1/...`-Requests mit Modell-IDs mit
> Provider-Angabe (z. B. `vllm-test/meta-llama/Llama-3.1-8B-Instruct`).

## Noch nicht integriert

* Native Batch-APIs von vLLM.
* OpenAI-kompatibler Lebenszyklus für Dateien.
* Hilfsendpunkte für den Lebenszyklus von Responses.


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