five-on-it / apps/creator/src/openrouter
apps/creator/src/openrouter
OpenRouter's chat completions (POST /api/v1/chat/completions) as a Model: the conversation with the tools as functions, one tool call at a time (parallel_tool_calls: false), no provider that keeps prompts for training (provider.data_collection: 'deny'), and the models after the first as fallbacks (models: OpenRouter tries the next when one is down or refuses). Every answer says what the call cost, in dollars (OpenRouter's usage accounting, always on). A provider out of credit (402) fails at once, a busy or broken one (429, 5xx) is tried again a couple of times, and every refusal is no fault of the brief (ModelError.system).
The prices are OpenRouter's own, read once at start from its models endpoint (GET /api/v1/models, fetchPrices): the dearest of the models a call may land on, which the runner bounds each call with before it is made (runner.ts), and which prices a call whose answer says no cost.