No description
  • Go 97.1%
  • Dockerfile 2.7%
  • Just 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Claudia 2d1542ead8
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
refactor: move to the meatbag org
It is infrastructure for this house rather than part of the vlv suite, so it builds and deploys the way caddy and elodie do.
2026-11-02 12:42:05 +01:00
internal refactor: move to the meatbag org 2026-11-02 12:42:05 +01:00
.gitignore feat: load a routing table that cannot mix local and remote 2026-11-02 12:37:25 +01:00
.woodpecker.yaml refactor: move to the meatbag org 2026-11-02 12:42:05 +01:00
config.example.yaml build: package the service for the registry 2026-11-02 12:37:25 +01:00
Containerfile build: package the service for the registry 2026-11-02 12:37:25 +01:00
go.mod refactor: move to the meatbag org 2026-11-02 12:42:05 +01:00
go.sum feat: load a routing table that cannot mix local and remote 2026-11-02 12:37:25 +01:00
justfile refactor: move to the meatbag org 2026-11-02 12:42:05 +01:00
main.go refactor: move to the meatbag org 2026-11-02 12:42:05 +01:00
README.md build: package the service for the registry 2026-11-02 12:37:25 +01:00

switchboard

The one address the house's services ask language models through. It speaks OpenAI's /v1/chat/completions and decides who actually answers, so swapping a provider is a change to one routing table and none to the services.

What a caller asks for

model What happens
anthropic/claude-haiku-5-5 That model and no other. If it is unavailable, the caller gets a 503
remote-fast (a pool) Members in order, swapping when one is unavailable
local, local/<model> Local only. If it is down, a 503 and the caller retries later
Anything else 404. There is no default route

The response's model is always the one that really answered, and usage.cost is what it cost. Anything citing a model must read model and not assume.

Asking for a local model never reaches a remote one. The config refuses to load a pool mixing the two, or a local upstream whose host is not on this network, so there is no failover path for a request to take. Which also means each remote pool's member list is a statement of which companies may see that prompt.

Exact model ids are for anything that has to be able to rely on the model, and pools are for anything that does not.

When a pool swaps

The upstream says What happens
429, 503, 529 Next member. This model rests for its Retry-After, or 30s
Timeout, connection failure, other 5xx Next member. This upstream rests 30s
Monthly cap reached, or out of credit Next member. This upstream rests until the month turns
401, 403 Next member, logged. This upstream rests 5 minutes
404 Next member, logged. This model rests 5 minutes
400 and other 4xx No swap. The caller gets the error, since the request is probably at fault
A refusal No swap. A refusal is an answer, and is not shopped around

A pool goes back to its first member as soon as that member's rest is over. A request nobody could answer is always a 503 with a Retry-After, whatever the last upstream said. Rests are in memory, so a restart clears them, and the monthly spend is on disk, so a restart does not.

Providers

openrouter, openai and local take the request as it came, reshaped a little for each one's vocabulary. anthropic is translated to the native Messages API, and refuses what it cannot carry (tools, images, temperature, mid-conversation system messages) rather than dropping it. Streaming is refused everywhere: a stream cannot fail over once started, and would arrive uncounted.

Running it

switchboard -config config.yaml -db ledger.db -addr :8080
SWITCHBOARD_TOKENS=spis-resolver-llm=…,other=…     who may ask
ANTHROPIC_API_KEY=…                                whatever key_env names

It refuses to start on a missing credential or a bad routing table. See config.example.yaml. GET /status shows each upstream's spend, cap and rest, and needs a caller's token. GET /healthz does not.

Each request logs who asked, what answered, the tokens and the cost. Never the prompt: these are food logs. Lines starting switchboard: are the ones worth an alert.