Developing

Run your Code Harness through Praxis and vLLM

Connect Codex or Claude Code through a local Praxis AI gateway to inference served by vLLM.

Praxis AI v0.13.0 (alpha) 33 min read
On this page

This guide runs a real coding client through a local Praxis gateway, with vLLM serving inference. The supported paths are:

Codex       -> Praxis /v1/responses        -> vLLM /v1/responses (native)
Codex       -> Praxis /v1/responses        -> vLLM /v1/chat/completions (translated)
Claude Code -> Praxis /v1/messages         -> vLLM /v1/messages (native)
Claude Code -> Praxis /v1/messages         -> vLLM /v1/chat/completions (translated)
OpenCode    -> Praxis /v1/chat/completions -> vLLM /v1/chat/completions (native)
pi          -> Praxis /v1/chat/completions -> vLLM /v1/chat/completions (native)

Use a native path when vLLM exposes the matching Responses or Anthropic-compatible API. On the native Codex path, Praxis keeps /v1/responses end to end and lowers only the client-owned tool types vLLM does not understand. Use a translated path when the backend exposes only OpenAI Chat Completions. One gateway can serve all four clients at once; see Serving all four clients from one gateway.

To run the clients inside NVIDIA OpenShell sandboxes while Praxis and vLLM stay on the host, set up vLLM and Praxis here, then follow Run your Code Harness in OpenShell through Praxis and vLLM.

1. Start vLLM

On-demand GPU endpoint

In GitHub Actions, open vLLM Dev Endpoint, choose Run workflow, and keep the defaults. The workflow provisions a temporary GPU, publishes a Cloudflare URL in the run summary, and tears everything down at the requested deadline or when the run is cancelled. The defaults serve Qwen3-8B with --reasoning-parser qwen3 and thinking off, which the coding clients below expect. Change the reasoning_parser and enable_thinking inputs only for a different model or when you want visible reasoning.

Record the two summary values:

export VLLM_URL=https://example.trycloudflare.com
export VLLM_MODEL=qwen3-8b

The Quick Tunnel is an unauthenticated, best-effort development endpoint. Treat its random URL as sensitive, keep it out of production, and cancel the workflow when you finish testing.

Existing or local vLLM

If vLLM is already reachable, set the same variables to its URL and exact served model name. To start a keyed local server:

export VLLM_API_KEY="$(openssl rand -hex 32)"
vllm serve Qwen/Qwen3-8B \
  --served-model-name qwen3-8b \
  --max-model-len 32768 \
  --enable-auto-tool-choice \
  --tool-call-parser hermes \
  --reasoning-parser qwen3 \
  --default-chat-template-kwargs '{"enable_thinking":false}' \
  --gpu-memory-utilization 0.97 \
  --enforce-eager \
  --api-key "$VLLM_API_KEY"

Or run the official vllm/vllm-openai image. Its entrypoint starts the server, so the arguments are the same vllm serve flags, and it reads the backend key from VLLM_API_KEY in the container environment:

export VLLM_API_KEY="$(openssl rand -hex 32)"
docker run --rm --name vllm \
  --gpus all \
  --ipc=host \
  -p 8000:8000 \
  -v "$HOME/.cache/huggingface:/root/.cache/huggingface" \
  -e VLLM_API_KEY \
  docker.io/vllm/vllm-openai:latest \
  --model Qwen/Qwen3-8B \
  --served-model-name qwen3-8b \
  --max-model-len 32768 \
  --enable-auto-tool-choice \
  --tool-call-parser hermes \
  --reasoning-parser qwen3 \
  --default-chat-template-kwargs '{"enable_thinking":false}' \
  --gpu-memory-utilization 0.97 \
  --enforce-eager

With Podman, replace --gpus all with --device nvidia.com/gpu=all. For reproducible behavior, pin a released tag instead of latest; the on-demand workflow uses the CUDA 13 default v0.32.0 image. Avoid the -cu129 variant: it currently resolves a CUDA 13 torchcodec wheel that cannot load without libnvrtc.so.13. The first run downloads a multi-gigabyte image plus the model weights; the Hugging Face cache mount keeps the weights for later runs.

Use VLLM_URL=http://127.0.0.1:8000 for either local server.

Reasoning flags matter for Claude Code

The two reasoning flags above deliberately differ from what CI serves:

  • --reasoning-parser qwen3 matches the model family. The parser decides how vLLM splits a <think> block out of the completion into reasoning_content; a parser for another family can leave that text in the assistant message.
  • --default-chat-template-kwargs '{"enable_thinking":false}' turns Qwen3 thinking off in the chat template, so the model emits no <think> block on the agentic turns Claude Code drives.

With --reasoning-parser deepseek_r1 and thinking on, Claude Code’s plan mode looped endlessly and wrote reasoning text into the plan. The two flags above fixed it and were verified together, so change them as a pair. If you need visible reasoning for other work, expect agentic clients to degrade.

The nightly vllm-gpu-claude-acceptance job guards this pairing. It drives a read-only planning turn through the native Anthropic path and fails if the run exhausts its turn budget or a <think> delimiter reaches user-visible text. The scenario is pinned in [claude_code.launch.planning] of tests/integration/fixtures/claude-code-cli/pin.toml, and reverting either flag should turn it red. It approximates the turn that broke, since interactive plan mode is not available through claude -p.

The 32,768-token window is sized for Claude Code auto mode. Its client-side safety classifier asks for about 2,112 output tokens regardless of Claude Code’s main output setting, on top of a large client-owned prompt, which alone can exceed a 16K or 18K window. On an A10G, eager execution reclaims CUDA-graph memory, and 0.97 utilization assumes a single-user development workload. If you lower the window or share the GPU, use auto mode only if the classifier request still fits. Claude Code’s default output budget is covered in section 4.

2. Point a Praxis example at vLLM

Copy the example for your client outside examples/:

# Codex, native Responses API (preferred for vLLM)
cp examples/configs/openai/responses/client-tool-compat.yaml praxis-vllm.yaml

# Codex, translated to Chat Completions
cp examples/configs/openai/responses/codex-http-chat-translation.yaml praxis-vllm.yaml

# Claude Code, native Anthropic API (preferred for vLLM), OpenCode, or pi
cp examples/configs/anthropic/messages-native-vllm.yaml praxis-vllm.yaml

# Claude Code, translated to Chat Completions
cp examples/configs/anthropic/messages-to-openai-vllm.yaml praxis-vllm.yaml

The native Claude configuration also declares a /v1/chat/completions route that forwards to vLLM without body translation, with Anthropic validation scoped to /v1/messages. OpenCode and pi use that route, so one gateway serves Claude Code, OpenCode, and pi together as long as vLLM supports their endpoints.

The native Codex example uses 127.0.0.1:3001 as its fixture backend; change that endpoint to 127.0.0.1:8000 for the local vLLM server. The other examples already target port 8000. For the on-demand HTTPS endpoint, remove https:// from VLLM_URL and replace the example’s vLLM backend endpoint with:

endpoints:
  - "example.trycloudflare.com:443"
tls:
  sni: "example.trycloudflare.com"

For the translated Codex example, replace the fixed provider credential with the environment-backed form the Claude examples use:

- filter: credential_injection
  clusters:
    - name: codex-chat-provider
      header: Authorization
      env_var: VLLM_API_KEY
      header_prefix: "Bearer "
      strip_client_credential: true

Set a backend key. It must match --api-key on a keyed vLLM server; any random value works for the unauthenticated dev endpoint:

export VLLM_API_KEY="${VLLM_API_KEY:-$(openssl rand -hex 32)}"
export GATEWAY_AUTH_PASSWORD="$(openssl rand -hex 24)"

Serving all four clients from one gateway

openshell/sandboxed-coding-clients.yaml serves all four clients over their native paths from one process. It sits under openshell/ because the sandbox guide reuses it, but nothing in it is OpenShell-specific. It combines the Claude Code, OpenCode, and pi chain from anthropic/messages-native-vllm.yaml with the Codex chain from openai/responses/client-tool-compat.yaml, on two listeners that point at the same vLLM server and share one GATEWAY_AUTH_PASSWORD.

The example binds both listeners to 0.0.0.0 because sandboxed clients arrive on the host’s container-bridge interface. Bind 127.0.0.1 when every client runs on the gateway host. For callers on another host, firewall both ports to those callers and put TLS in front of the listeners: the client credential is Basic, so anyone who can read a plain-HTTP connection can recover it. A remote client’s base URL must use https://; plain HTTP is for a loopback gateway only.

listeners:
  # Claude Code (/v1/messages), OpenCode and pi (/v1/chat/completions).
  - name: messages-chat-gateway
    address: "127.0.0.1:8080"
    filter_chains: [claude-and-opencode]

  # Codex (/v1/responses).
  - name: responses-gateway
    address: "127.0.0.1:8081"
    filter_chains: [codex-responses]

filter_chains:
  - name: claude-and-opencode
    filters: # ... from anthropic/messages-native-vllm.yaml
  - name: codex-responses
    # Prefix with the same basic_auth filter the chain above uses, so one
    # shared credential gates both listeners. Give this chain's cluster its
    # own name; the endpoint is the same vLLM server. Also add a
    # credential_injection inside the IRR inference step — see below.
    filters: # ... from openai/responses/client-tool-compat.yaml

The Codex chain needs two edits. The standalone example has no auth filter and forwards the client’s Bearer credential to keyed vLLM. Prefixing basic_auth (with its default strip_authorization) removes that credential, and the chain has no credential_injection to replace it, so the sub-request reaches vLLM unauthenticated and fails with 401. Add the injection inside the IRR inference step, after router, as the Claude chain does:

              - filter: router
                routes:
                  - path_prefix: "/"
                    cluster: "vllm-responses-backend"
              # `basic_auth` at the head of the chain stripped the caller's
              # `Authorization`, so the sub-request reaches keyed vLLM
              # unauthenticated without this.
              - filter: credential_injection
                clusters:
                  - name: vllm-responses-backend
                    header: Authorization
                    env_var: VLLM_API_KEY
                    header_prefix: "Bearer "
                    strip_client_credential: true
              - filter: load_balancer
                # ... unchanged from the example

The cluster name must match the one the step’s router and load_balancer select.

Codex needs its own listener. Its rich client tools need openai_client_tool_compat, which needs openai_stream_events, which fails closed outside an iterative_request_router step. The IRR is a terminal filter that cannot share a chain with a top-level load_balancer, and it buffers a sub-request response unless a filter selects streaming, which the native /v1/messages and /v1/chat/completions paths do not. Routed through it, Claude Code, OpenCode, and pi would render nothing until each turn finished. Each CLI sets its own base URL, so the second port costs one line of client config.

Point Claude Code, OpenCode, and pi at http://127.0.0.1:8080 and Codex at http://127.0.0.1:8081/v1, then follow sections 3 to 6 with two changes. Codex must present the shared Basic credential instead of a Bearer key; see Codex behind the gateway’s Basic auth. From the container image, the store needs an absolute database_url; see the writable database path note, or use PostgreSQL instead.

Run Praxis from source

The SQLite feature enables the local response store the native Codex example uses and does no harm on the other paths. Run Praxis in the background so the two generated secrets stay in the shell that launches the client:

cargo build -p praxis-ai-proxy --no-default-features \
  --features standard,openai-all,store-sqlite
./target/debug/praxis-ai -c praxis-vllm.yaml > /tmp/praxis-vllm.log 2>&1 &
export PRAXIS_PID=$!

Praxis listens at http://127.0.0.1:8080.

Run Praxis from a container image

The standard published image leaves out the experimental Responses filters, the agentic loop, and both stores, and rejects those filters at startup. Use an -experimental tag instead. Every release and nightly tag is also published with that suffix, built as PRAXIS_AI_FEATURES=full,openai-all,store-all:

docker pull ghcr.io/praxis-proxy/ai:latest-experimental

latest-experimental moves on each release. For reproducible behavior, pin a versioned tag such as 0.10.0-experimental, or nightly-experimental for a pre-release, and use it in place of praxis-ai-responses in the docker run commands below.

Build locally only for a feature set the tags do not carry, or for an unreleased commit:

docker build -f Containerfile -t praxis-ai-responses \
  --build-arg PRAXIS_AI_FEATURES=full,openai-all,store-sqlite .

The image entrypoint is praxis-ai, its working directory is /etc/praxis, and it runs as the unprivileged praxis user (UID 100). Mounting the config at /etc/praxis/praxis.yaml is enough, since the binary falls back to praxis.yaml in the working directory, but -c works for any mount path. Praxis reads GATEWAY_AUTH_PASSWORD and VLLM_API_KEY from its own process environment at pipeline build time, so forward them into the container. The z mount suffix relabels the config for SELinux hosts such as Fedora and RHEL; drop it elsewhere.

Host networking (Linux only with Docker) needs no config edits, because 127.0.0.1 inside the container is the host loopback for both the listener and the vLLM backend:

docker run -d --rm --name praxis-vllm \
  --network host \
  -e VLLM_API_KEY -e GATEWAY_AUTH_PASSWORD \
  -v "$PWD/praxis-vllm.yaml:/etc/praxis/praxis.yaml:ro,z" \
  praxis-ai-responses -c /etc/praxis/praxis.yaml

To publish a port instead, make three edits to the copied config:

  1. Change the listener to address: "0.0.0.0:8080". A listener bound to 127.0.0.1 in the container’s namespace is unreachable through a published port.
  2. Change the local vLLM endpoint from 127.0.0.1:8000 to host.docker.internal:8000, and pass --add-host=host.docker.internal:host-gateway.
  3. Add host.docker.internal to trusted_private_endpoints on both load_balancer clusters (vllm-backend and vllm-responses-backend). allow_private_endpoints covers literal private endpoints in the config, but this hostname resolves to a private address. Without the entry, requests fail with upstream hostname resolved to private/reserved IP address. Prefer it over insecure_options.allow_private_upstreams, which relaxes the check for every upstream.
docker run -d --rm --name praxis-vllm \
  -p 8080:8080 \
  --add-host=host.docker.internal:host-gateway \
  -e VLLM_API_KEY -e GATEWAY_AUTH_PASSWORD \
  -v "$PWD/praxis-vllm.yaml:/etc/praxis/praxis.yaml:ro,z" \
  praxis-ai-responses -c /etc/praxis/praxis.yaml

Both commands work unchanged with Podman. Podman also resolves host.containers.internal itself, so the published-port config can use that name (in trusted_private_endpoints too) and drop --add-host. The on-demand GPU endpoint has a public hostname, so the endpoints and tls.sni edits are its only change in either networking mode.

Follow startup with docker logs -f praxis-vllm. For a readiness probe, add an admin listener to the copied config:

admin:
  address: "127.0.0.1:9901"

The admin endpoint must bind loopback unless insecure_options.allow_public_admin: true is set, so query it from inside the container with docker exec praxis-vllm wget -qO- http://127.0.0.1:9901/healthy, or from the host under --network host. To clean up, use docker rm -f praxis-vllm instead of kill.

The native Codex example needs a writable database path

Of the four examples, only client-tool-compat.yaml has a store filter, and it needs an absolute database_url. /etc/praxis is root-owned while the process runs as praxis (UID 100), so the relative sqlite://responses.db?mode=rwc cannot be created: the proxy starts, then the first /v1/responses request fails with HTTP 500 and unable to open database file. Point database_url at /var/lib/praxis, the writable state directory the container user owns:

- filter: openai_responses_store
  backend: sqlite
  database_url: "sqlite:///var/lib/praxis/responses.db?mode=rwc"

The database then lives in the container’s writable layer and goes away with --rm, which suits a CLI test loop. To keep responses across restarts, mount a volume at /var/lib/praxis (-v praxis-state:/var/lib/praxis). With Podman, add :U to chown it to the container user; a host directory needs chown 100:100 (or -m 0777) before the first run.

Using PostgreSQL instead of SQLite

The -experimental tags include both backends; a local build selects one with store-postgres, store-sqlite, or store-all. Switching the Codex example to PostgreSQL is one filter edit:

- filter: openai_responses_store
  backend: postgres
  database_url: "postgres://praxis@127.0.0.1:5432/praxis"
  responses_table: openai_responses
  conversations_table: openai_conversations
  allow_private_database_url: true
  ssl_mode: disable

See openai_responses_store for every field. For this setup:

  • allow_private_database_url is required for a loopback or other private target, which the URL validator rejects by default. It is meant for local development.
  • ssl_mode defaults to verify-full, which a local server without TLS cannot satisfy. Use disable only when the connection stays on the host. For a remote database, keep the default and supply ssl_root_cert; examples/configs/openai/responses/response-store-postgres-mtls.yaml shows the client-certificate variant.
  • The URL can omit the password: SQLx reads PGPASSWORD from the process environment, so pass the secret with -e PGPASSWORD. The require_certificate_authentication profile fails closed when PGPASSWORD is set.
  • Start PostgreSQL first. The store pool connects at startup, and the process exits after three immediate retries on a refused connection.
  • Schema upgrades are recreate-only: a release that needs a newer schema refuses to start against old tables, so treat stored responses as disposable. See Responses store schema upgrade.

3. Connect Codex

Use an isolated Codex home so the test leaves your normal settings alone:

export CODEX_HOME="$(mktemp -d)"
# Native /v1/responses passes this credential through to keyed vLLM.
export PRAXIS_API_KEY="$VLLM_API_KEY"
cat > "$CODEX_HOME/config.toml" <<EOF
model = "$VLLM_MODEL"
model_provider = "praxis"
web_search = "disabled"

[model_providers.praxis]
name = "Local Praxis"
base_url = "http://127.0.0.1:8080/v1"
wire_api = "responses"
env_key = "PRAXIS_API_KEY"
EOF

codex exec --skip-git-repo-check \
  "Inspect this directory, create praxis-vllm-check.txt, then summarize the change."

With the native example, Praxis forwards the Responses traffic to vLLM’s /v1/responses, lowering and restoring Codex-specific tool types without translating to Chat Completions. With the translated example, set PRAXIS_API_KEY=local-codex-client-key; Praxis translates to Chat Completions, injects VLLM_API_KEY, and streams the translated response back.

Codex behind the gateway’s Basic auth

The native Codex example has no basic_auth, so the client credential above is the backend credential. Behind a gateway that authenticates clients, such as the all-in-one gateway, Codex must send the Basic credential instead. Codex builds headers from http_headers and env_http_headers independently of env_key, and appends the env_key bearer as a second Authorization header. Drop env_key and carry the credential in env_http_headers:

export PRAXIS_GATEWAY_AUTH="Basic $(printf 'gateway:%s' "$GATEWAY_AUTH_PASSWORD" | base64)"
[model_providers.praxis]
name = "Local Praxis"
base_url = "http://127.0.0.1:8081/v1"
wire_api = "responses"
env_http_headers = { Authorization = "PRAXIS_GATEWAY_AUTH" }

With no env_key, no experimental_bearer_token, and requires_openai_auth at its default, Codex adds no auth headers of its own. The isolated CODEX_HOME matters here: a logged-in Codex home would supply ambient credentials this provider would inherit. basic_auth verifies and strips the client credential, and credential_injection supplies VLLM_API_KEY toward vLLM, the same three-credential separation the Claude examples use.

The Codex app-server daemon outlives your shell

Codex 0.162 and newer send provider requests from a long-lived app-server daemon under $CODEX_HOME/app-server-daemon/, not from the TUI. The daemon resolves env_http_headers and keeps the environment of the shell that first spawned it, so re-exporting credentials in a new shell has no effect on a running daemon. The symptom is Codex getting 401 from the gateway while a plain curl from the same shell succeeds.

To confirm, check the Praxis access log. The user agent carries the TUI’s version and the daemon’s, and a mismatch means the daemon is stale:

user_agent.original="codex-tui/0.162.1 (…) (codex-tui; 0.160.1)"
                                 TUI ↑              ↑ daemon actually serving

Kill the daemon, then relaunch from a shell with the credential exported:

kill "$(jq -r .pid "$CODEX_HOME/app-server-daemon/daemon.pid")"
kill "$(jq -r .pid "$CODEX_HOME/app-server-daemon/daemon-updater.pid")"
pgrep -af app-server   # confirm nothing survived
codex

A Codex upgrade does not restart the daemon either, so repeat this whenever the two versions diverge. A fresh CODEX_HOME="$(mktemp -d)" avoids the problem only if no daemon was spawned earlier in that home.

4. Connect Claude Code

The Claude examples authenticate the client with Basic auth and replace its Anthropic key with VLLM_API_KEY toward vLLM:

export ANTHROPIC_BASE_URL=http://127.0.0.1:8080
export ANTHROPIC_API_KEY=local-claude-client-key
export ANTHROPIC_CUSTOM_HEADERS="Authorization: Basic $(printf 'gateway:%s' "$GATEWAY_AUTH_PASSWORD" | base64)"
export ANTHROPIC_MODEL="$VLLM_MODEL"
export ANTHROPIC_DEFAULT_MODEL="$VLLM_MODEL"
export ANTHROPIC_DEFAULT_OPUS_MODEL="$VLLM_MODEL"
export ANTHROPIC_DEFAULT_SONNET_MODEL="$VLLM_MODEL"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="$VLLM_MODEL"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
# Optional headroom: cap the requested output budget (see the note below).
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192
# Tell Claude Code the served model's real window so it auto-compacts before
# vLLM rejects the prompt (see the note below).
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=32768
# Required if you select Claude Code's auto permission mode with this backend.
export CLAUDE_CODE_AUTO_MODE_SERVER=0

claude --model "$VLLM_MODEL"
# To exercise client-classified auto mode explicitly:
# claude --permission-mode auto --model "$VLLM_MODEL"

GATEWAY_AUTH_PASSWORD and VLLM_API_KEY must be in the Praxis process environment. The other variables configure Claude Code.

The translated messages-to-openai-vllm.yaml route sets allow_lossy_features: [prompt_caching, extended_thinking, mid_conversation_system], so Claude Code can keep thinking and prompt caching on. Praxis strips the markers Chat Completions cannot represent and folds Claude Code’s mid-conversation system message (its environment block) into the leading one, which some vLLM chat templates would otherwise reject with “System message must be at the beginning”. Each loss is reported rather than rejected; see anthropic_messages_to_chat_completions.

To see the strict behavior, a 400 on any thinking or prompt-caching marker, remove allow_lossy_features from the anthropic_messages_to_chat_completions filter in your copy of messages-to-openai-vllm.yaml and disable both features in Claude Code. Do not switch to the plain messages-to-openai.yaml example for this: it injects no backend credential, so the keyed vLLM server rejects it with 401 first.

export CLAUDE_CODE_DISABLE_THINKING=1
export DISABLE_PROMPT_CACHING=1

Claude Code always sends the mid-conversation system message, and the strict route keeps it in place, so the model’s chat template decides whether the request survives. This guide’s default Qwen3-8B template renders it in place.

Claude Code sends the default max_tokens for the Anthropic model name it believes it is calling, not one sized to the backend. vLLM treats that budget as an upper bound: get_max_tokens caps it at --max-model-len minus the prompt length, and vLLM rejects a request up front only when the prompt itself exceeds the window or the budget alone exceeds --max-model-len. This was verified against vLLM 0.32.0, the version the on-demand endpoint and the GPU nightly serve, on both Chat Completions and /v1/messages. An oversized default therefore costs no prompt space. The 8192 cap above is optional and only keeps each turn’s output budget predictable.

Claude Code sizes auto-compaction against the window it assumes for an unrecognized model name, so on its own it compacts too late: once the prompt passes --max-model-len, every request fails with HTTP 400 and the conversation can only be /cleared. Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the server’s real --max-model-len for any model name that is not a canonical claude-* id, which includes the served alias. The GPU nightly’s Claude Code acceptance test sets it against the pinned Claude Code 2.1.278 and asserts that the client auto-compacts below the server window. Don’t use CLAUDE_CODE_AUTO_COMPACT_WINDOW for a window below 100,000 tokens: it accepts 100,000 to 1,000,000, and a smaller value draws a startup warning and is treated as 100k. CLAUDE_CODE_MAX_CONTEXT_TOKENS works at every size. If a long session still nears the limit, run /compact. Qwen3-8B is natively 32,768 tokens, and a larger window needs --rope-scaling on vllm serve.

Praxis and vLLM do not implement Anthropic’s server-side auto-mode classifier protocol. CLAUDE_CODE_AUTO_MODE_SERVER=0 makes Claude Code send the classifier model requests through Praxis itself. It affects only the auto permission mode, and the classifier still consumes model inference; it is not an on-device check. Do not set it to 1 here. See Anthropic’s auto-mode classifier documentation.

Using a Claude Code settings file

The same variables can go in the env block of a claude --settings file. That block overrides shell exports in sessions that load the file, so use one source per session. Keep the window in env as CLAUDE_CODE_MAX_CONTEXT_TOKENS, not in modelSettings.<model>.autoCompactWindow: the settings key is capped at the window Claude Code already assumes, so it cannot raise it for an unrecognized model name.

5. Connect OpenCode

OpenCode 1.x and 2.x ship as different npm packages (opencode-ai for 1.x, @opencode/cli for 2.x) with different configuration schemas, so a 1.x configuration does not carry over. Check with opencode --version: 1.x prints a bare version such as 1.19.6, and 2.x prints opencode v2.1.2.

Both use the native Claude configuration from section 2, which forwards /v1/chat/completions to vLLM and authenticates clients with Basic auth (username gateway, password GATEWAY_AUTH_PASSWORD). The Praxis side is the same for both majors.

OpenCode 1.x

These steps are verified against OpenCode 1.19.3.

Add this to ~/.config/opencode/opencode.jsonc, merging the provider entries with any existing settings:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "praxis": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Praxis",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1",
        "headers": {
          "Authorization": "{env:PRAXIS_GATEWAY_AUTH}"
        }
      },
      "models": {
        "qwen3-8b": {
          "name": "Qwen3 8B",
          "limit": { "context": 32768, "output": 8192 }
        }
      }
    }
  }
}

Replace qwen3-8b with the served name in VLLM_MODEL and match the limits to your vLLM server. For a remote gateway, set baseURL to its HTTPS address, keeping the /v1 suffix; HTTP is for a loopback gateway only.

OpenCode substitutes {env:VAR} at load time, so the credential stays out of the file. Export it from the shell where you set GATEWAY_AUTH_PASSWORD in section 2 (it must match the Praxis process); OpenCode does not need VLLM_API_KEY:

export PRAXIS_GATEWAY_AUTH="Basic $(printf 'gateway:%s' "$GATEWAY_AUTH_PASSWORD" | base64)"
opencode --model "praxis/$VLLM_MODEL"

If PRAXIS_GATEWAY_AUTH is unset, OpenCode sends an empty Authorization header and the gateway answers a bare 401.

To keep background traffic such as session titles on the backend, set "small_model": "praxis/qwen3-8b" beside the provider. Otherwise it may resolve to a model the backend does not serve and fail with a 404.

Restart OpenCode after changing its configuration. /models also selects the configured model.

Why options.headers, and not apiKey

options.apiKey is sent as Authorization: Bearer, which the gateway’s basic_auth (an RFC 7617 Basic parser) rejects with 401. headers is the only option that puts an arbitrary Authorization header on every request.

The published https://opencode.ai/config.json schema does not declare headers under provider.<id>.options. It names only apiKey, baseURL, enterpriseUrl, setCacheKey, timeout, headerTimeout, and chunkTimeout. The key works because OpenCode passes the whole options record to the @ai-sdk/openai-compatible factory, which accepts headers. This was verified in source and live against OpenCode 1.19.3 (the version the integration tests pin) and earlier against 1.18.35, but it is runtime behavior, not a documented contract. If a release starts validating provider options against the schema, fall back to the per-model form below.

The header also follows baseURL wherever configuration sends it. OpenCode deep-merges global configuration ahead of the project’s, so a project that overrides only provider.praxis.options.baseURL inherits the global options.headers.Authorization and sends the gateway credential to its chosen host. Plain options.headers cannot check the destination. If you open projects you do not fully trust, put the praxis provider in each trusted project’s own opencode.jsonc instead of the global file, and do not export PRAXIS_GATEWAY_AUTH in the shell that launches OpenCode there: {env:...} substitution also runs for project configuration. The per-model form below has the same exposure.

Headless invocation

opencode run drives a single non-interactive turn for CI and scripts:

opencode run --model "praxis/$VLLM_MODEL" --format json -- "Summarize README.md" < /dev/null

The prompt is a positional argument. On run, -p/--password is the OpenCode server Basic-auth password, so the claude -p "..." habit silently passes your prompt as a password. Use -- to separate the prompt from the flags.

--format json emits one JSON event per line. A successful turn emits step_start, one or more text events (assistant text at part.text), then step_finish. A failed turn emits an error event with statusCode and the resolved request URL. --print-logs and --log-level DEBUG are global flags, not run flags; they send diagnostics to stderr and show which baseURL the provider resolved.

Redirect stdin from /dev/null. With stdin open, opencode run blocks after logging init, before sending any request, even with the prompt given as an argument. In CI that looks like a hang with no output and no network activity.

Alternative: per-model headers

A per-model headers map is part of the published schema, so the gateway credential can be attached declaratively:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "praxis": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Praxis",
      "options": { "baseURL": "http://127.0.0.1:8080/v1" },
      "models": {
        "qwen3-8b": {
          "name": "Qwen3 8B",
          "limit": { "context": 32768, "output": 8192 },
          "headers": { "Authorization": "Basic <base64 of gateway:password>" }
        }
      }
    }
  }
}

The model object rejects unknown keys, so a misspelling fails at startup. The base64 credential is written into the file, with no environment lookup. Use this form for CI and short-lived credentials, not in a developer’s ~/.config.

OpenCode 2.x

These steps are verified against OpenCode 2.1.2. For the upstream changes, see the OpenCode V1 migration guide.

Add this to ~/.config/opencode/opencode.jsonc, merging the providers entry with any existing settings. 2.x renames provider to providers and npm to package (with an aisdk: prefix), and moves options.baseURL to settings.baseURL:

{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "praxis": {
      "package": "aisdk:@ai-sdk/openai-compatible",
      "name": "Praxis",
      "settings": { "baseURL": "http://127.0.0.1:8080/v1" },
      "models": {
        "qwen3-8b": {
          "name": "Qwen3 8B",
          "limit": { "context": 32768, "output": 8192 }
        }
      }
    }
  }
}

Replace qwen3-8b with the served name in VLLM_MODEL and match the limits to your vLLM server. For a remote gateway, set baseURL to its HTTPS address, keeping the /v1 suffix, and export the same URL so the plugin can verify the destination (the local http://127.0.0.1:8080/v1 needs no export):

export PRAXIS_BASE_URL="https://gateway.example.com/v1"

2.x ignores unknown configuration keys. 1.x rejected a misspelled key at startup; 2.1.2 ignores it silently, so setting instead of settings drops the baseURL. Copy the keys exactly.

Create ~/.config/opencode/plugins/praxis-auth.ts. OpenCode 2.x loads every plugin in that directory, so the configuration needs no plugins entry:

import { Plugin } from "@opencode/plugin"

export default Plugin.define({
  id: "praxis-auth",
  async setup(ctx) {
    await ctx.session.hook(
      "model.request",
      (event) => {
        const trustedURL = process.env.PRAXIS_BASE_URL ?? "http://127.0.0.1:8080/v1"
        if (event.baseURL !== trustedURL) {
          throw new Error("Praxis baseURL does not match the trusted gateway")
        }
        const password = process.env.GATEWAY_AUTH_PASSWORD
        if (!password) throw new Error("GATEWAY_AUTH_PASSWORD is required for Praxis")
        const token = Buffer.from(`gateway:${password}`).toString("base64")
        event.headers.Authorization = `Basic ${token}`
      },
      { providerID: "praxis" },
    )
  },
})

Before every model request to the praxis provider, the plugin checks the resolved baseURL against PRAXIS_BASE_URL, which must match exactly, including any trailing slash, and should name only a gateway you trust. It then attaches Basic auth with username gateway.

A plugin that fails to load fails open. Verified against OpenCode 2.1.2:

  • If the hook throws (a baseURL mismatch or an unset GATEWAY_AUTH_PASSWORD), OpenCode does not send the request. It emits an error event with the plugin’s message and exits 1. 1.x sent the turn without credentials instead.
  • If the plugin fails to load (a syntax error, a 1.x-style plugin, or a plugins entry that points at a file rather than a directory), OpenCode logs failed to load plugin at WARN and continues, sending every turn with no Authorization header and exiting 0. The message appears only with --print-logs.
  • If the plugin’s providerID does not match the provider, the hook never runs and nothing is logged.

A real Praxis gateway rejects an unauthenticated turn with 401, so a sudden 401 can mean the plugin failed to load.

Launch OpenCode from the shell where you set GATEWAY_AUTH_PASSWORD in section 2. OpenCode does not need VLLM_API_KEY:

opencode --model "praxis/$VLLM_MODEL"

Headless invocation (2.x)

opencode run --standalone --model "praxis/$VLLM_MODEL" --format json "Summarize README.md" < /dev/null

The 2.x command line differs from 1.x in ways that fail quietly:

  • Pass --standalone in scripts. Without it, opencode run connects to a shared background server (opencode serve --service), starting one if needed, and that server outlives run. --standalone runs a private server that exits with the command.
  • Do not put -- before the prompt. In 2.1.2, opencode run -- "hello" sends hello hello. Pass the prompt last with no separator.
  • -p is not a run flag in 2.x; opencode run -p "..." prints help and exits 1.
  • There is no --pure flag. To run without the plugin, remove it from ~/.config/opencode/plugins/.
  • Redirect stdin from /dev/null, as in 1.x.

--format json emits one JSON event per line. A plain text turn emits only text events (assistant text at part.text). A tool-calling turn emits step_start, tool_use, step_finish, then text. A failed turn emits an error event with error.type and error.message; a gateway 401 shows as error.type provider.auth with error.status 401. Plugin load failures are logged at WARN, so use --print-logs --log-level warn; ERROR hides them.

2.x renames built-in tools: bash is now shell and task is now subagent. Use the new names when a prompt asks for a tool by name.

Alternative: provider headers without a plugin (2.x)

2.x accepts a provider-level headers map with {env:NAME} substitution, so the credential can stay out of the file without a plugin:

{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "praxis": {
      "package": "aisdk:@ai-sdk/openai-compatible",
      "name": "Praxis",
      "settings": { "baseURL": "http://127.0.0.1:8080/v1" },
      "headers": { "Authorization": "Basic {env:PRAXIS_GATEWAY_BASIC_TOKEN}" },
      "models": {
        "qwen3-8b": {
          "name": "Qwen3 8B",
          "limit": { "context": 32768, "output": 8192 }
        }
      }
    }
  }
}

Export the Basic token, the base64 encoding of gateway:<password>:

export PRAXIS_GATEWAY_BASIC_TOKEN="$(printf 'gateway:%s' "$GATEWAY_AUTH_PASSWORD" | base64)"

If the variable is unset, OpenCode substitutes an empty string and the gateway answers 401. Do not install the plugin alongside this configuration.

For interactive use, prefer the plugin: it refuses to send anything when a project config points baseURL at another host, while the headers map sends the token wherever baseURL points.

6. Connect pi

These steps are verified against pi 1.5.2. Install that version from the upstream release, or with npm install -g @earendil-works/pi-coding-agent@1.5.2 (Node 22.19 or later), and check it with pi --version.

pi reaches custom endpoints through providers in ~/.pi/agent/models.json. Use its openai-completions wire API, which sends Chat Completions to the same /v1/chat/completions route OpenCode uses. The native Claude configuration from section 2 handles it as is: no translation, Basic auth for the client, and VLLM_API_KEY injected toward vLLM.

Create ~/.pi/agent/models.json, or merge the praxis provider into yours:

{
  "$schema": "https://pi.dev/schemas/models.schema.json",
  "providers": {
    "praxis": {
      "name": "Praxis",
      "baseUrl": "http://127.0.0.1:8080/v1",
      "api": "openai-completions",
      "apiKey": "local-pi-client-key",
      "headers": { "Authorization": "Basic ${PRAXIS_GATEWAY_BASIC_TOKEN}" },
      "models": [
        { "id": "qwen3-8b", "name": "Qwen3 8B", "contextWindow": 32768, "maxTokens": 8192 }
      ]
    }
  }
}

Replace qwen3-8b with the served name in VLLM_MODEL and match contextWindow and maxTokens to your vLLM server.

The Authorization header carries the gateway credential. Export the Basic token it reads, the base64 encoding of gateway:<password>:

export PRAXIS_GATEWAY_BASIC_TOKEN="$(printf 'gateway:%s' "$GATEWAY_AUTH_PASSWORD" | base64)"

Then launch pi from that shell. pi does not need VLLM_API_KEY:

pi --model "praxis/$VLLM_MODEL"

Notes on this configuration, verified against pi 1.5.2:

  • apiKey is a placeholder, but it must be set. Without it, pi reports No API key found for praxis. and sends nothing. The configured Authorization header replaces the Bearer key pi would send, so the placeholder never leaves the client.
  • A missing token fails closed. ${PRAXIS_GATEWAY_BASIC_TOKEN} resolves at request time. If it is unset, pi sends nothing and reports Failed to resolve provider "praxis" header "Authorization" from environment variable: PRAXIS_GATEWAY_BASIC_TOKEN. A header value can also start with !command to read the token from a secret manager.
  • vLLM needs no compat or reasoning settings. With reasoning at its default of false, pi sends no reasoning or thinking fields, and the server flags from section 1 keep Qwen3 thinking off. Do not set thinkingTokenBudgetField here.
  • The token goes wherever baseUrl points. Unlike the OpenCode plugins, pi has no destination check, so keep models.json pointed at your gateway.

Headless invocation

pi --print drives a single non-interactive turn for CI and scripts:

pi --print --mode json --offline --no-session --model "praxis/$VLLM_MODEL" -- "Summarize README.md" < /dev/null
  • Redirect stdin from /dev/null. With stdin open, pi --print waits for end of input and sends nothing. Piped input is prepended to the prompt.
  • In --mode json, a failed turn still exits 0. A gateway 401 or an unresolved header appears only as stopReason: "error" with an errorMessage on the final assistant message_end event. --mode text exits 1 for the same failures, so JSON-mode scripts must check the stop reason, not the exit status.
  • pi needs no egress beyond Praxis and completes in a loopback-only network namespace. --offline turns off its startup network operations anyway.
  • pi’s four tools (read, bash, edit, write) run without a permission prompt, including in --print mode. Run it in a workspace you are willing to let the model change.

Cleanup

Stop local Praxis and cancel the on-demand endpoint workflow:

kill "$PRAXIS_PID"

Troubleshooting

  • 401 from Praxis on the Claude, OpenCode, or pi path: check the Basic Authorization header and that the client’s GATEWAY_AUTH_PASSWORD matches the gateway’s.
  • 401 from vLLM: VLLM_API_KEY does not match the key passed to vLLM.
  • 401 from vLLM on the Codex listener of the all-in-one gateway only: the prefixed basic_auth stripped the client credential and nothing replaced it. Add the credential_injection from section 2 inside the IRR inference step, after its router and before its load_balancer.
  • 401 from Praxis on a Codex path gated by basic_auth: env_key is probably still set alongside env_http_headers, so the request carries two Authorization headers. Remove env_key. A stale logged-in CODEX_HOME does the same; use the mktemp -d home from section 3.
  • Codex gets 401 while a plain curl from the same shell succeeds: the app-server daemon is stale. See The Codex app-server daemon outlives your shell.
  • OpenCode gets a bare 401 on every turn: PRAXIS_GATEWAY_AUTH was not exported in the shell that launched OpenCode, so {env:PRAXIS_GATEWAY_AUTH} became an empty Authorization header. Export it and restart OpenCode; --print-logs --log-level DEBUG shows the baseURL and headers the provider resolved.
  • OpenCode reaches api.openai.com instead of Praxis, or asks for OPENAI_API_KEY: the provider options were not applied, which upstream has reported for the bundled adapter and for sub-sessions. Confirm the resolved baseURL with --print-logs --log-level DEBUG and pin a known-good version.
  • opencode run or pi --print hangs and nothing reaches Praxis: stdin is still open. Redirect it from /dev/null. Neither client needs egress beyond Praxis.
  • OpenCode 2.x sends no Authorization header and exits 0: the plugin did not load. Re-run with --print-logs --log-level warn and look for failed to load plugin. Common causes are a 1.x-style plugin, a syntax error, or a plugins entry pointing at a file; leave the plugin in ~/.config/opencode/plugins/ with no plugins entry.
  • OpenCode 2.x exits 1 with Praxis baseURL does not match the trusted gateway or GATEWAY_AUTH_PASSWORD is required for Praxis: the plugin’s guard refused the request. Fix PRAXIS_BASE_URL or export the password.
  • OpenCode 2.x processes keep running after opencode run exits: the run started the shared background server. Pass --standalone, or stop it with opencode service stop.
  • pi reports No API key found for praxis.: set the placeholder apiKey from section 6 in ~/.pi/agent/models.json.
  • pi reports Failed to resolve provider "praxis" header "Authorization": export PRAXIS_GATEWAY_BASIC_TOKEN in the shell that launches pi.
  • Model not found: use the exact slash-free served name, normally qwen3-8b.
  • 400 with request body is not JSON on a bodyless request such as GET /v1/models, logged as request body rejected by filter filter="openai_responses_format": a config from an older copy runs the Responses body classifier on every request, and on_invalid: reject turns an empty body into a 400 before routing. Drop the leading openai_responses_format and let the head-driven openai_responses_request carry its on_invalid and headers, as both Codex examples in section 2 do; it releases unrecognized operations without reading a body. Do not use on_invalid: continue instead: it also forwards malformed Responses bodies to vLLM.
  • RFC 9457 application/problem+json where an OpenAI client expects {"error": {...}}: the chain is missing ai_operation. The body classifiers each install a formatter for one protocol (openai_responses_request for Responses, anthropic_messages_request for Anthropic Messages), so Chat Completions traffic reaches core’s error path with none. ai_operation classifies from the request head and installs the matching formatter for every OpenAI and Anthropic protocol; put it right after basic_auth, as the Codex examples and the native Claude Code and OpenCode example do. OpenCode is hit hardest, because its /v1/chat/completions traffic shares a listener with another protocol.
  • 400 with maximum context length is 32768 tokens: the prompt itself exceeds the window, or max_tokens alone exceeds --max-model-len; otherwise vLLM clamps the output budget. If it happens on the first turn with an input count near 28,000, Claude Code’s startup prompt (MCP tool definitions, plugin skills, and CLAUDE.md) fills most of the window. Run /context for the breakdown; it is local and works while requests fail. Start Claude Code with --strict-mcp-config to drop globally configured MCP servers, disable unneeded plugins with /plugin, and prefer a working directory with a small or no CLAUDE.md.
  • Claude Code never finishes a turn (plan mode loops, or reasoning text shows up in the answer or plan): the server is probably emitting thinking the client should not see. Serve Qwen3 with --reasoning-parser qwen3 and --default-chat-template-kwargs '{"enable_thinking":false}' as in section 1 and restart vLLM; nothing on the Praxis or client side changes this. On the on-demand endpoint, check the run’s reasoning_parser and enable_thinking inputs.
  • Auto mode fails with Error: You are not in plan mode. To enter plan mode, call the EnterPlanMode tool first.: this is a symptom, either a plain Claude Code plan-state failure or reasoning text desynchronizing the agentic loop. Check for reasoning text before applying the Qwen3 settings above.
  • TLS or connection failure: put only the tunnel hostname in endpoints and tls.sni, without https://.
  • Connection refused on 8080 from another machine while vLLM on 8000 answers: every example in section 2 binds 127.0.0.1:8080, under --network host too. Change it to address: "0.0.0.0:8080" and open 8080 on the host firewall. A loopback-only listener refuses immediately; a blocked port usually hangs or reports no route. Keep the authentication filter and terminate TLS in front, since the Basic password is otherwise readable on the wire. A second listener, such as the Codex one in the all-in-one gateway, needs the same edit plus -p 8081:8081 on the published-port container path.
  • Claude startup probes may call /v1/messages/count_tokens. Native vLLM supports it; the translated Chat path can return 404, and Claude degrades gracefully.

Pinned client versions

The integration tests pin one version of each client and one vLLM build. Each client’s tests/integration/fixtures/*/pin.toml manifest is its source of truth. The [vllm] block of the Claude Code, OpenCode 1.x, and Codex manifests pins the vLLM backend in two layers:

  • base_image is the upstream vllm/vllm-openai image, by digest, that vllm/Containerfile builds from, so it fixes the vLLM build every GPU lane runs. To reproduce a lane’s server, run that image with the manifest’s [vllm.launch] flags as in Existing or local vLLM, passing --model Qwen/Qwen3-8B in place of the in-image path.
  • baked_image names the vllm/images.json entry the GPU lanes serve by default. That entry owns the model and its Hugging Face revision, and its weights are in the image, so lanes start without downloading weights or a Hugging Face token. Its published tag is mutable, so each lane records the image it served (local image ID, plus registry digest when pulled) in the qualification report, not the manifest.

A Codex candidate dispatch loads the requested checkpoint with the pinned upstream image. See Qualifying a Codex candidate checkpoint.

cargo xtask check-pins (part of make lint) fails if any harness constant, workflow, checksum fixture, or image reference disagrees with the manifests, or if a launch would load anything other than the baked weights.

To move every pin to its latest upstream release within each manifest’s major_series:

cargo xtask bump-pins --dry-run   # report available bumps, write nothing
cargo xtask bump-pins             # or: --pin opencode --pin vllm ...

It rewrites every mechanical site, swaps the checksum fixtures, and validates the result before writing. It also updates claims an acceptance lane re-proves on every pull request: the pi “verified against” lines in this guide, and the Codex WebSocket recording, whose wire shapes it carries forward with metadata naming their source version. Those lanes must pass before the bump can merge. It never changes other behavioral pins (tool lists, exit-code semantics, version-conditioned test expectations, claims no lane exercises); its report lists them as a re-validation checklist, with every line that still names the old version. The weekly Bump Pins workflow runs it and opens a draft pull request with that checklist, gated by the GPU acceptance lanes (vllm-full-suite label) before review.