[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7C9VE0A40GMMGHQ62KC2NE3":3,"skill-same:01M7C9VE0A40GMMGHQ62KC2NE3":53},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":34,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M7C9VE0A40GMMGHQ62KC2NE3","call-llm",null,"Call external language models from crux code through its shared OpenRouter gateway and model configuration.","bionic-coding\u002Fcrux","bionic-coding","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F301040008?v=4","01M7C9T2NA1V1V0EF1M552HRB3","Bionic Coding","01M7C9T2P72H1AQV5T5PTBFNHN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux\u002Fblob\u002Fmain\u002Fcrux\u002Fskills\u002Fcall-llm\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: call-llm\ndescription: \"Call external language models from crux code through its shared OpenRouter gateway and model configuration.\"\nuser-invocable: false\nmetadata:\n  tags: \"llm, multi-model, gateway\"\n  bundles: \"crux-core, crux-docs\"\n  risk_level: \"medium\"\n  requires_access: \"run-plugin-script\"\n  requires_env: \"OPENROUTER_API_KEY\"\n---\n\n# Crux LLM Caller\n\n\u003C!-- BEGIN GENERATED: runtime-compat -->\n## Runtime compatibility\n\nThis skill is portable across Claude Code, Codex, OpenCode, and OMP (Oh My Pi). This section overrides platform-specific labels below.\n\n- Before running a command that uses `CRUX_PLUGIN_ROOT`, set it to the installed plugin root. In Claude Code, use the value of `CLAUDE_PLUGIN_ROOT`. In Codex, OpenCode, and OMP, derive it from the absolute path of this selected `SKILL.md`: the plugin root is the parent of its `skills\u002F` directory (in OMP `bash`, `skill:\u002F\u002F\u003Cname>` resolves to the skill directory). In a source checkout, use the checkout `crux\u002F` directory.\n- For project-local skills, use `.claude\u002Fskills` in Claude Code, `.agents\u002Fskills` in Codex, `.opencode\u002Fskills` in OpenCode (which also reads the singular `.opencode\u002Fskill`), and `.omp\u002Fskills` in OMP. Set `CRUX_LOCAL_SKILLS_DIR` to that path before following any command below that uses it.\n- Translate Claude Code tool labels such as `Agent`, `Read`, `Write`, `Bash`, `WebSearch`, and `WebFetch` to the matching capability in the current session. Codex names its own capabilities; OpenCode uses the lowercase forms `subagent`, `read`, `edit`, `shell`, `websearch`, and `webfetch`, where `edit` covers both `Edit` and `Write`; OMP uses `task`, `read`, `edit`, `write`, `bash`, `grep`, `glob`, `find`, `todo`, and `web_search` (where `read` also handles URLs and `skill:\u002F\u002F` URIs). Do not attempt to invoke the Claude Code labels as literal commands on another host.\n- Install the generated role agents before delegating: `install-codex-agents` in Codex, `install-opencode-agents` in OpenCode, `install-omp-agents` in OMP. Codex names them `crux_architect`, `crux_brainstormer`, `crux_commander`, `crux_dev_lead`, `crux_developer`, `crux_historian`, `crux_librarian`, `crux_night_gardener`, `crux_reviewer`, and `crux_wayfinder`; OpenCode and OMP use the bare role names `architect`, `brainstormer`, `commander`, `dev-lead`, `developer`, `historian`, `librarian`, `night-gardener`, `reviewer`, and `wayfinder` (in OMP, `scout` may also be used for reconnaissance alongside `wayfinder`). If a required role or capability is unavailable, report that truthfully instead of claiming it ran.\n- Argument placeholders such as `$adr` and `$book` bind only in Claude Code. On a host without argument binding they are unset — take the value from the user's phrase. The \"Fields OpenCode ignores\" section of `OPENCODE_GUIDE.md` names the invocation-control fields OpenCode ignores.\n\u003C!-- END GENERATED: runtime-compat -->\n\n## One gateway, one key\n\nEvery model crux calls resolves through **one OpenAI-compatible gateway**, authenticated by **one `OPENROUTER_API_KEY`**. There is no per-provider client, no provider enum, and no provider-specific key. A model is named by a registry key; the registry maps that key to the gateway address the request is sent to.\n\nTwo consequences worth stating, because both are load-bearing:\n\n- **Adding or retiring a model is a registry edit**, not a code change. Nothing in this skill's surface names a vendor.\n- **The one key is a single point of failure by design.** When it is missing or rejected, every call fails at once rather than one provider degrading. The council turns that into a below-quorum deferral rather than a verdict; see `council\u002FSKILL.md`.\n\n## File locations\n\n```\ncrux\u002Fscripts\u002Fcrux\u002Fcore\u002F\n└── llm_caller.py             ← the gateway client\n\ncrux\u002Fscripts\u002Fcrux\u002F_config\u002F\n└── llm_router_config.json    ← the registry: model keys, addresses, params\n\n~\u002F.crux\u002Fenv                   ← OPENROUTER_API_KEY (managed by `crux-env`)\n```\n\n## Exports\n\nRe-exported from `crux.core` as `crux.llm`:\n\n```\nCalling:     call_model, call_gateway, build_gateway_request\nResponse:    parse_gateway_response, raise_for_gateway_status\nConvenience: call_claude_opus, call_claude_sonnet, call_gemini_pro, call_gemini_flash\nDiscovery:   list_available_models, get_model_config, get_default_model, get_default_models\nConfig:      ModelConfig, gateway_timeout_seconds, invalidate_model_cache\nErrors:      ModelRefusedError, GatewayError, GatewayInsufficientCreditError,\n             GatewayUpstreamError, GatewayTimeoutError, GatewayAuthError,\n             GatewayRateLimitError, GatewayClientError, GatewayUnexpectedStatusError\n```\n\nThe convenience functions are named for the **role** they resolve, not the model or a provider client — each is `call_model(get_default_model(\u003Crole>), …)` under the hood. The role-to-model mapping lives in the registry (`crux\u002Fscripts\u002Fcrux\u002F_config\u002Fllm_router_config.json`), so check it before trusting a name: `call_claude_sonnet` resolves `anthropic_balanced` and `call_claude_opus` resolves `anthropic_top`, whatever those roles point at today.\n\n## Running it (PEP 723 driver under `uv`)\n\n`llm_caller.py` imports `httpx`, so bare `python3` dies with `ModuleNotFoundError`. Write your driver to a temp `.py` starting with the standard PEP 723 header, then run it with `uv` (which provisions the deps into a cached, isolated environment):\n\n```python\n# \u002F\u002F\u002F script\n# requires-python = \">=3.10\"\n# dependencies = [\"httpx>=0.27\"]\n# \u002F\u002F\u002F\nimport sys\nsys.path.insert(0, \"${CRUX_PLUGIN_ROOT}\u002Fscripts\")\n\nfrom crux.llm import call_model\n# ... your driver code\n```\n\n```bash\nd=$(mktemp -d) && uv run \"$d\u002Fdriver.py\"\n```\n\nWrite the driver into a private per-run directory as above, never a fixed shared path like `\u002Ftmp\u002Fdriver.py` — a predictable name in a world-writable directory is a symlink hazard.\n\nWhen writing the temp file, substitute `${CRUX_PLUGIN_ROOT}` (crux's portable plugin-root name — in Claude Code, the value of `CLAUDE_PLUGIN_ROOT`; in Codex, derived from this `SKILL.md`'s path per the Runtime compatibility note above) with its actual value; in a source checkout substitute the checkout's `crux\u002F` directory. Without `uv` installed this fails at the shell (`command not found: uv`, exit 127) — remediation: install uv (https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002F). See `council\u002FSKILL.md` and `docs\u002FAGENTS.md` §10.A for the canonical reference.\n\n## `call_model` — the recommended entry point\n\n```python\nfrom crux.llm import call_model\n\nresponse = call_model(\n    model=\"claude-opus-5.5\", # a registry key, not a vendor model id\n    prompt=\"Analyze this architecture for potential issues...\",\n    system=\"You are a senior software architect.\",\n    max_tokens=8000,         # optional; the registry entry's default if None\n    temperature=0.7,         # optional; omitted for models that reject or ignore it\n)\nprint(response)              # a string\n```\n\n`call_model` resolves the registry entry, builds the request, sends it, maps the status, and returns the assistant text.\n\n## `build_gateway_request` and `call_gateway` — the lower level\n\nReach for these when you need something `call_model` does not expose: multi-part content (images, video, audio), a `response_format` pin, a per-call timeout, or the raw response body.\n\n```python\nfrom crux.llm import build_gateway_request, call_gateway, get_model_config, get_default_model\n\ncfg = get_model_config(get_default_model(\"google_fast\"))\n\n# One call, text in and text out — but with a per-call deadline.\ntext = call_gateway(cfg, \"Summarize this.\", max_tokens=2000, timeout=60.0)\n\n# Multi-part content: pass a list of OpenAI-compatible parts instead of a string.\nparts = [\n    {\"type\": \"text\", \"text\": \"What is in this image?\"},\n    {\"type\": \"image_url\", \"image_url\": {\"url\": \"data:image\u002Fpng;base64,...\"}},\n]\ntext = call_gateway(cfg, parts, max_tokens=2000)\n\n# Or build the request without sending it — useful in tests and probes.\nurl, headers, payload = build_gateway_request(cfg, parts, max_tokens=2000)\n```\n\n`build_gateway_request` is the **single place the wire format is decided**. The synchronous caller and the council both build through it, so a change to the request shape cannot land on one path and miss the other. It returns a `(url, headers, payload)` triple and sends nothing, which is what makes the payload assertable in a test without a network call.\n\nThe key travels in a header, never in the URL. HTTP error text embeds the full URL including any query string, and callers persist those error strings — a key in the query string would leak into logs on any non-2xx.\n\n## `ModelConfig`\n\nThe resolved registry entry. Fields worth knowing:\n\n| Field | Meaning |\n|---|---|\n| `api_string` | The model id sent to the gateway. |\n| `max_output_tokens` | The default output budget when a call passes none. |\n| `effort` | The reasoning-effort pin, sent as the top-level `reasoning_effort`. |\n| `supports_temperature` | When false, `temperature` is omitted: the model rejects it or ignores it. |\n| `serving_providers` | The upstream hosts this entry may route to (`provider.only`). Empty means the gateway chooses. |\n| `data_collection` | The retention pin, sent on **every** request. Defaults to `\"deny\"`. |\n\n`ModelConfig` is a dataclass, so an override for one call is `dataclasses.replace(cfg, effort=\"low\")` — the registry entry stays untouched.\n\n**`serving_providers` and `data_collection` are separate concerns and must stay separate.** `serving_providers` pins *which host* may serve the request; the council uses it to hold its seats on distinct upstreams. `data_collection` denies prompt retention and applies to *every* request whether or not a host is pinned. They previously travelled together, which meant that any entry without a host pin — most of the registry — sent no retention control at all.\n\n## The error taxonomy\n\nNine exception classes, each earning its place by a **distinct operator action**. Catch `GatewayError` to handle any status-derived failure; catch a subclass when the action differs.\n\n| Class | Status | What the operator does |\n|---|---|---|\n| `GatewayInsufficientCreditError` | 402 | Add credit or raise the key's spend limit. **Do not retry** — retrying spends nothing and fixes nothing. |\n| `GatewayTimeoutError` | 408, 524 | Retry with a longer deadline. The request is fine. |\n| `GatewayRateLimitError` | 429 | Back off, then retry. The request is fine. |\n| `GatewayAuthError` | 401, 403 | Fix the credential or the entitlement — re-set it with `crux-env set OPENROUTER_API_KEY \u003Cvalue>`, or confirm presence with `crux-env check` (never prints values). Not a malformed request. |\n| `GatewayUpstreamError` | 5xx (incl. 502, 503, 529) | Wait and retry; the fault is server-side. |\n| `GatewayClientError` | other 4xx | Fix the request — bad model id, malformed payload, unsupported param. Retrying verbatim reproduces it. |\n| `GatewayUnexpectedStatusError` | other non-2xx (3xx, 1xx) | Report the status. The gateway answered something the client does not handle. |\n| `GatewayError` | — | The base class. Carries `status_code` as an `int`. |\n| `ModelRefusedError` | 200 | Not a status failure at all: the request succeeded and a safety classifier declined. Change the content or route to a fallback model. |\n\nTwo properties of this table are deliberate and easy to break:\n\n- **The order of the checks is the partition.** 402 and 429 are matched before the generic 4xx because retrying a credit exhaustion is futile while retrying a throttle is correct — opposite actions a shared label would erase.\n- **Every non-2xx is typed.** Nothing falls through to the HTTP library's own error, which carries no operator action and surfaces as `unknown`.\n\n`raise_for_gateway_status` is exported and shared, like `build_gateway_request` beside it: it is the single place an HTTP status becomes a typed exception, so the router, the council and the standalone scripts cannot drift into separate error taxonomies for the same gateway.\n\n`ModelRefusedError` is raised by `parse_gateway_response`, not by the status mapping, because a refusal arrives as a successful response whose `finish_reason` is `content_filter`. Without that check it reads as an empty string, which quietly distorts a council consensus instead of degrading one seat.\n\n## Model discovery\n\n```python\nfrom crux.llm import list_available_models, get_model_config, get_default_model, get_default_models\n\nlist_available_models()                # every registry key\nget_model_config(\"claude-opus-5.5\")    # the resolved ModelConfig\nget_default_model(\"anthropic_top\")     # the model a ROLE resolves to\nget_default_models(\"council_default\")  # roles that map to a list\n```\n\n**Prefer a role over a model key** in anything durable. `get_default_model(\"anthropic_top\")` survives a model retirement; a hardcoded model key does not. Resolve the role at call time rather than at import, so a registry edit takes effect without a restart.\n\n`get_default_model` raises `TypeError` when the role maps to a list — use `get_default_models` there.\n\n## Caching\n\n`get_default_model` and `gateway_timeout_seconds` read the registry through a cache, so a call does not re-parse the whole registry to recover one value. After editing the registry at runtime, call `invalidate_model_cache()` — it clears both, which is why it exists instead of two separate clears that could leave the caches disagreeing.\n\n## Credentials\n\n`OPENROUTER_API_KEY` is read via `crux_env.require(...)` from `~\u002F.crux\u002Fenv`, managed by the `crux-env` CLI:\n\n```bash\ncrux-env set OPENROUTER_API_KEY \u003Cvalue>\n```\n\nDo not load dotenv files manually and do not read the key from the process environment directly. A missing key raises `EnvNotConfigured`, whose remediation text names the key — do not echo that text into a log.\n\n## Rules\n\n- Trace multi-step LLM workflows through the Tracer when a reasoning trajectory needs to survive the session. See `${CRUX_PLUGIN_ROOT}\u002Fbox\u002Fruntime-apis.md` for the retained API and its source contract.\n- For council decisions, use the `council` skill rather than raw LLM calls.\n- Name a **role**, not a model key, wherever the choice outlives the call site.\n- Reach for `build_gateway_request` when you need to assert on a request without sending it; that is the seam tests are meant to use.\n","# Crux LLM Caller\n\n\u003C!-- BEGIN GENERATED: runtime-compat -->\n## Runtime compatibility\n\nThis skill is portable across Claude Code, Codex, OpenCode, and OMP (Oh My Pi). This section overrides platform-specific labels below.\n\n- Before running a command that uses `CRUX_PLUGIN_ROOT`, set it to the installed plugin root. In Claude Code, use the value of `CLAUDE_PLUGIN_ROOT`. In Codex, OpenCode, and OMP, derive it from the absolute path of this selected `SKILL.md`: the plugin root is the parent of its `skills\u002F` directory (in OMP `bash`, `skill:\u002F\u002F\u003Cname>` resolves to the skill directory). In a source checkout, use the checkout `crux\u002F` directory.\n- For project-local skills, use `.claude\u002Fskills` in Claude Code, `.agents\u002Fskills` in Codex, `.opencode\u002Fskills` in OpenCode (which also reads the singular `.opencode\u002Fskill`), and `.omp\u002Fskills` in OMP. Set `CRUX_LOCAL_SKILLS_DIR` to that path before following any command below that uses it.\n- Translate Claude Code tool labels such as `Agent`, `Read`, `Write`, `Bash`, `WebSearch`, and `WebFetch` to the matching capability in the current session. Codex names its own capabilities; OpenCode uses the lowercase forms `subagent`, `read`, `edit`, `shell`, `websearch`, and `webfetch`, where `edit` covers both `Edit` and `Write`; OMP uses `task`, `read`, `edit`, `write`, `bash`, `grep`, `glob`, `find`, `todo`, and `web_search` (where `read` also handles URLs and `skill:\u002F\u002F` URIs). Do not attempt to invoke the Claude Code labels as literal commands on another host.\n- Install the generated role agents before delegating: `install-codex-agents` in Codex, `install-opencode-agents` in OpenCode, `install-omp-agents` in OMP. Codex names them `crux_architect`, `crux_brainstormer`, `crux_commander`, `crux_dev_lead`, `crux_developer`, `crux_historian`, `crux_librarian`, `crux_night_gardener`, `crux_reviewer`, and `crux_wayfinder`; OpenCode and OMP use the bare role names `architect`, `brainstormer`, `commander`, `dev-lead`, `developer`, `historian`, `librarian`, `night-gardener`, `reviewer`, and `wayfinder` (in OMP, `scout` may also be used for reconnaissance alongside `wayfinder`). If a required role or capability is unavailable, report that truthfully instead of claiming it ran.\n- Argument placeholders such as `$adr` and `$book` bind only in Claude Code. On a host without argument binding they are unset — take the value from the user's phrase. The \"Fields OpenCode ignores\" section of `OPENCODE_GUIDE.md` names the invocation-control fields OpenCode ignores.\n\u003C!-- END GENERATED: runtime-compat -->\n\n## One gateway, one key\n\nEvery model crux calls resolves through **one OpenAI-compatible gateway**, authenticated by **one `OPENROUTER_API_KEY`**. There is no per-provider client, no provider enum, and no provider-specific key. A model is named by a registry key; the registry maps that key to the gateway address the request is sent to.\n\nTwo consequences worth stating, because both are load-bearing:\n\n- **Adding or retiring a model is a registry edit**, not a code change. Nothing in this skill's surface names a vendor.\n- **The one key is a single point of failure by design.** When it is missing or rejected, every call fails at once rather than one provider degrading. The council turns that into a below-quorum deferral rather than a verdict; see `council\u002FSKILL.md`.\n\n## File locations\n\n```\ncrux\u002Fscripts\u002Fcrux\u002Fcore\u002F\n└── llm_caller.py             ← the gateway client\n\ncrux\u002Fscripts\u002Fcrux\u002F_config\u002F\n└── llm_router_config.json    ← the registry: model keys, addresses, params\n\n~\u002F.crux\u002Fenv                   ← OPENROUTER_API_KEY (managed by `crux-env`)\n```\n\n## Exports\n\nRe-exported from `crux.core` as `crux.llm`:\n\n```\nCalling:     call_model, call_gateway, build_gateway_request\nResponse:    parse_gateway_response, raise_for_gateway_status\nConvenience: call_claude_opus, call_claude_sonnet, call_gemini_pro, call_gemini_flash\nDiscovery:   list_available_models, get_model_config, get_default_model, get_default_models\nConfig:      ModelConfig, gateway_timeout_seconds, invalidate_model_cache\nErrors:      ModelRefusedError, GatewayError, GatewayInsufficientCreditError,\n             GatewayUpstreamError, GatewayTimeoutError, GatewayAuthError,\n             GatewayRateLimitError, GatewayClientError, GatewayUnexpectedStatusError\n```\n\nThe convenience functions are named for the **role** they resolve, not the model or a provider client — each is `call_model(get_default_model(\u003Crole>), …)` under the hood. The role-to-model mapping lives in the registry (`crux\u002Fscripts\u002Fcrux\u002F_config\u002Fllm_router_config.json`), so check it before trusting a name: `call_claude_sonnet` resolves `anthropic_balanced` and `call_claude_opus` resolves `anthropic_top`, whatever those roles point at today.\n\n## Running it (PEP 723 driver under `uv`)\n\n`llm_caller.py` imports `httpx`, so bare `python3` dies with `ModuleNotFoundError`. Write your driver to a temp `.py` starting with the standard PEP 723 header, then run it with `uv` (which provisions the deps into a cached, isolated environment):\n\n```python\n# \u002F\u002F\u002F script\n# requires-python = \">=3.10\"\n# dependencies = [\"httpx>=0.27\"]\n# \u002F\u002F\u002F\nimport sys\nsys.path.insert(0, \"${CRUX_PLUGIN_ROOT}\u002Fscripts\")\n\nfrom crux.llm import call_model\n# ... your driver code\n```\n\n```bash\nd=$(mktemp -d) && uv run \"$d\u002Fdriver.py\"\n```\n\nWrite the driver into a private per-run directory as above, never a fixed shared path like `\u002Ftmp\u002Fdriver.py` — a predictable name in a world-writable directory is a symlink hazard.\n\nWhen writing the temp file, substitute `${CRUX_PLUGIN_ROOT}` (crux's portable plugin-root name — in Claude Code, the value of `CLAUDE_PLUGIN_ROOT`; in Codex, derived from this `SKILL.md`'s path per the Runtime compatibility note above) with its actual value; in a source checkout substitute the checkout's `crux\u002F` directory. Without `uv` installed this fails at the shell (`command not found: uv`, exit 127) — remediation: install uv (https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002F). See `council\u002FSKILL.md` and `docs\u002FAGENTS.md` §10.A for the canonical reference.\n\n## `call_model` — the recommended entry point\n\n```python\nfrom crux.llm import call_model\n\nresponse = call_model(\n    model=\"claude-opus-5.5\", # a registry key, not a vendor model id\n    prompt=\"Analyze this architecture for potential issues...\",\n    system=\"You are a senior software architect.\",\n    max_tokens=8000,         # optional; the registry entry's default if None\n    temperature=0.7,         # optional; omitted for models that reject or ignore it\n)\nprint(response)              # a string\n```\n\n`call_model` resolves the registry entry, builds the request, sends it, maps the status, and returns the assistant text.\n\n## `build_gateway_request` and `call_gateway` — the lower level\n\nReach for these when you need something `call_model` does not expose: multi-part content (images, video, audio), a `response_format` pin, a per-call timeout, or the raw response body.\n\n```python\nfrom crux.llm import build_gateway_request, call_gateway, get_model_config, get_default_model\n\ncfg = get_model_config(get_default_model(\"google_fast\"))\n\n# One call, text in and text out — but with a per-call deadline.\ntext = call_gateway(cfg, \"Summarize this.\", max_tokens=2000, timeout=60.0)\n\n# Multi-part content: pass a list of OpenAI-compatible parts instead of a string.\nparts = [\n    {\"type\": \"text\", \"text\": \"What is in this image?\"},\n    {\"type\": \"image_url\", \"image_url\": {\"url\": \"data:image\u002Fpng;base64,...\"}},\n]\ntext = call_gateway(cfg, parts, max_tokens=2000)\n\n# Or build the request without sending it — useful in tests and probes.\nurl, headers, payload = build_gateway_request(cfg, parts, max_tokens=2000)\n```\n\n`build_gateway_request` is the **single place the wire format is decided**. The synchronous caller and the council both build through it, so a change to the request shape cannot land on one path and miss the other. It returns a `(url, headers, payload)` triple and sends nothing, which is what makes the payload assertable in a test without a network call.\n\nThe key travels in a header, never in the URL. HTTP error text embeds the full URL including any query string, and callers persist those error strings — a key in the query string would leak into logs on any non-2xx.\n\n## `ModelConfig`\n\nThe resolved registry entry. Fields worth knowing:\n\n| Field | Meaning |\n|---|---|\n| `api_string` | The model id sent to the gateway. |\n| `max_output_tokens` | The default output budget when a call passes none. |\n| `effort` | The reasoning-effort pin, sent as the top-level `reasoning_effort`. |\n| `supports_temperature` | When false, `temperature` is omitted: the model rejects it or ignores it. |\n| `serving_providers` | The upstream hosts this entry may route to (`provider.only`). Empty means the gateway chooses. |\n| `data_collection` | The retention pin, sent on **every** request. Defaults to `\"deny\"`. |\n\n`ModelConfig` is a dataclass, so an override for one call is `dataclasses.replace(cfg, effort=\"low\")` — the registry entry stays untouched.\n\n**`serving_providers` and `data_collection` are separate concerns and must stay separate.** `serving_providers` pins *which host* may serve the request; the council uses it to hold its seats on distinct upstreams. `data_collection` denies prompt retention and applies to *every* request whether or not a host is pinned. They previously travelled together, which meant that any entry without a host pin — most of the registry — sent no retention control at all.\n\n## The error taxonomy\n\nNine exception classes, each earning its place by a **distinct operator action**. Catch `GatewayError` to handle any status-derived failure; catch a subclass when the action differs.\n\n| Class | Status | What the operator does |\n|---|---|---|\n| `GatewayInsufficientCreditError` | 402 | Add credit or raise the key's spend limit. **Do not retry** — retrying spends nothing and fixes nothing. |\n| `GatewayTimeoutError` | 408, 524 | Retry with a longer deadline. The request is fine. |\n| `GatewayRateLimitError` | 429 | Back off, then retry. The request is fine. |\n| `GatewayAuthError` | 401, 403 | Fix the credential or the entitlement — re-set it with `crux-env set OPENROUTER_API_KEY \u003Cvalue>`, or confirm presence with `crux-env check` (never prints values). Not a malformed request. |\n| `GatewayUpstreamError` | 5xx (incl. 502, 503, 529) | Wait and retry; the fault is server-side. |\n| `GatewayClientError` | other 4xx | Fix the request — bad model id, malformed payload, unsupported param. Retrying verbatim reproduces it. |\n| `GatewayUnexpectedStatusError` | other non-2xx (3xx, 1xx) | Report the status. The gateway answered something the client does not handle. |\n| `GatewayError` | — | The base class. Carries `status_code` as an `int`. |\n| `ModelRefusedError` | 200 | Not a status failure at all: the request succeeded and a safety classifier declined. Change the content or route to a fallback model. |\n\nTwo properties of this table are deliberate and easy to break:\n\n- **The order of the checks is the partition.** 402 and 429 are matched before the generic 4xx because retrying a credit exhaustion is futile while retrying a throttle is correct — opposite actions a shared label would erase.\n- **Every non-2xx is typed.** Nothing falls through to the HTTP library's own error, which carries no operator action and surfaces as `unknown`.\n\n`raise_for_gateway_status` is exported and shared, like `build_gateway_request` beside it: it is the single place an HTTP status becomes a typed exception, so the router, the council and the standalone scripts cannot drift into separate error taxonomies for the same gateway.\n\n`ModelRefusedError` is raised by `parse_gateway_response`, not by the status mapping, because a refusal arrives as a successful response whose `finish_reason` is `content_filter`. Without that check it reads as an empty string, which quietly distorts a council consensus instead of degrading one seat.\n\n## Model discovery\n\n```python\nfrom crux.llm import list_available_models, get_model_config, get_default_model, get_default_models\n\nlist_available_models()                # every registry key\nget_model_config(\"claude-opus-5.5\")    # the resolved ModelConfig\nget_default_model(\"anthropic_top\")     # the model a ROLE resolves to\nget_default_models(\"council_default\")  # roles that map to a list\n```\n\n**Prefer a role over a model key** in anything durable. `get_default_model(\"anthropic_top\")` survives a model retirement; a hardcoded model key does not. Resolve the role at call time rather than at import, so a registry edit takes effect without a restart.\n\n`get_default_model` raises `TypeError` when the role maps to a list — use `get_default_models` there.\n\n## Caching\n\n`get_default_model` and `gateway_timeout_seconds` read the registry through a cache, so a call does not re-parse the whole registry to recover one value. After editing the registry at runtime, call `invalidate_model_cache()` — it clears both, which is why it exists instead of two separate clears that could leave the caches disagreeing.\n\n## Credentials\n\n`OPENROUTER_API_KEY` is read via `crux_env.require(...)` from `~\u002F.crux\u002Fenv`, managed by the `crux-env` CLI:\n\n```bash\ncrux-env set OPENROUTER_API_KEY \u003Cvalue>\n```\n\nDo not load dotenv files manually and do not read the key from the process environment directly. A missing key raises `EnvNotConfigured`, whose remediation text names the key — do not echo that text into a log.\n\n## Rules\n\n- Trace multi-step LLM workflows through the Tracer when a reasoning trajectory needs to survive the session. See `${CRUX_PLUGIN_ROOT}\u002Fbox\u002Fruntime-apis.md` for the retained API and its source contract.\n- For council decisions, use the `council` skill rather than raw LLM calls.\n- Name a **role**, not a model key, wherever the choice outlives the call site.\n- Reach for `build_gateway_request` when you need to assert on a request without sending it; that is the seam tests are meant to use.\n",{"name":5,"metadata":24,"description":7,"user-invocable":20},{"tags":25,"bundles":26,"risk_level":27,"requires_env":28,"requires_access":29},"llm, multi-model, gateway","crux-core, crux-docs","medium","OPENROUTER_API_KEY","run-plugin-script","main","dd4f16e7ac12ff940790660ec897677284ae4b6d","crux\u002Fskills\u002Fcall-llm","https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux","https:\u002F\u002Fbionic-coding.com\u002Fcrux\u002F","https:\u002F\u002Fgithub.com\u002Fbionic-coding","https:\u002F\u002Fbionic-coding.com","Durable intent, disposable code.","2026-11-12 09:36:33",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add bionic-coding\u002Fcrux --skill call-llm",{"tool":45,"command":46},"bunx","bunx skills add bionic-coding\u002Fcrux --skill call-llm",{"tool":48,"command":49},"pnpm","pnpm dlx skills add bionic-coding\u002Fcrux --skill call-llm","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux\u002Fblob\u002Fmain\u002Fcrux\u002Fskills\u002Fcall-llm\u002FSKILL.md",true,[],[54,61,68,75,82,89],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7CA5PH4JT2V5WBTA5ZPJNS8","whiteboarding","Explore an idea through docs-informed dialogue before committing to a design. Capture the exploration for later filing as a brief.","https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux\u002Fblob\u002Fmain\u002Fcrux\u002Fskills\u002Fwhiteboarding\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7CA5GZPSVNJJZYQMF0JT3EH","verify-code-docs","Check generated code documentation against source and report drift without regenerating it.","https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux\u002Fblob\u002Fmain\u002Fcrux\u002Fskills\u002Fverify-code-docs\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7CA5A4HA73VF91N8VY6SDBN","transition-observation","Apply a human disposition to an observation's lifecycle state without changing its claim or body.","https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux\u002Fblob\u002Fmain\u002Fcrux\u002Fskills\u002Ftransition-observation\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7CA53X1ESGWKTPCEQ55JWEZ","transition-invariant","Ratify, reject, or retire an invariant on human direction. Update lifecycle metadata without changing the invariant's body.","https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux\u002Fblob\u002Fmain\u002Fcrux\u002Fskills\u002Ftransition-invariant\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7CA4Y2VC25NFZE0XJZ47VSX","transition-decision","Apply a human ratify, reject, or defer verdict to a recovered decision candidate; ratification creates a Proposed ADR or observation.","https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux\u002Fblob\u002Fmain\u002Fcrux\u002Fskills\u002Ftransition-decision\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M7CA4QD9RFDC379VD9DNK90D","transition-brief","Publish or abandon a draft brief, updating lifecycle metadata and indexes without changing its body.","https:\u002F\u002Fgithub.com\u002Fbionic-coding\u002Fcrux\u002Fblob\u002Fmain\u002Fcrux\u002Fskills\u002Ftransition-brief\u002FSKILL.md",[],[]]