Disclaimer: All code in this repository is LLM-generated. See LLMs.
Alpha: this is an architecture spike, not a production-ready service. See INTERNALS.md for architecture, security, operations, and development details.
A credential broker built on Praxis AI.
One listener serves the ChatGPT Codex Responses API, authenticated through
codex login, under /v1, the Anthropic Messages API under
/anthropic/v1, and Mistral's chat completions under /mistral/v1. Every
route has a credential mode:
- injected: the broker supplies its own credential (the Codex login, a Claude subscription token, or a Mistral API key), and only for requests that carry the token of a registered CI run. This is how agent runs use the broker: they never see a real credential, and each run is capped.
- pass-through: the caller's own Claude credential is forwarded to Anthropic, never stored, and only metered. This is for interactive Claude Code on your own subscription.
Every request that reaches a provider is metered.
Requires Podman, curl, and this repository's scripts. The default images are:
ghcr.io/cgwalters-bot/praxis-credential-broker-proxy:main
ghcr.io/cgwalters-bot/praxis-credential-broker-provider-codex:main
ghcr.io/cgwalters-bot/praxis-credential-broker-gateway:main
The gateway image is Praxis AI, built from source with this repository's filters, and with its routes built in.
Create the internal channel secret, store the Claude subscription token the
broker injects (from claude setup-token on a trusted machine; the script
reads it from the terminal without echo, or from standard input), complete
the Codex device login, and start the pod:
bash scripts/init-secrets
bash scripts/init-anthropic-token
# or: password-manager read claude/oauth-token | bash scripts/init-anthropic-token
bash scripts/native-pod.sh login
export PRAXIS_RUN_TOKEN_POLICY=$HOME/run-token-policy.yaml # see below
bash scripts/native-pod.sh up
bash scripts/native-pod.sh health
# later
bash scripts/native-pod.sh downdown preserves the secrets and Codex login for a later restart. GHCR access
policies may require podman login ghcr.io.
The Mistral route needs a key of its own, which a deployment may leave out:
bash scripts/init-mistral-key before up stores it, read like the Claude
token. Without it the broker starts all the same, and Mistral refuses what
/mistral forwards.
Which CI jobs may register runs, and so use the broker's credentials, is a
policy file: copy run-token-policy.yaml, name the workflows and the
repository ids that may register, and point PRAXIS_RUN_TOKEN_POLICY at the
copy. Without it no run can register, and only pass-through requests are
served.
To use a full-commit-SHA tag or a compatible private mirror, override the
images before login and up:
export PRAXIS_PROXY_IMAGE=ghcr.io/cgwalters-bot/praxis-credential-broker-proxy:<commit-sha>
export PRAXIS_PROVIDER_CODEX_IMAGE=ghcr.io/cgwalters-bot/praxis-credential-broker-provider-codex:<commit-sha>
export PRAXIS_GATEWAY_IMAGE=ghcr.io/cgwalters-bot/praxis-credential-broker-gateway:<commit-sha>
bash scripts/native-pod.sh login
bash scripts/native-pod.sh upjust is for build and development conveniences only. Build local images and
explicitly select them for the runtime scripts:
just build
export PRAXIS_PROXY_IMAGE=localhost/praxis-credential-proxy:dev
export PRAXIS_PROVIDER_CODEX_IMAGE=localhost/praxis-provider-codex:dev
export PRAXIS_GATEWAY_IMAGE=localhost/praxis-gateway:dev
bash scripts/native-pod.sh login
bash scripts/native-pod.sh upUse the same secret setup above before starting local images.
Praxis listens on 127.0.0.1:18080. A CI job's supervisor registers its run
with the job's GitHub Actions OIDC token, for the audience
praxis-credential-broker, and hands only the returned run token to the
agent:
curl -X POST -H "Authorization: Bearer $OIDC_TOKEN" http://127.0.0.1:18080/v1/runs
# 201 {"token": "praxis-run-...", "usage": {...}}The agent's sandbox must not get the job's ACTIONS_ID_TOKEN_REQUEST_*
variables; see INTERNALS.md. When the job ends,
DELETE /v1/runs/self with the run token finishes the run and returns its
usage record.
Codex sends the run token as its API key, from a provider definition in
~/.codex/config.toml:
[model_providers.praxis]
name = "Local Praxis"
base_url = "http://127.0.0.1:18080/v1"
wire_api = "responses"
env_key = "PRAXIS_RUN_TOKEN"and a named profile in ~/.codex/praxis.config.toml:
model_provider = "praxis"OpenCode takes it as its apiKey:
{
"provider": {
"praxis": {
"npm": "@ai-sdk/openai",
"options": {
"baseURL": "http://127.0.0.1:18080/v1",
"apiKey": "{env:PRAXIS_RUN_TOKEN}"
},
"models": {
"gpt-6-astra": {
"name": "gpt-6-astra"
}
}
}
}
}codex --profile praxis
opencode run --model praxis/gpt-6-astraClaude Code sends a fixed placeholder as its credential, which selects the
broker's Claude token, and the run token in a header of its own. It appends
/v1/messages to the base URL:
export ANTHROPIC_BASE_URL=http://127.0.0.1:18080/anthropic
export ANTHROPIC_AUTH_TOKEN=praxis-substitute:anthropic
export ANTHROPIC_CUSTOM_HEADERS="x-run-token: $PRAXIS_RUN_TOKEN"
unset ANTHROPIC_API_KEY CLAUDE_CODE_OAUTH_TOKEN
claudeA request with the placeholder but without a valid run token is refused with 401. Each run is capped (20M tokens per API by default), and a request over its run's cap gets 429. Injecting a subscription token at a gateway is undocumented by Anthropic; read the risks in INTERNALS.md first.
Mistral's chat completions are at /mistral/v1/chat/completions, and
nothing else of Mistral's API is. A client sends the run token as its API
key, as on Responses:
curl http://127.0.0.1:18080/mistral/v1/chat/completions \
-H "Authorization: Bearer $PRAXIS_RUN_TOKEN" -H 'Content-Type: application/json' \
-d '{"model": "zai-glm-5-3", "messages": [{"role": "user", "content": "hi"}]}'The broker maps no model names, here or on the other routes: model goes
upstream as the client wrote it, and a client's own name for a model, such
as OpenCode's praxis/gpt-6-astra, is its provider entry and the upstream
name. A provider entry has one base URL, so Mistral's models get an entry
of their own, such as praxis-mistral, and are then
praxis-mistral/zai-glm-5-3 (GLM-5.3 as Mistral hosts it) and
praxis-mistral/mistral-vibe-cli-latest (Mistral Medium 3.5), the names
Mistral Vibe itself uses upstream. For Mistral Vibe, in the
config.toml of its VIBE_HOME:
active_model = "glm-5-3"
[[providers]]
name = "praxis"
api_base = "http://127.0.0.1:18080/mistral/v1"
api_key_env_var = "PRAXIS_RUN_TOKEN"
backend = "mistral"
[[models]]
name = "zai-glm-5-3"
provider = "praxis"
alias = "glm-5-3"Neither client has been run against the route yet; what has is in INTERNALS.md.
The policy's workflows names each workflow that may register, in its own
repository and at one ref. Two entries, off unless the policy file has
them, admit more: any_workflow every workflow of the repositories or
owners it lists (or of all of GitHub), and called_workflows a named
workflow wherever it runs, which is what a reusable workflow called from
another repository needs.
any_workflow:
repositories:
owner_ids: [333055778] # every repository of this owner
called_workflows:
- workflow: OWNER/REPO/.github/workflows/FILE.yml
ref: refs/heads/main # or sha: the commit callers pin
callers:
repository_ids: [1372023819]The token is still verified in full and the job still proves it is a job, so its agent, which holds no identity token, cannot register a run of its own by asking. The run has the same caps and usage record, which says which entry admitted it. Either entry widens who can spend the broker's credentials to whoever can push a workflow to an admitted repository, which includes an agent that holds a GitHub credential able to. Read INTERNALS.md first: it says which claims each form checks, and has the exact text for this deployment.
A job with no GitHub Actions identity to show, or a deployment that trusts
its private network, can have runs register on their word alone. This is
off unless the policy file has unproven:
unproven:
max_registrations: 8 # in any hour, from all callers togetherThen a request with no Authorization registers the run it names (letters,
digits, ., _ and -, at most 128), and gets a run token with the same
caps, lifetime and usage record as any other:
curl -X POST -H "x-run-id: $RUN_NAME" http://127.0.0.1:18080/v1/runs
# 201 {"token": "praxis-run-...", "usage": {"proof": "none", "run": "...", ...}}Whatever can reach the port can then spend the broker's credentials, the agent of a job included, which can register a run of its own for a fresh cap. Read INTERNALS.md for what that gives up, the exact steps to turn it on and how to turn it off.
A person's own agent, such as an interactive OpenCode or Codex on a workstation, has no CI job to register a run with. The deployment can name operators instead, each with a long-lived token that is admitted wherever a run token is, for the injected clusters its entry lists:
bash scripts/create-operator-token me inference-backend
# writes ~/.config/praxis-credential-broker/operator-token-me (mode 0600) and
# prints the entry, with only the token's SHA-256, for operator-tokens.yamlPut that entry in your copy of operator-tokens.yaml, point
PRAXIS_OPERATOR_TOKENS at it for native-pod.sh up (under Quadlet, a
drop-in mounts it), and restart the pod. The client sends the token as its API key; OpenCode can read it
from the file, so the token is in no configuration:
"options": {
"baseURL": "http://127.0.0.1:18080/v1",
"apiKey": "{file:~/.config/praxis-credential-broker/operator-token-me}"
}An operator is capped like a run (20M tokens per API in a sliding 6 hours),
and GET /usage counts what it used under operators, by its name. See
INTERNALS.md for what the token can do.
A Claude Code that is logged in itself (claude auth login) can use the
same prefix: any Authorization other than the placeholder is forwarded to
https://api.anthropic.com as it is, and never stored. No run token is
needed, and the broker's token is never added. The broker meters these
requests but does not cap them; your own subscription's limits apply.
export ANTHROPIC_BASE_URL=http://127.0.0.1:18080/anthropic
unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY
claudeFrom another tailnet host, use the broker host's MagicDNS name instead, such
as http://<host>.<tailnet>.ts.net:18080/anthropic, once the pod is published
on the tailnet (see INTERNALS.md). The old
/v1/messages route without the prefix, and the separate listener on port
18083, are gone.
contrib/quadlet/ has rootless Quadlet units for the same pod that run the
published images and mount nothing from a checkout; see
INTERNALS.md.
For operational procedures, security properties, test topology, publishing, and provenance, read INTERNALS.md.