@anyforge/control
v0.2.3
Published
AnyForge Control CLI — governed LLM proxy for Claude Code, Cursor, Cline, and any agent that talks to OpenAI- or Anthropic-shape APIs.
Readme
@anyforge/control
Governed LLM proxy for any agent. Use the AI tools you already use — Claude Code, Cursor, Cline, Continue, or your own SDK — and route every call through AnyForge for cost analytics, audit log, and policy enforcement.
Install
npx @anyforge/control initThe CLI:
- Issues a one-time auth code, opens your browser to authorise it.
- Stores the resulting API key at
~/.anyforge/credentials(chmod 600). - Asks whether to install globally (
~/.claude/settings.json) or per-repo (the per-repo option only appears when you run the command at the root of a git working tree). - Patches the chosen target so Claude Code routes through
https://crew.anyforge.ai/v1/anthropicand…/v1/openai. The actual API key is inlined into the patched config — no${ANYFORGE_API_KEY}indirection, no shell restart required.
After that, your next LLM call shows up under Control on /usage within seconds.
Install scope
| Choice | Files written | Effect |
|---|---|---|
| global | ~/.claude/settings.json (+ optional shell-rc hints for Cursor / Cline if installed) | Every Claude Code session on this machine routes through AnyForge |
| repo | <repo>/.claude/settings.local.json and <repo>/.env | Only Claude Code sessions inside this repo are routed; no global side effects |
Pick whichever suits the moment — the choices aren't mutually exclusive over time:
- Want to add a second repo? Re-run
npx @anyforge/control initfrom that repo's root and pickrepoagain. - Want to switch to a system-wide install later? Re-run from anywhere and pick
global. - Want to undo a per-repo install? Delete the
# === AnyForge Control ===block in<repo>/.envand theenvkeys in<repo>/.claude/settings.local.json.anyforge logoutclears the saved credential but doesn't touch patched configs.
The
.envwritten in per-repo mode contains a liveANYFORGE_API_KEY. The CLI warns if your repo's.gitignoredoesn't already exclude.env. Add it before committing.
Why ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY?
Claude Code recognises both, but they behave differently. ANTHROPIC_API_KEY is sent as X-Api-Key and — when an OAuth Console login is also present — surfaces an "Auth conflict: Using ANTHROPIC_API_KEY instead of Anthropic Console key" warning, and can cascade into a "selected model may not exist" error. ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer …, is documented for "routing through an LLM gateway or proxy", out-ranks the OAuth login cleanly, and matches the bearer-token shape AnyForge expects. We patch the token form, and on every install we explicitly delete any stale ANTHROPIC_API_KEY left behind by older versions.
Commands
| | |
|---|---|
| anyforge init | Authorise this device and patch local agent configs |
| anyforge whoami | Show the company tied to the saved key |
| anyforge status | Verify the proxy is reachable and your BYOK key is configured |
| anyforge logout | Clear the local credential file (does not revoke server-side) |
Endpoints
The CLI defaults to https://crew.anyforge.ai. Override per-invocation with --endpoint, or globally with the ANYFORGE_ENDPOINT environment variable.
The proxy exposes:
POST /v1/anthropic/messages— drop-in forhttps://api.anthropic.com/v1/messages. UseAuthorization: Bearer sk_anyforge_…instead ofx-api-key.POST /v1/openai/chat/completions— drop-in forhttps://api.openai.com/v1/chat/completions.
Both validate your AnyForge API key, look up your company's BYOK provider key, forward the request, and stream the response back unchanged. Token counts and cost are logged to your usage dashboard.
What you get
- Cost analytics — per-call, per-company, per-model spend on
/usage. - Audit log — hash-chained record of every prompt + response.
- BYOK — your provider keys live in your AnyForge company; the CLI never holds raw provider keys on the local machine.
- One key, every agent — the same
sk_anyforge_…works for any agent that talks OpenAI- or Anthropic-shape APIs.
Coming soon
anyforge proxy— local proxy mode for OPA-enforced redaction before requests leave your network.- Intent-based routing (rules / regex / embeddings).
- Portable memory injection.
- Ollama support for local models.
License
Apache-2.0
