Host Claude Opus through the tool proxy - #46
Open
devbadya wants to merge 2 commits into
Open
Conversation
The 0.8B on-device model stays as the fallback. With ANTHROPIC_API_KEY on the proxy, visitors chat against claude-opus-5 without a GPU or a 448 MB install, and the key never enters the Pages bundle. Co-authored-by: Sebastian <devbadya@users.noreply.github.com>
Skill exemplars inject earlier tool results into the prompt. The mock provider was answering from those instead of calling the calculator. The header still said on-device after a hosted model had connected. Co-authored-by: Sebastian <devbadya@users.noreply.github.com>
devbadya
marked this pull request as ready for review
August 31, 2026 10:44
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.
Why
The on-device 0.8B model will not become ChatGPT. Visitors without a GPU (or without installing 448 MB) currently get nothing. This puts Claude Opus behind the existing Railway/tool proxy so the published Pages site can chat like a hosted product: one key on the server, no key in the bundle, tools still run in the tab.
The official Opus API is platform.claude.com (Console → API keys + Billing). That is the site to use. OpenRouter is an optional middleman if Anthropic is unset (
OPENAI_BASE_URL=https://openrouter.ai/api/v1,OPENAI_MODEL=anthropic/claude-opus-5). Do not buy keys from resellers.What changed
POST /api/chaton the tool proxy streams Claude Opus (ANTHROPIC_API_KEY, default modelclaude-opus-5). OpenAI-compatible hosts remain a fallback. Set either key tomockto exercise the wiring without a provider.{ chat: { model, provider } }when a key is set. The landing page then offers Start chatting and skips the download.highso this proxy can rebuild tool-round messages without storing Anthropic thinking blocks (those must be echoed unmodified or the API 400s).PROXY_ORIGINSis set,/api/chatrequires a matchingOriginso a curl from the public internet cannot spend the key.How to turn it on
ANTHROPIC_API_KEY(and keepPROXY_ORIGINSpointed at the Pages origin).AGENT_API_BASEto the Railway origin, or paste that origin into Tool proxy URL.You pay Anthropic per token for every visitor ($5 / MTok input, $25 / MTok output). Leave the key unset and inference stays in the tab, which is how the public demo still works.
Walkthrough
Mock provider (
ANTHROPIC_API_KEY=mock) onpnpm dev. Landing offers Start chatting with no GPU install; header readsmock · hosted;12 * 8calls the calculator and answers96.Hosted landing with Start chatting
Calculator tool card and 12 times 8 equals 96
hosted_mock_chat_hello_and_calculator.mp4
Checks
pnpm checkis green (1231 tests).To show artifacts inline, enable in settings.