feat(caddy): expose LiteLLM at /llm/* for tailnet API clients#62
Merged
Conversation
…Cursor) Programmatic OpenAI-compatible clients on the tailnet (Cline, Cursor, scripts) had no way to reach the model gateway: it's bound 127.0.0.1-only and Caddy had no route for it (the compose comment claiming "tailnet peers reach this via Caddy" was aspirational — no such route existed, and SSO can't gate a non-interactive API client anyway). - auth/caddy/Caddyfile: add a `/llm/*` bypass handle (no forward_auth) that strips the prefix and reverse-proxies to model-gateway:11435. Auth is LiteLLM's own Bearer master key, which the gateway enforces (401 without it) — safe over the tailnet, which is the only interface Caddy binds. - docker-compose.yml: add model-gateway to proxy-net so Caddy can reach it; correct the previously-stale ports comment to describe the real /llm/* path. Clients use: base URL https://<tailnet-host>/llm/v1 , key = LITELLM_MASTER_KEY, model = local-chat. No new host port, no 0.0.0.0 exposure. Validated live: GET /llm/v1/models with the key returns local-chat/local-embed; without the key returns 401 (LiteLLM), not a 302 SSO redirect. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Programmatic OpenAI-compatible clients on the tailnet (Cline, Cursor, scripts) had no way to reach the model gateway — it's
127.0.0.1-only and Caddy had no route for it (the compose comment claiming "tailnet peers reach this via Caddy" was aspirational). SSO can't gate a non-interactive API client anyway.What
auth/caddy/Caddyfile—/llm/*bypasshandle_path(noforward_auth) →model-gateway:11435, prefix stripped so LiteLLM sees/v1/.... Auth is LiteLLM's own Bearer master key (gateway returns 401 without it). Safe over the tailnet (the only interface Caddy binds).docker-compose.yml— addmodel-gatewaytoproxy-net(Caddy couldn't resolve it otherwise); correct the stale ports comment.Client config
https://<tailnet-host>/llm/v1LITELLM_MASTER_KEYlocal-chatValidation (live)
GET /llm/v1/modelswith the key →local-chat,local-embed.HTTP 401(LiteLLM), not a 302 SSO redirect.🤖 Generated with Claude Code