/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ /** * Trust pill — small badge sitting near the model name in the chat header * that names the actual API host requests are going to when a BYOK route is * active. Always-on for BYOK models (not just during streaming) so users can * see at a glance where their data is going, without having to open DevTools. * * Returns null for proxy/free routes — the pill is a BYOK-specific trust * signal; we don't need a "→ our proxy" pill cluttering the UI for the * default tier. */ import { useEffect, useState } from 'react'; import { Lock } from 'lucide-react'; import { cn } from '@/lib/utils'; import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/tooltip'; import { resolveStreamRoute } from '@/lib/llm/byok-guard'; import { getApiKeys, subscribeApiKeys, type ApiKeyConfig } from '@/services/api-keys'; interface ByokStreamingPillProps { modelId: string; className?: string; } export function ByokStreamingPill({ modelId, className }: ByokStreamingPillProps) { const [apiKeys, setApiKeys] = useState(() => getApiKeys()); useEffect(() => subscribeApiKeys(() => setApiKeys(getApiKeys())), []); const route = resolveStreamRoute(modelId, apiKeys); if (route.kind !== 'anthropic' && route.kind !== 'openai') return null; const host = route.kind === 'anthropic' ? 'api.anthropic.com' : 'api.openai.com'; const shortHost = route.kind === 'anthropic' ? 'anthropic.com' : 'openai.com'; return ( {shortHost} Messages from this model go directly from your browser to{' '} {host}. To verify, open DevTools → Network and filter {shortHost}. ); }