Skip to content

feat(app): choose OpenRouter or TypeSafe for Jev in the API keys dialog - #152

Open
tbrandenburg wants to merge 2 commits into
CopilotKit:mainfrom
tbrandenburg:feat/148-jev-openrouter-byok
Open

tbrandenburg wants to merge 2 commits into
CopilotKit:mainfrom
tbrandenburg:feat/148-jev-openrouter-byok

Conversation

@tbrandenburg

Copy link
Copy Markdown

Summary

Lets visitors who bring their own keys choose OpenRouter or TypeSafe for Jev in the API keys dialog. Omitting the choice keeps today's TypeSafe behaviour.

Closes #148

Stacked on #151 (shared-server provider support, closes #147): this branch contains that PR's commit, so review only the top commit, feat(app): choose OpenRouter or TypeSafe for Jev in the API keys dialog. I'll rebase once #151 merges.

Changes

  • Dialog: a "Jev provider" selector (TypeSafe default, OpenRouter) that relabels the key field. x-jev-provider is only sent when OpenRouter is chosen.
  • apps/app/src/lib/provider-keys.ts: strict allow-list for the header (typesafe | openrouter); anything else is rejected with the existing input error.
  • credentials.py: Credentials.jev_provider, x-jev-provider is stripped like the other credential headers, an unknown value is invalid_keys, and the provider is part of the BYOK thread-ID hash so checkpoints never mix providers. /credentials/validate now tests the selected provider's endpoint.
  • visualization_router.jev_provider() uses the visitor's provider when credentials are present.
  • README and docs updated.

Security notes

Same handling as the existing key headers: memory-only in the browser, not persisted or logged, stripped before the inner app, tracing disabled for BYOK. Unknown provider values fail closed. Changing the provider changes the thread namespace, so no history is shared across providers.

Testing

  • uv run --directory apps/agent pytest: 119 passed (new: header parsing and allow-list, provider-specific thread namespacing, visitor provider overriding the server setting).
  • pnpm --filter @repo/app test: 165 passed (new: header allow-list). pnpm --filter @repo/app lint: no errors.
  • End to end, no mocks: dev server plus agent, real OpenAI key and real OpenRouter key entered in the dialog with "OpenRouter" selected. Test connection passed against both providers, Save keys worked, and the prompt "Create a beautiful interactive bar chart ..." streamed a preview after about 13-24 s and rendered the final chart (screenshot below; the "Wind" bar is selected and the detail panel shows 70 units / 35.9%). The agent log shows the real POST /credentials/validate returning 200.

Not verified

Tom Brandenburg added 2 commits November 22, 2026 14:22
…server keys

JEV_PROVIDER=openrouter selects OpenRouter's Decisions API with OPENROUTER_API_KEY and typesafe/jev-1.14 by default. TypeSafe remains the default; visitor keys always use TypeSafe; an unsupported value fails at startup with no fallback.

Closes CopilotKit#147
The dialog gets a Jev provider selector. The choice travels in x-jev-provider next to the key headers, is allow-listed by the Next.js proxy and the agent middleware, is stripped before the inner app, namespaces BYOK thread IDs, and selects the validation endpoint. Omitting the header keeps TypeSafe behavior.

Closes CopilotKit#148

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant