feat(smith): OpenRouter as a first-class provider and route target - #1303
Merged
Conversation
- `openrouter:` model prefix in smith (explicit only — no bare-name sniff: vendor/model slash ids collide with Ollama namespaces and an aggregator is a distinct billing path, spec 0028) - OpenRouter mode on the OpenAI chat client: usage-cost accounting (Usage.usd now carries the generation's real USD cost from the wire) and app attribution headers - built-in route target (spec 0179): OPENROUTER_API_KEY alone makes `openrouter` a route target defaulting to openrouter/auto - auto-detect ladder rung (last), title-gen rung, /configure and /model completion entries, 128K context-window floor - spec 0208 records the decision
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.
What
Adds OpenRouter (https://openrouter.ai) as a first-class model provider, following the DeepSeek/Grok pattern: a thin variant of the existing OpenAI chat-completions client plus a built-in route target. Motivated by stealth models like
stealth/ox-alpha(1M context, tool calling, currently free) that appear on OpenRouter before they have official SDKs — with this, any new routed model is reachable the day it drops via/model openrouter:vendor/model, no per-model code.openrouter:model prefix in smith's spec routing. Explicit only — no bare-name sniff: OpenRouter ids arevendor/modelslash paths, which collide with Ollama namespaces (hf.co/user/model), and an aggregator is a distinct billing path (spec 0028). Variant suffixes (:free,:nitro) pass through in the model id.OpenAi::openrouter): sends OpenRouter'susage: {include: true}accounting knob and reads the response'scostfield, soUsage.usdcarries the generation's actual USD cost for any routed model — no price table. Also sends the optionalHTTP-Referer/X-Titleattribution headers.OPENROUTER_API_KEYalone makesopenroutera route target (default modelopenrouter/auto, the aggregator's meta-router id).provider_dialectmaps it to OpenAI-chat, so native harnesses can be routed through it like any other openai-compatible target. A declared[smith.models.openrouter]profile still overrides the built-in.OPENROUTER_API_KEYis the new last rung (yields to every direct vendor key), for both sessions and title-gen.openrouter(heterogeneous models; overflow learn-and-retry tightens per model). Effort support stays unadvertised until a routed model is measured to grade it (spec 0160's model-aware rule)./modelcompletions (openrouter:openrouter/auto,openrouter:stealth/ox-alpha),/configuresmith-auth method + guidance, config.toml template comments, credential-error hints.Testing
cargo build+cargo test --workspace: all green (1455 daemon, 748 protocol, 229 smith, …, 0 failures).:freesuffixes, bare-slash-id does NOT route to OpenRouter, auto-detect precedence with the new rung, profile endpoint/key defaults; the existingevery_builtin_target_is_routable_and_self_consistentguard covers the new built-in.No TUI-visible rendering change, so no recording — the new surface is model specs, route targets, and the
/configurelist.🤖 Generated with Claude Code