feat(agent): route visualization through OpenRouter's Jev for shared server keys
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) oropenrouter.- With
openrouter: useOPENROUTER_API_KEY, POST tohttps://openrouter.ai/api/alpha/decisions, default modeltypesafe/jev-1.14(JEV_MODELstill overrides). server_credentials_available()checks the key that matches the selected provider.- Unknown
JEV_PROVIDERvalues 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.