diff --git a/.env.example b/.env.example index 29bbc80c..495a292b 100644 --- a/.env.example +++ b/.env.example @@ -10,8 +10,13 @@ OPENAI_API_KEY= LLM_MODEL=chat-latest # Jev selects the renderer and visualization before each new user turn. +# JEV_PROVIDER=typesafe (default) uses TYPESAFE_API_KEY and jev-latest. +# JEV_PROVIDER=openrouter uses OPENROUTER_API_KEY and typesafe/jev-1.14. +JEV_PROVIDER=typesafe TYPESAFE_API_KEY= -JEV_MODEL=jev-latest +# OPENROUTER_API_KEY= +# JEV_MODEL overrides the provider's default model for shared-server requests. +# JEV_MODEL=jev-latest # Frontend settings: place these in apps/app/.env.local. # LANGGRAPH_DEPLOYMENT_URL defaults to http://localhost:8123. diff --git a/README.md b/README.md index 26671fab..b2d56f01 100644 --- a/README.md +++ b/README.md @@ -153,11 +153,11 @@ make dev Open the [app](http://localhost:3000). The [agent health endpoint](http://localhost:8123/health) confirms the agent service is running. See [Getting started](docs/getting-started.md) for configuration and verification. -The default model is `chat-latest`, OpenAI’s documented alias for the latest ChatGPT Instant model, requiring `OPENAI_API_KEY`. Jev (`jev-latest`, requiring `TYPESAFE_API_KEY`) selects the renderer and visualization for each user turn. Basic tables use A2UI; charts, diagrams, calculators, and maps use Open Generative UI. Provider failures are surfaced instead of silently substituting another router or model. See [Visualization routing](docs/visualization-routing.md). +The default model is `chat-latest`, OpenAI’s documented alias for the latest ChatGPT Instant model, requiring `OPENAI_API_KEY`. Jev selects the renderer and visualization for each user turn via TypeSafe or OpenRouter. Basic tables use A2UI; charts, diagrams, calculators, and maps use Open Generative UI. Provider failures are surfaced instead of silently substituting another router or model. See [Visualization routing](docs/visualization-routing.md). ## Use your own API keys -The chat asks for both keys before sending your first message or example prompt and keeps your draft while you set them up. Open **API keys** in the chat header, enter an OpenAI key and a Jev key, then choose **Test connection** and **Save keys**. The connection test makes a small request to each provider. Your keys use `chat-latest` for answers and `jev-latest` for visualization routing, with usage billed to your provider accounts. +The chat asks for both keys before sending your first message or example prompt and keeps your draft while you set them up. Open **API keys** in the chat header, enter an OpenAI key, select TypeSafe or OpenRouter for Jev and enter its key, then choose **Test connection** and **Save keys**. The connection test makes a small request to each provider. Your keys use `chat-latest` for answers and the selected provider's Jev model for visualization routing, with usage billed to your provider accounts. Keys stay in browser memory until refresh or **Clear keys**; the app does not save them in browser storage. Requests send them through the application server to their respective providers. They are kept out of chat state and checkpoints, and hosted LangSmith tracing is disabled for requests using your keys. Only use this feature on a deployment whose operator you trust. Saving or clearing keys starts a new chat; **New chat** keeps your keys for the current session. diff --git a/apps/agent/main.py b/apps/agent/main.py index 9fec803e..780fb733 100644 --- a/apps/agent/main.py +++ b/apps/agent/main.py @@ -22,7 +22,7 @@ current_credentials, validate_credentials, ) -from src.visualization_router import JevVisualizationMiddleware +from src.visualization_router import JevVisualizationMiddleware, jev_provider from src.skill_backend import SKILL_SOURCES, build_agent_backend from src.query import query_data from src.todos import AgentState, todo_tools @@ -32,6 +32,7 @@ from src.prompt import SYSTEM_PROMPT load_dotenv() +jev_provider() # fail at startup on an unsupported JEV_PROVIDER, like LLM_MODEL agent = create_deep_agent( model=CredentialScopedModel(fallback=build_model(allow_unconfigured=True)), diff --git a/apps/agent/src/credentials.py b/apps/agent/src/credentials.py index ea8cac90..d8ce630e 100644 --- a/apps/agent/src/credentials.py +++ b/apps/agent/src/credentials.py @@ -18,10 +18,11 @@ class Credentials: openai: str = field(repr=False) jev: str = field(repr=False) + jev_provider: str = 'typesafe' current_credentials: ContextVar[Credentials | None] = ContextVar('provider_credentials', default=None) -SENSITIVE_HEADERS = {b'x-openai-api-key', b'x-jev-api-key'} +SENSITIVE_HEADERS = {b'x-openai-api-key', b'x-jev-api-key', b'x-jev-provider'} def parse_credentials(headers): @@ -40,15 +41,21 @@ def parse_credentials(headers): values[name] = value.decode('ascii') if not values: return None - if len(values) != 2: + if b'x-openai-api-key' not in values or b'x-jev-api-key' not in values: raise ValueError('invalid_keys') - return Credentials(values[b'x-openai-api-key'], values[b'x-jev-api-key']) + provider = values.get(b'x-jev-provider', 'typesafe') + if provider not in {'typesafe', 'openrouter'}: + raise ValueError('invalid_keys') + return Credentials(values[b'x-openai-api-key'], values[b'x-jev-api-key'], provider) def server_credentials_available(): model = os.environ.get('LLM_MODEL', 'chat-latest').strip() key = 'ANTHROPIC_API_KEY' if model.startswith('claude-') else 'OPENAI_API_KEY' - return bool(os.environ.get(key, '').strip() and os.environ.get('TYPESAFE_API_KEY', '').strip()) + from src.visualization_router import JEV_PROVIDERS, jev_provider + + jev_key = JEV_PROVIDERS[jev_provider()][0] + return bool(os.environ.get(key, '').strip() and os.environ.get(jev_key, '').strip()) class CredentialsMiddleware: @@ -77,7 +84,7 @@ async def __call__(self, scope, receive, send): def private_thread_id(thread_id): credentials = current_credentials.get() if credentials: - key = hashlib.sha256(json.dumps([credentials.openai, credentials.jev]).encode()).digest() + key = hashlib.sha256(json.dumps([credentials.openai, credentials.jev, credentials.jev_provider]).encode()).digest() namespace = 'byok' else: key = b'open-intelligent-ui-server-threads-v1' @@ -98,7 +105,7 @@ async def run(self, input): async def validate_credentials(credentials): """Exercise both APIs; never forward their response bodies or exceptions.""" - from src.visualization_router import JEV_URL, request_options + from src.visualization_router import jev_url, request_options async def check(provider, url, options): try: @@ -119,7 +126,7 @@ async def check(provider, url, options): 'headers': {'Authorization': f'Bearer {credentials.openai}'}, 'json': {'model': 'chat-latest', 'messages': [{'role': 'user', 'content': 'Reply OK.'}], 'max_completion_tokens': 8}, }), - check('jev', JEV_URL, request_options([{'role': 'human', 'content': 'Hello'}])), + check('jev', jev_url(), request_options([{'role': 'human', 'content': 'Hello'}])), ) finally: current_credentials.reset(token) diff --git a/apps/agent/src/visualization_router.py b/apps/agent/src/visualization_router.py index 928556b7..f9e2f425 100644 --- a/apps/agent/src/visualization_router.py +++ b/apps/agent/src/visualization_router.py @@ -12,6 +12,11 @@ from pydantic import BaseModel, Field, ValidationError JEV_URL = "https://api.typesafe.ai/v1/systemone" +OPENROUTER_JEV_URL = "https://openrouter.ai/api/alpha/decisions" +JEV_PROVIDERS = { + "typesafe": ("TYPESAFE_API_KEY", JEV_URL, "jev-latest"), + "openrouter": ("OPENROUTER_API_KEY", OPENROUTER_JEV_URL, "typesafe/jev-1.14"), +} VISUALIZATIONS = { "text": "Direct facts, prose, writing, code, conversation, or a clarification; no visual needed.", "table": "Basic table: exact values, records, simple side-by-side comparison; no custom interaction.", @@ -113,19 +118,36 @@ def routing_input(state): return turn, context +def jev_provider(): + from src.credentials import current_credentials + + credentials = current_credentials.get() + if credentials: + return credentials.jev_provider + provider = os.environ.get("JEV_PROVIDER", "typesafe").strip() + if provider not in JEV_PROVIDERS: + raise ValueError("JEV_PROVIDER must be typesafe or openrouter.") + return provider + + +def jev_url(): + return JEV_PROVIDERS[jev_provider()][1] + + def request_options(context): from src.credentials import current_credentials credentials = current_credentials.get() - key = credentials.jev if credentials else os.environ.get("TYPESAFE_API_KEY", "").strip() + key_name, _, default_model = JEV_PROVIDERS[jev_provider()] + key = credentials.jev if credentials else os.environ.get(key_name, "").strip() if not key: raise ValueError( - "TYPESAFE_API_KEY is required for Jev visualization routing. Configure it and restart the agent." + f"{key_name} is required for Jev visualization routing. Configure it and restart the agent." ) return { "headers": {"Authorization": f"Bearer {key}"}, "json": { - "model": "jev-latest" if credentials else os.environ.get("JEV_MODEL", "jev-latest"), + "model": default_model if credentials else os.environ.get("JEV_MODEL", default_model), "state": {"conversation": context}, "questions": { "visualization": { @@ -159,7 +181,7 @@ def provider_trust_env(): def route(context): try: with httpx.Client(timeout=15, trust_env=provider_trust_env()) as client: - return parse_response(client.post(JEV_URL, **request_options(context))) + return parse_response(client.post(jev_url(), **request_options(context))) except httpx.HTTPError: raise ValueError( "Jev visualization routing is unavailable or timed out. Please retry." @@ -170,7 +192,7 @@ async def aroute(context): try: async with httpx.AsyncClient(timeout=15, trust_env=provider_trust_env()) as client: return parse_response( - await client.post(JEV_URL, **request_options(context)) + await client.post(jev_url(), **request_options(context)) ) except httpx.HTTPError: raise ValueError( diff --git a/apps/agent/tests/test_credentials.py b/apps/agent/tests/test_credentials.py index 12177858..a7819b82 100644 --- a/apps/agent/tests/test_credentials.py +++ b/apps/agent/tests/test_credentials.py @@ -25,6 +25,40 @@ def test_headers_validate_without_disclosing_values(): parse_credentials([(b'x-openai-api-key', b'only')]) +def test_openrouter_selection_is_explicit_and_namespaces_threads(): + from src.credentials import parse_credentials, current_credentials, private_thread_id + headers = [(b'x-openai-api-key', b'o'), (b'x-jev-api-key', b'j')] + typesafe = parse_credentials(headers) + router = parse_credentials(headers + [(b'x-jev-provider', b'openrouter')]) + assert typesafe.jev_provider == 'typesafe' + assert router.jev_provider == 'openrouter' + token = current_credentials.set(typesafe) + try: + first = private_thread_id('thread') + finally: + current_credentials.reset(token) + token = current_credentials.set(router) + try: + assert first != private_thread_id('thread') + finally: + current_credentials.reset(token) + with pytest.raises(ValueError): + parse_credentials(headers + [(b'x-jev-provider', b'unknown')]) + + +def test_openrouter_routes_to_its_own_endpoint(monkeypatch): + from src.credentials import Credentials, current_credentials + from src.visualization_router import jev_url, request_options + monkeypatch.setenv('JEV_MODEL', 'server-model') + token = current_credentials.set(Credentials('openai', 'router-secret', 'openrouter')) + try: + assert jev_url() == 'https://openrouter.ai/api/alpha/decisions' + assert request_options([])['json']['model'] == 'typesafe/jev-1.14' + assert request_options([])['headers']['Authorization'] == 'Bearer router-secret' + finally: + current_credentials.reset(token) + + def test_concurrent_streams_isolate_keys_and_reset_on_cancellation(): from src.credentials import CredentialsMiddleware, current_credentials async def exercise(): diff --git a/apps/agent/tests/test_jev_provider.py b/apps/agent/tests/test_jev_provider.py new file mode 100644 index 00000000..d6f6f012 --- /dev/null +++ b/apps/agent/tests/test_jev_provider.py @@ -0,0 +1,72 @@ +import pytest + +from src.credentials import Credentials, current_credentials, server_credentials_available +from src.visualization_router import jev_url, request_options + + +@pytest.fixture(autouse=True) +def clean_env(monkeypatch): + for name in ("JEV_PROVIDER", "JEV_MODEL", "TYPESAFE_API_KEY", "OPENROUTER_API_KEY", "OPENAI_API_KEY", "LLM_MODEL"): + monkeypatch.delenv(name, raising=False) + + +def test_typesafe_is_the_default(monkeypatch): + monkeypatch.setenv("TYPESAFE_API_KEY", "ts-secret") + options = request_options([]) + assert jev_url() == "https://api.typesafe.ai/v1/systemone" + assert options["json"]["model"] == "jev-latest" + assert options["headers"]["Authorization"] == "Bearer ts-secret" + + +def test_openrouter_uses_its_endpoint_key_and_model(monkeypatch): + monkeypatch.setenv("JEV_PROVIDER", "openrouter") + monkeypatch.setenv("OPENROUTER_API_KEY", "or-secret") + monkeypatch.setenv("TYPESAFE_API_KEY", "ts-secret") + options = request_options([]) + assert jev_url() == "https://openrouter.ai/api/alpha/decisions" + assert options["json"]["model"] == "typesafe/jev-1.14" + assert options["headers"]["Authorization"] == "Bearer or-secret" + monkeypatch.setenv("JEV_MODEL", "typesafe/jev-1.13") + assert request_options([])["json"]["model"] == "typesafe/jev-1.13" + + +def test_openrouter_without_its_key_names_the_missing_variable(monkeypatch): + monkeypatch.setenv("JEV_PROVIDER", "openrouter") + monkeypatch.setenv("TYPESAFE_API_KEY", "ts-secret") + with pytest.raises(ValueError, match="OPENROUTER_API_KEY"): + request_options([]) + + +def test_unknown_provider_is_rejected_without_fallback(monkeypatch): + monkeypatch.setenv("JEV_PROVIDER", "other") + monkeypatch.setenv("TYPESAFE_API_KEY", "ts-secret") + with pytest.raises(ValueError, match="JEV_PROVIDER"): + jev_url() + + +def test_visitor_provider_choice_overrides_the_server_setting(monkeypatch): + monkeypatch.setenv("JEV_PROVIDER", "openrouter") + monkeypatch.setenv("JEV_MODEL", "server-model") + token = current_credentials.set(Credentials("visitor-openai", "visitor-jev")) + try: + assert jev_url() == "https://api.typesafe.ai/v1/systemone" + assert request_options([])["json"]["model"] == "jev-latest" + finally: + current_credentials.reset(token) + token = current_credentials.set(Credentials("visitor-openai", "visitor-jev", "openrouter")) + try: + assert jev_url() == "https://openrouter.ai/api/alpha/decisions" + assert request_options([])["json"]["model"] == "typesafe/jev-1.14" + finally: + current_credentials.reset(token) + + +def test_server_credentials_follow_the_selected_provider(monkeypatch): + monkeypatch.setenv("OPENAI_API_KEY", "openai") + monkeypatch.setenv("OPENROUTER_API_KEY", "or") + assert not server_credentials_available() + monkeypatch.setenv("JEV_PROVIDER", "openrouter") + assert server_credentials_available() + monkeypatch.setenv("JEV_PROVIDER", "typesafe") + monkeypatch.setenv("TYPESAFE_API_KEY", "ts") + assert server_credentials_available() diff --git a/apps/app/src/components/chat/provider-keys-dialog.tsx b/apps/app/src/components/chat/provider-keys-dialog.tsx index 1743e307..157b4f04 100644 --- a/apps/app/src/components/chat/provider-keys-dialog.tsx +++ b/apps/app/src/components/chat/provider-keys-dialog.tsx @@ -10,6 +10,7 @@ export function ProviderKeysDialog({ onClose, disabled = false }: { onClose: () const request = useRef(null); const [openai, setOpenai] = useState(""); const [jev, setJev] = useState(""); + const [provider, setProvider] = useState<"typesafe" | "openrouter">("typesafe"); const [pending, setPending] = useState(false); const [validated, setValidated] = useState(false); const [error, setError] = useState(null); @@ -38,7 +39,7 @@ export function ProviderKeysDialog({ onClose, disabled = false }: { onClose: () try { const response = await fetch("/api/provider-keys", { method: "POST", - headers: { "x-openai-api-key": openai.trim(), "x-jev-api-key": jev.trim() }, + headers: { "x-openai-api-key": openai.trim(), "x-jev-api-key": jev.trim(), ...(provider === "openrouter" ? { "x-jev-provider": provider } : {}) }, signal: controller.signal, cache: "no-store", }); @@ -66,7 +67,12 @@ export function ProviderKeysDialog({ onClose, disabled = false }: { onClose: ()
{ event.preventDefault(); void testConnection(); }}> edit(setOpenai, event.target.value)} disabled={pending || disabled} /> - + + + edit(setJev, event.target.value)} disabled={pending || disabled} /> {error &&

{error}

}

{pending ? "Checking both providers…" : validated ? "Both keys work. Save to start a new chat." : hasKeys ? "Your own keys are active for this session." : "Both keys are required to start chatting."}

@@ -74,7 +80,7 @@ export function ProviderKeysDialog({ onClose, disabled = false }: { onClose: () {hasKeys && } - +
diff --git a/apps/app/src/components/chat/provider-keys.css b/apps/app/src/components/chat/provider-keys.css index 97427513..4450b350 100644 --- a/apps/app/src/components/chat/provider-keys.css +++ b/apps/app/src/components/chat/provider-keys.css @@ -14,7 +14,7 @@ .provider-keys-dialog h2 { margin: 0 0 12px; font-size: 20px; font-weight: 600; } .provider-keys-dialog p { margin: 12px 0; font-size: 13px; line-height: 1.6; } .provider-keys-dialog label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 500; } -.provider-keys-dialog input { width: 100%; min-width: 0; border: 1px solid var(--border-default); border-radius: 8px; padding: 10px; background: var(--surface-primary); font-size: 16px; } +.provider-keys-dialog input, .provider-keys-dialog select { width: 100%; min-width: 0; border: 1px solid var(--border-default); border-radius: 8px; padding: 10px; background: var(--surface-primary); font-size: 16px; } .provider-keys-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 20px; } .provider-keys-actions button { padding: 10px 12px; border: 1px solid var(--border-default); border-radius: 8px; font-size: 12px; cursor: pointer; } .provider-keys-actions .provider-keys-save { background: var(--text-primary); color: var(--surface-primary); } diff --git a/apps/app/src/components/chat/provider-keys.tsx b/apps/app/src/components/chat/provider-keys.tsx index 8840ee61..2352160c 100644 --- a/apps/app/src/components/chat/provider-keys.tsx +++ b/apps/app/src/components/chat/provider-keys.tsx @@ -2,7 +2,7 @@ import { createContext, useContext, useState, type ReactNode } from "react"; -export type ProviderKeys = { openai: string; jev: string }; +export type ProviderKeys = { openai: string; jev: string; jevProvider?: "typesafe" | "openrouter" }; type ProviderKeysContextValue = { headers: Record | undefined; hasKeys: boolean; @@ -26,7 +26,7 @@ export function ProviderKeysProvider({ children }: { children: ReactNode }) { const newChat = () => { setDraft(""); setSession((value) => value + 1); }; return ( { setKeys(value); setKeysOpen(false); setSession((value) => value + 1); }, diff --git a/apps/app/src/lib/__tests__/provider-keys.test.ts b/apps/app/src/lib/__tests__/provider-keys.test.ts index 51ef428e..2ed32ce5 100644 --- a/apps/app/src/lib/__tests__/provider-keys.test.ts +++ b/apps/app/src/lib/__tests__/provider-keys.test.ts @@ -1,6 +1,13 @@ import { describe, expect, it } from "vitest"; import { readProviderHeaders } from "../provider-keys"; +it("accepts only explicitly supported Jev providers", () => { + const keys = { "x-openai-api-key": "openai", "x-jev-api-key": "jev" }; + expect(readProviderHeaders(new Headers({ ...keys, "x-jev-provider": "openrouter" }))) + .toEqual({ ...keys, "x-jev-provider": "openrouter" }); + expect(() => readProviderHeaders(new Headers({ ...keys, "x-jev-provider": "other" }))).toThrow(); +}); + describe("request-scoped provider credentials", () => { it("leaves server mode unchanged when no keys are supplied", () => { expect(readProviderHeaders(new Headers())).toBeUndefined(); diff --git a/apps/app/src/lib/provider-keys.ts b/apps/app/src/lib/provider-keys.ts index e39a29d8..5e42b4ef 100644 --- a/apps/app/src/lib/provider-keys.ts +++ b/apps/app/src/lib/provider-keys.ts @@ -1,6 +1,7 @@ export type ProviderHeaders = { "x-openai-api-key": string; "x-jev-api-key": string; + "x-jev-provider"?: "typesafe" | "openrouter"; }; export const PROVIDER_KEY_INPUT_ERROR = "Enter both OpenAI and Jev API keys (up to 4,096 characters each, without spaces)."; @@ -9,9 +10,10 @@ export const PROVIDER_KEY_INPUT_ERROR = "Enter both OpenAI and Jev API keys (up export function readProviderHeaders(headers: Headers): ProviderHeaders | undefined { const openai = headers.get("x-openai-api-key"); const jev = headers.get("x-jev-api-key"); - if (openai === null && jev === null) return undefined; + const provider = headers.get("x-jev-provider"); + if (openai === null && jev === null && provider === null) return undefined; const valid = (value: string | null): value is string => value !== null && /^[\x21-\x7e]{1,4096}$/.test(value.trim()); - if (!valid(openai) || !valid(jev)) throw new Error(PROVIDER_KEY_INPUT_ERROR); - return { "x-openai-api-key": openai.trim(), "x-jev-api-key": jev.trim() }; + if (!valid(openai) || !valid(jev) || (provider !== null && provider !== "typesafe" && provider !== "openrouter")) throw new Error(PROVIDER_KEY_INPUT_ERROR); + return { "x-openai-api-key": openai.trim(), "x-jev-api-key": jev.trim(), ...(provider ? { "x-jev-provider": provider } : {}) }; } diff --git a/docs/deployment.md b/docs/deployment.md index 1bbf12d8..855eff0f 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -18,6 +18,8 @@ For shared credentials, the blueprint and Python factory default to `LLM_MODEL=c | `LLM_MODEL` | Agent | `claude-*` routes to Anthropic; `gpt-*` routes to OpenAI | | `ANTHROPIC_API_KEY` | Agent | Required when selecting Anthropic | | `OPENAI_API_KEY` | Agent | Required when selecting OpenAI | +| `JEV_PROVIDER` | Agent | `typesafe` (default) or `openrouter`; selects the shared-server Jev provider | +| `OPENROUTER_API_KEY` | Agent | Jev key when `JEV_PROVIDER=openrouter` | | `LANGSMITH_API_KEY` | As configured | Optional tracing configuration | | `LANGGRAPH_DEPLOYMENT_URL` | Frontend | Blueprint obtains agent host:port via `fromService`; runtime normalizes it to a URL | | `RATE_LIMIT_ENABLED` | Frontend | Defaults to `false` in blueprint | @@ -32,9 +34,9 @@ Both services declare scaling from one to three instances. Agent checkpoints cur ## Visitor API keys -Visitors can supply OpenAI and Jev keys through **API keys** in the chat header. The Next.js runtime forwards only `x-openai-api-key` and `x-jev-api-key` to the configured agent, creating a separate runtime instance per request. The Python ASGI middleware strips these headers before the inner application and scopes credentials to the entire streaming request without changing process environment variables. BYOK conversations have credential-specific checkpoint IDs, separate from shared-mode conversations. Both keys are required; partial pairs never fall back to server secrets. +Visitors can supply OpenAI and Jev keys through **API keys** in the chat header, choosing TypeSafe or OpenRouter as the Jev provider. The Next.js runtime forwards only `x-openai-api-key`, `x-jev-api-key` and the optional `x-jev-provider` to the configured agent, creating a separate runtime instance per request. The Python ASGI middleware strips these headers before the inner application and scopes credentials to the entire streaming request without changing process environment variables. BYOK conversations have credential- and provider-specific checkpoint IDs, separate from shared-mode conversations. Both keys are required; partial pairs never fall back to server secrets. -`POST /api/provider-keys` proxies connection validation to the agent’s `POST /credentials/validate`. It performs small real provider requests and returns only fixed error messages. BYOK always uses the standard OpenAI endpoint and `chat-latest`; Jev uses `jev-latest`. Hosted LangSmith tracing is disabled for BYOK. The application does not persist the keys, but its server necessarily receives them: use HTTPS externally and a trusted private or TLS connection between frontend and agent. Do not configure infrastructure to log credential headers. +`POST /api/provider-keys` proxies connection validation to the agent’s `POST /credentials/validate`. It performs small real provider requests and returns only fixed error messages. BYOK always uses the standard OpenAI endpoint and `chat-latest`; Jev uses `jev-latest` on TypeSafe or `typesafe/jev-1.14` on OpenRouter. Hosted LangSmith tracing is disabled for BYOK. The application does not persist the keys, but its server necessarily receives them: use HTTPS externally and a trusted private or TLS connection between frontend and agent. Do not configure infrastructure to log credential headers. ## Other hosts diff --git a/docs/visualization-routing.md b/docs/visualization-routing.md index 77622a0f..f1dfa4c2 100644 --- a/docs/visualization-routing.md +++ b/docs/visualization-routing.md @@ -2,7 +2,7 @@ The answer model defaults to `chat-latest`, the documented API alias for the latest ChatGPT Instant model. This is a moving alias, not a pinned `gpt-6-instant` snapshot. Its available model ID was verified using the configured OpenAI account. See [OpenAI's model documentation](https://developers.openai.com/api/docs/models/chat-latest). -Jev (`jev-latest`) makes one typed presentation decision for each new user message through [TypeSafe's System One API](https://docs.typesafe.ai/introduction/quickstart). It receives up to four recent user/assistant text messages, capped at 6,000 characters each. It does not receive API keys, system instructions, raw tool outputs, or generated tool code. +Jev makes one typed presentation decision for each new user message through [TypeSafe's System One API](https://docs.typesafe.ai/introduction/quickstart) (`jev-latest`) or, for shared-server routing, [OpenRouter's Decisions API](https://openrouter.ai/docs/guides/community/jev) (`typesafe/jev-1.14`). It receives up to four recent user/assistant text messages, capped at 6,000 characters each. It does not receive API keys, system instructions, raw tool outputs, or generated tool code. | Selected visualization | Renderer | | --- | --- | @@ -17,7 +17,7 @@ The renderer is derived from Jev's validated choice, preventing contradictory re The A2UI catalog supplies a semantic HTML table with column headers, a caption, keyboard-focusable horizontal scrolling, and a required provenance label. It accepts at most 12 columns and 200 rows and rejects mismatched row widths. React renders values as text. Charts and diagrams continue to use the existing isolated sandbox. -Set `OPENAI_API_KEY`, `TYPESAFE_API_KEY`, `LLM_MODEL=chat-latest`, and optionally `JEV_MODEL=jev-latest` on the agent server. Provider secrets never belong in browser variables. Existing `claude-*` and `gpt-*` overrides remain available. Jev authentication failures, invalid choices, and timeouts fail the turn with a retryable error; there is no silent fallback claiming that Jev made a decision. Successful health checks confirm the server is running, not provider access. +Set `OPENAI_API_KEY`, `LLM_MODEL=chat-latest`, and a Jev key on the agent server: `TYPESAFE_API_KEY` by default, or `JEV_PROVIDER=openrouter` with `OPENROUTER_API_KEY`. `JEV_MODEL` optionally overrides the provider's default model. An unsupported `JEV_PROVIDER` fails at startup, and there is no fallback between providers. Visitor-supplied keys use the provider selected in the API keys dialog (TypeSafe by default). Provider secrets never belong in browser variables. Existing `claude-*` and `gpt-*` overrides remain available. Jev authentication failures, invalid choices, and timeouts fail the turn with a retryable error; there is no silent fallback claiming that Jev made a decision. Successful health checks confirm the server is running, not provider access. Routing is a model judgment, not a guarantee of the objectively best visualization. Missing source data still requires clarification or explicit illustrative assumptions. Live provider checks and browser checks complement the deterministic routing, error-path, continuation, and A2UI rendering tests.