OpenGenerativeUI icon indicating copy to clipboard operation
OpenGenerativeUI copied to clipboard

feat(agent): route visualization through OpenRouter's Jev for shared server keys

Open tbrandenburg opened this issue 1 week ago • 0 comments

Problem

Visualization routing requires a separate TypeSafe account and TYPESAFE_API_KEY. Jev is also available through OpenRouter (typesafe/jev-1.14, billed to the OpenRouter account), and self-hosters who already route chat models through OpenRouter (#97 / #100) would need only one key and one bill.

Proposal

Add an explicit provider setting for shared-server routing (no change to BYOK in this issue):

  • JEV_PROVIDER=typesafe (default, unchanged) or openrouter.
  • With openrouter: use OPENROUTER_API_KEY, POST to https://openrouter.ai/api/alpha/decisions, default model typesafe/jev-1.14 (JEV_MODEL still overrides).
  • server_credentials_available() checks the key that matches the selected provider.
  • Unknown JEV_PROVIDER values fail with an actionable error. No silent fallback between providers.

The request and response shape are the same as the existing call; I verified a live OpenRouter request returns a valid choice answer that decision_from_response accepts.

Scope

  • apps/agent/src/visualization_router.py, apps/agent/src/credentials.py, agent tests, docs/visualization-routing.md, docs/deployment.md, .env.example.
  • Backward compatible: nothing changes unless JEV_PROVIDER=openrouter.

Security / caveats

  • The key stays server-side and is never logged.
  • OpenRouter documents this Decisions endpoint under /api/alpha/, so the path may change; it is isolated in one constant.

Definition of done

  • Default behaviour unchanged, covered by existing tests.
  • New tests for endpoint, key, and default model selection and for invalid provider values.
  • Docs describe both providers.

Related

#97 / #100 (OpenRouter for the chat model), #98 (server-held keys). A follow-up issue covers the BYOK dialog.

Per CONTRIBUTING I would normally ask first; the implementation already exists and is tested, so a PR is linked here for review. Happy to reshape or drop it.

tbrandenburg avatar Nov 22 '26 13:11 tbrandenburg