Skip to content

dev-server: optional LLM relay for bring-your-own-key AI features - #108

Merged
kosuke55 merged 5 commits into
mainfrom
dev-server-llm-relay
Aug 26, 2026
Merged

dev-server: optional LLM relay for bring-your-own-key AI features#108
kosuke55 merged 5 commits into
mainfrom
dev-server-llm-relay

Conversation

@kosuke55

@kosuke55 kosuke55 commented Aug 23, 2026

Copy link
Copy Markdown
Owner
trim.378B04A1-EE1C-4454-8A87-F53CB4C25F68.MOV

Adds an optional LLM relay to the dev server so browsers can reach LLM APIs (Anthropic / OpenAI / Gemini) without CORS issues. The API key comes from a request header supplied by the page, is used for that request only, and is never logged or stored. Same localhost-only binding as the static server.

  • POST /api/ai-scenario/llm-relay — forwards to the vendor selected by header
  • DRAWTONOMY_LLM_BASE_URL — point the relay at a local stand-in for testing
  • README: bring-your-own-key setup
  • v0.2.0

drawtonomy generates scenarios in the browser, but browsers cannot call the
AI vendors directly: CORS policy differs per vendor and some refuse
browser-origin requests. This adds a small forwarding module so the page can
post to one same-origin route instead.

Supports Anthropic, OpenAI and Gemini. Each vendor's HTTP shape is described
in one table, so adding or fixing a vendor touches a single place.

The caller's API key travels per request in a header, is used only to build
the outgoing call, and is never written to disk, added to the environment, or
logged. Gemini takes its key in a header rather than the ?key= query
parameter so it cannot land in an access log.

Tests use a stub fetch, so they need no network and no key.
The relay answers for its own path and reports back when it did not, so the
existing static serving and SPA fallback are reached unchanged for every
other request.
README gains a section naming the three supported providers, where to get a
key, and what the server does and does not do with it.
DRAWTONOMY_LLM_BASE_URL swaps the host of every vendor URL while keeping the
path and headers, so a stand-in server sees exactly what a vendor would. This
makes it possible to develop the relay, or exercise the whole generation flow,
without a real key and without spending on API calls.
@kosuke55
kosuke55 merged commit a7c2467 into main Aug 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant