import { Alert, AlertDescription } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { useGetCoreConfigQuery } from "@/lib/store"; import { useCopyToClipboard } from "@/hooks/useCopyToClipboard"; import { Link } from "@tanstack/react-router"; import { Copy, InfoIcon, KeyRound } from "lucide-react"; import { useMemo } from "react"; import ContactUsView from "../views/contactUsView"; export default function APIKeysView() { const { data: bifrostConfig, isLoading } = useGetCoreConfigQuery({ fromDB: true }); const isAuthConfigure = useMemo(() => { return bifrostConfig?.auth_config?.is_enabled; }, [bifrostConfig]); const curlExample = `# Base64 encode your username:password # Example: echo -n "username:password" | base64 curl --location 'http://localhost:8080/v1/chat/completions' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic ' --data '{ "model": "openai/gpt-4", "messages": [ { "role": "user", "content": "explain big bang?" } ] }'`; const { copy: copyToClipboard } = useCopyToClipboard(); if (isLoading) { return
Loading...
; } if (!isAuthConfigure) { return (

To generate API keys, you need to set up admin username and password first.{" "} Configure Security Settings .

Once generated you will need to use this API key for all API calls to the Bifrost admin APIs and UI.

); } const isInferenceAuthDisabled = bifrostConfig?.auth_config?.disable_auth_on_inference ?? false; return (

{isInferenceAuthDisabled ? ( <> Authentication is currently disabled for inference API calls. You can make inference requests without authentication. Dashboard and admin API calls still require Basic auth with your admin credentials encoded in the standard{" "} username:password format with base64 encoding. ) : ( <> Use Basic auth with your admin credentials when making API calls to Bifrost. Encode your credentials in the standard{" "} username:password format with base64 encoding. )}

{!isInferenceAuthDisabled && ( <>

Example:

{curlExample}
)}
} title="Scope Based API Keys" description="Need granular access control with scope-based API keys? Enterprise customers can create multiple API keys with specific permissions for different services, teams, or environments." readmeLink="https://docs.getbifrost.io/enterprise/api-keys" />
); }