Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(web): guide users to add other models in LLM connection form (#14405)

Jannik Maierhöferd0128007073d
diff --git a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
index 795ee7f586..10527b1435 100644
--- a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
+++ b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
@@ -48,6 +48,13 @@ import {
const isLangfuseCloud = Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION);
+/**
+ * UI-only sentinel value for the adapter dropdown. Selecting it does not set a
+ * real adapter; instead it surfaces guidance that any OpenAI-compatible
+ * provider can be added through one of the existing adapters.
+ */
+const OTHER_MODEL_OPTION = "other-model";
+
const isCustomModelsRequired = (adapter: LLMAdapter) =>
adapter === LLMAdapter.Azure || adapter === LLMAdapter.Bedrock;
@@ -260,6 +267,10 @@ export function CreateLLMApiKeyForm({
existingKey,
}: CreateLLMApiKeyFormProps) {
const [showAdvancedSettings, setShowAdvancedSettings] = useState(false);
+ // When the "Other model" option is selected we hide the form fields and show
+ // guidance instead. This is purely UI state and never reaches the form value.
+ const [showOtherModelInfo, setShowOtherModelInfo] = useState(false);
+ const [adapterSelectOpen, setAdapterSelectOpen] = useState(false);
const utils = api.useUtils();
const capture = usePostHogClientCapture();
@@ -674,13 +685,27 @@ export function CreateLLMApiKeyForm({
Schema that is accepted at that provider endpoint.
</FormDescription>
<Select
- defaultValue={field.value}
+ open={adapterSelectOpen}
+ onOpenChange={setAdapterSelectOpen}
+ value={showOtherModelInfo ? OTHER_MODEL_OPTION : field.value}
onValueChange={(value) => {
+ if (value === OTHER_MODEL_OPTION) {
+ setShowOtherModelInfo(true);
+ return;
+ }
+ setShowOtherModelInfo(false);
+ // Only reset the base URL when the adapter actually
+ // changes. Bouncing through the "other model" sentinel and
+ // back to the same adapter looks like a value change to
+ // Radix, but must not wipe a custom base URL the user
+ // already entered.
+ if (value !== field.value) {
+ form.setValue(
+ "baseURL",
+ getCustomizedBaseURL(value as LLMAdapter),
+ );
+ }
field.onChange(value as LLMAdapter);
- form.setValue(
- "baseURL",
- getCustomizedBaseURL(value as LLMAdapter),
- );
}}
disabled={isFieldDisabled("adapter")}
>
@@ -695,211 +720,106 @@ export function CreateLLMApiKeyForm({
{provider}
</SelectItem>
))}
+ {mode === "create" && (
+ <SelectItem value={OTHER_MODEL_OPTION}>
+ other model
+ </SelectItem>
+ )}
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
- {/* Provider name */}
- <FormField
- control={form.control}
- name="provider"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Provider name</FormLabel>
- <FormDescription>
- Key to identify the connection within Langfuse. Cannot contain
- colons.
- </FormDescription>
- <FormControl>
- <Input
- {...field}
- placeholder={`e.g. ${currentAdapter}`}
- disabled={isFieldDisabled("provider")}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- {/* API Key or AWS Credentials or Vertex AI Credentials */}
- {currentAdapter === LLMAdapter.Bedrock ? (
+ {showOtherModelInfo && (
+ <div className="bg-muted/40 text-muted-foreground space-y-2 rounded-md border p-4 text-sm">
+ <p>
+ You can use any model provider as LLM connection that supports
+ one of the adapters in the list. Many providers support the
+ OpenAI API schema, such as Z.ai, OpenRouter, Qwen, Mistral,
+ Hugging Face, and more. Just replace the API Base URL with the
+ endpoint for the model, and add your provider&apos;s custom
+ model names and api key.
+ </p>
+ <p>
+ <a
+ href="https://langfuse.com/docs/administration/llm-connection#supported-providers"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-600 underline hover:text-blue-800"
+ >
+ Learn more about supported providers
+ </a>
+ </p>
+ </div>
+ )}
+
+ {!showOtherModelInfo && (
<>
+ {/* Provider name */}
<FormField
control={form.control}
- name="authMethod"
+ name="provider"
render={({ field }) => (
<FormItem>
- <FormLabel>Authentication Method</FormLabel>
+ <FormLabel>Provider name</FormLabel>
<FormDescription>
- Select how Langfuse should authenticate to Bedrock.
- </FormDescription>
- <FormControl>
- <Tabs
- value={field.value}
- onValueChange={(value) =>
- field.onChange(value as BedrockAuthMethod)
- }
- className="w-full"
- >
- <TabsList
- className={cn(
- "grid h-auto w-full gap-1",
- "grid-cols-2",
- )}
- >
- <TabsTrigger
- value={AuthMethod.AccessKeys}
- className="text-xs"
- >
- AWS access keys
- </TabsTrigger>
- <TabsTrigger
- value={AuthMethod.ApiKey}
- className="text-xs"
- >
- API key
- </TabsTrigger>
- </TabsList>
- </Tabs>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="awsRegion"
- render={({ field }) => (
- <FormItem>
- <FormLabel>AWS Region</FormLabel>
- <FormDescription>
- {mode === "update" &&
- existingKey?.config &&
- (existingKey.config as BedrockConfig).region && (
- <span className="text-sm">
- Current:{" "}
- <code className="bg-muted rounded px-1 py-0.5">
- {(existingKey.config as BedrockConfig).region}
- </code>
- </span>
- )}
+ Key to identify the connection within Langfuse. Cannot
+ contain colons.
</FormDescription>
<FormControl>
<Input
{...field}
- placeholder={
- mode === "update" && existingKey?.config
- ? ((existingKey.config as BedrockConfig).region ??
- "")
- : "e.g., us-east-1"
- }
- data-1p-ignore
+ placeholder={`e.g. ${currentAdapter}`}
+ disabled={isFieldDisabled("provider")}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
- {currentAuthMethod === AuthMethod.ApiKey && (
- <FormField
- control={form.control}
- name="bedrockApiKey"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Bedrock API Key</FormLabel>
- <FormDescription>
- {mode === "update" ? (
- <>
- Use{" "}
- <a
- href="https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html"
- target="_blank"
- rel="noopener noreferrer"
- className="text-blue-600 underline hover:text-blue-800"
- >
- Amazon Bedrock API keys
- </a>{" "}
- to replace the current authentication.
- </>
- ) : (
- <>
- Use{" "}
- <a
- href="https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html"
- target="_blank"
- rel="noopener noreferrer"
- className="text-blue-600 underline hover:text-blue-800"
- >
- Amazon Bedrock API keys
- </a>
- .
- </>
- )}
- </FormDescription>
- <FormControl>
- <Input
- {...field}
- type="password"
- placeholder={
- mode === "update"
- ? isKeepingCurrentBedrockAuthMethod &&
- existingKey?.displaySecretKey
- ? `${existingKey.displaySecretKey} (preserved unless replaced)`
- : "Enter Bedrock API key"
- : undefined
- }
- autoComplete="new-password"
- data-1p-ignore
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
- {currentAuthMethod === AuthMethod.AccessKeys && (
+
+ {/* API Key or AWS Credentials or Vertex AI Credentials */}
+ {currentAdapter === LLMAdapter.Bedrock ? (
<>
<FormField
control={form.control}
- name="awsAccessKeyId"
+ name="authMethod"
render={({ field }) => (
<FormItem>
- <FormLabel>
- AWS Access Key ID
- {!isLangfuseCloud && (
- <span className="text-muted-foreground font-normal">
- {" "}
- (optional)
- </span>
- )}
- </FormLabel>
+ <FormLabel>Authentication Method</FormLabel>
<FormDescription>
- {mode === "update"
- ? isKeepingCurrentBedrockAuthMethod
- ? "Leave empty to keep existing credentials. To update, provide both Access Key ID and Secret Access Key."
- : "Provide both Access Key ID and Secret Access Key."
- : isLangfuseCloud
- ? "These should be long-lived credentials for an AWS user with `bedrock:InvokeModel` permission."
- : "For self-hosted deployments, AWS credentials are optional. When omitted, authentication will use the AWS SDK default credential provider chain."}
+ Select how Langfuse should authenticate to Bedrock.
</FormDescription>
<FormControl>
- <Input
- {...field}
- placeholder={
- mode === "update"
- ? isUsingDefaultAwsCredentialsForCurrentAuthMethod
- ? "Using default AWS credentials"
- : isKeepingCurrentBedrockAuthMethod
- ? "•••••••• (existing credentials preserved if empty)"
- : "Enter AWS access key ID"
- : undefined
+ <Tabs
+ value={field.value}
+ onValueChange={(value) =>
+ field.onChange(value as BedrockAuthMethod)
}
- autoComplete="off"
- data-1p-ignore
- />
+ className="w-full"
+ >
+ <TabsList
+ className={cn(
+ "grid h-auto w-full gap-1",
+ "grid-cols-2",
+ )}
+ >
+ <TabsTrigger
+ value={AuthMethod.AccessKeys}
+ className="text-xs"
+ >
+ AWS access keys
+ </TabsTrigger>
+ <TabsTrigger
+ value={AuthMethod.ApiKey}
+ className="text-xs"
+ >
+ API key
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
</FormControl>
<FormMessage />
</FormItem>
@@ -907,33 +827,31 @@ export function CreateLLMApiKeyForm({
/>
<FormField
control={form.control}
- name="awsSecretAccessKey"
+ name="awsRegion"
render={({ field }) => (
<FormItem>
- <FormLabel>
- AWS Secret Access Key
- {!isLangfuseCloud && (
- <span className="text-muted-foreground font-normal">
- {" "}
- (optional)
- </span>
- )}
- </FormLabel>
+ <FormLabel>AWS Region</FormLabel>
+ <FormDescription>
+ {mode === "update" &&
+ existingKey?.config &&
+ (existingKey.config as BedrockConfig).region && (
+ <span className="text-sm">
+ Current:{" "}
+ <code className="bg-muted rounded px-1 py-0.5">
+ {(existingKey.config as BedrockConfig).region}
+ </code>
+ </span>
+ )}
+ </FormDescription>
<FormControl>
<Input
{...field}
- type="password"
placeholder={
- mode === "update"
- ? isUsingDefaultAwsCredentialsForCurrentAuthMethod
- ? "Using default AWS credentials"
- : isKeepingCurrentBedrockAuthMethod &&
- existingKey?.displaySecretKey
- ? `${existingKey.displaySecretKey} (preserved if empty)`
- : "Enter AWS secret access key"
- : undefined
+ mode === "update" && existingKey?.config
+ ? ((existingKey.config as BedrockConfig)
+ .region ?? "")
+ : "e.g., us-east-1"
}
- autoComplete="new-password"
data-1p-ignore
/>
</FormControl>
@@ -941,97 +859,235 @@ export function CreateLLMApiKeyForm({
</FormItem>
)}
/>
- </>
- )}
- {!isLangfuseCloud &&
- currentAuthMethod === AuthMethod.AccessKeys && (
- <div className="text-muted-foreground space-y-2 border-l-2 border-blue-200 pl-4 text-sm">
- <p>
- <strong>Default credential provider chain:</strong> When
- AWS credentials are omitted, the system will automatically
- check for credentials in this order:
- </p>
- <ul className="ml-2 list-inside list-disc space-y-1">
- <li>
- Environment variables (AWS_ACCESS_KEY_ID,
- AWS_SECRET_ACCESS_KEY)
- </li>
- <li>AWS credentials file (~/.aws/credentials)</li>
- <li>IAM roles for EC2 instances</li>
- <li>IAM roles for ECS tasks</li>
- </ul>
- <p>
- <a
- href="https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html"
- target="_blank"
- rel="noopener noreferrer"
- className="text-blue-600 underline hover:text-blue-800"
- >
- Learn more about AWS credential providers →
- </a>
- </p>
- </div>
- )}
- </>
- ) : currentAdapter === LLMAdapter.VertexAI ? (
- <>
- {/* Vertex AI ADC option for self-hosted only, create mode only */}
- {!isLangfuseCloud && mode === "create" && (
- <FormItem>
- <span className="row flex">
- <span className="flex-1">
- <FormLabel>
- Use Application Default Credentials (ADC)
- </FormLabel>
- <FormDescription>
- When enabled, authentication uses the GCP
- environment&apos;s default credentials instead of a
- service account key.
- </FormDescription>
- </span>
- <FormControl>
- <Switch
- checked={
- form.watch("secretKey") ===
- VERTEXAI_USE_DEFAULT_CREDENTIALS
- }
- onCheckedChange={(checked) => {
- if (checked) {
- form.setValue(
- "secretKey",
- VERTEXAI_USE_DEFAULT_CREDENTIALS,
- );
- } else {
- form.setValue("secretKey", "");
- }
- }}
+ {currentAuthMethod === AuthMethod.ApiKey && (
+ <FormField
+ control={form.control}
+ name="bedrockApiKey"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Bedrock API Key</FormLabel>
+ <FormDescription>
+ {mode === "update" ? (
+ <>
+ Use{" "}
+ <a
+ href="https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-600 underline hover:text-blue-800"
+ >
+ Amazon Bedrock API keys
+ </a>{" "}
+ to replace the current authentication.
+ </>
+ ) : (
+ <>
+ Use{" "}
+ <a
+ href="https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-600 underline hover:text-blue-800"
+ >
+ Amazon Bedrock API keys
+ </a>
+ .
+ </>
+ )}
+ </FormDescription>
+ <FormControl>
+ <Input
+ {...field}
+ type="password"
+ placeholder={
+ mode === "update"
+ ? isKeepingCurrentBedrockAuthMethod &&
+ existingKey?.displaySecretKey
+ ? `${existingKey.displaySecretKey} (preserved unless replaced)`
+ : "Enter Bedrock API key"
+ : undefined
+ }
+ autoComplete="new-password"
+ data-1p-ignore
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ )}
+ {currentAuthMethod === AuthMethod.AccessKeys && (
+ <>
+ <FormField
+ control={form.control}
+ name="awsAccessKeyId"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>
+ AWS Access Key ID
+ {!isLangfuseCloud && (
+ <span className="text-muted-foreground font-normal">
+ {" "}
+ (optional)
+ </span>
+ )}
+ </FormLabel>
+ <FormDescription>
+ {mode === "update"
+ ? isKeepingCurrentBedrockAuthMethod
+ ? "Leave empty to keep existing credentials. To update, provide both Access Key ID and Secret Access Key."
+ : "Provide both Access Key ID and Secret Access Key."
+ : isLangfuseCloud
+ ? "These should be long-lived credentials for an AWS user with `bedrock:InvokeModel` permission."
+ : "For self-hosted deployments, AWS credentials are optional. When omitted, authentication will use the AWS SDK default credential provider chain."}
+ </FormDescription>
+ <FormControl>
+ <Input
+ {...field}
+ placeholder={
+ mode === "update"
+ ? isUsingDefaultAwsCredentialsForCurrentAuthMethod
+ ? "Using default AWS credentials"
+ : isKeepingCurrentBedrockAuthMethod
+ ? "•••••••• (existing credentials preserved if empty)"
+ : "Enter AWS access key ID"
+ : undefined
+ }
+ autoComplete="off"
+ data-1p-ignore
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
/>
- </FormControl>
- </span>
- </FormItem>
- )}
-
- {/* Service Account Key - hidden when ADC is enabled */}
- {(isLangfuseCloud ||
- form.watch("secretKey") !==
- VERTEXAI_USE_DEFAULT_CREDENTIALS) && (
- <FormField
- control={form.control}
- name="secretKey"
- render={({ field }) => (
+ <FormField
+ control={form.control}
+ name="awsSecretAccessKey"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>
+ AWS Secret Access Key
+ {!isLangfuseCloud && (
+ <span className="text-muted-foreground font-normal">
+ {" "}
+ (optional)
+ </span>
+ )}
+ </FormLabel>
+ <FormControl>
+ <Input
+ {...field}
+ type="password"
+ placeholder={
+ mode === "update"
+ ? isUsingDefaultAwsCredentialsForCurrentAuthMethod
+ ? "Using default AWS credentials"
+ : isKeepingCurrentBedrockAuthMethod &&
+ existingKey?.displaySecretKey
+ ? `${existingKey.displaySecretKey} (preserved if empty)`
+ : "Enter AWS secret access key"
+ : undefined
+ }
+ autoComplete="new-password"
+ data-1p-ignore
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </>
+ )}
+ {!isLangfuseCloud &&
+ currentAuthMethod === AuthMethod.AccessKeys && (
+ <div className="text-muted-foreground space-y-2 border-l-2 border-blue-200 pl-4 text-sm">
+ <p>
+ <strong>Default credential provider chain:</strong>{" "}
+ When AWS credentials are omitted, the system will
+ automatically check for credentials in this order:
+ </p>
+ <ul className="ml-2 list-inside list-disc space-y-1">
+ <li>
+ Environment variables (AWS_ACCESS_KEY_ID,
+ AWS_SECRET_ACCESS_KEY)
+ </li>
+ <li>AWS credentials file (~/.aws/credentials)</li>
+ <li>IAM roles for EC2 instances</li>
+ <li>IAM roles for ECS tasks</li>
+ </ul>
+ <p>
+ <a
+ href="https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-600 underline hover:text-blue-800"
+ >
+ Learn more about AWS credential providers →
+ </a>
+ </p>
+ </div>
+ )}
+ </>
+ ) : currentAdapter === LLMAdapter.VertexAI ? (
+ <>
+ {/* Vertex AI ADC option for self-hosted only, create mode only */}
+ {!isLangfuseCloud && mode === "create" && (
<FormItem>
- <FormLabel>GCP Service Account Key (JSON)</FormLabel>
- <FormDescription>
- {isLangfuseCloud
- ? "Your API keys are stored encrypted on our servers."
- : "Your API keys are stored encrypted in your database."}
- </FormDescription>
- <FormDescription className="text-dark-yellow">
- Paste your GCP service account JSON key here. The
- service account must have `Vertex AI User` role
- permissions. Example JSON:
- <pre className="text-xs">
- {`{
+ <span className="row flex">
+ <span className="flex-1">
+ <FormLabel>
+ Use Application Default Credentials (ADC)
+ </FormLabel>
+ <FormDescription>
+ When enabled, authentication uses the GCP
+ environment&apos;s default credentials instead of a
+ service account key.
+ </FormDescription>
+ </span>
+ <FormControl>
+ <Switch
+ checked={
+ form.watch("secretKey") ===
+ VERTEXAI_USE_DEFAULT_CREDENTIALS
+ }
+ onCheckedChange={(checked) => {
+ if (checked) {
+ form.setValue(
+ "secretKey",
+ VERTEXAI_USE_DEFAULT_CREDENTIALS,
+ );
+ } else {
+ form.setValue("secretKey", "");
+ }
+ }}
+ />
+ </FormControl>
+ </span>
+ </FormItem>
+ )}
+
+ {/* Service Account Key - hidden when ADC is enabled */}
+ {(isLangfuseCloud ||
+ form.watch("secretKey") !==
+ VERTEXAI_USE_DEFAULT_CREDENTIALS) && (
+ <FormField
+ control={form.control}
+ name="secretKey"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>GCP Service Account Key (JSON)</FormLabel>
+ <FormDescription>
+ {isLangfuseCloud
+ ? "Your API keys are stored encrypted on our servers."
+ : "Your API keys are stored encrypted in your database."}
+ </FormDescription>
+ <FormDescription className="text-dark-yellow">
+ Paste your GCP service account JSON key here. The
+ service account must have `Vertex AI User` role
+ permissions. Example JSON:
+ <pre className="text-xs">
+ {`{
"type": "service_account",
"project_id": "<project_id>",
"private_key_id": "<private_key_id>",
@@ -1043,7 +1099,79 @@ export function CreateLLMApiKeyForm({
"auth_provider_x509_cert_url": "<auth_provider_x509_cert_url>",
"client_x509_cert_url": "<client_x509_cert_url>",
}`}
- </pre>
+ </pre>
+ </FormDescription>
+ <FormControl>
+ <Input
+ {...field}
+ placeholder={
+ mode === "update"
+ ? existingKey?.displaySecretKey
+ : '{"type": "service_account", ...}'
+ }
+ autoComplete="off"
+ spellCheck="false"
+ autoCapitalize="off"
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ )}
+
+ {/* ADC info box for self-hosted */}
+ {!isLangfuseCloud &&
+ form.watch("secretKey") ===
+ VERTEXAI_USE_DEFAULT_CREDENTIALS && (
+ <div className="text-muted-foreground space-y-2 border-l-2 border-blue-200 pl-4 text-sm">
+ <p>
+ <strong>
+ Application Default Credentials (ADC):
+ </strong>{" "}
+ When enabled, the system will automatically check for
+ credentials in this order:
+ </p>
+ <ul className="ml-2 list-inside list-disc space-y-1">
+ <li>
+ Environment variable
+ (GOOGLE_APPLICATION_CREDENTIALS)
+ </li>
+ <li>
+ gcloud CLI credentials (gcloud auth
+ application-default login)
+ </li>
+ <li>GKE Workload Identity</li>
+ <li>Cloud Run service account</li>
+ <li>
+ GCE instance service account (metadata service)
+ </li>
+ </ul>
+ <p>
+ <a
+ href="https://cloud.google.com/docs/authentication/application-default-credentials"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-600 underline hover:text-blue-800"
+ >
+ Learn more about GCP Application Default Credentials
+ →
+ </a>
+ </p>
+ </div>
+ )}
+ </>
+ ) : (
+ <FormField
+ control={form.control}
+ name="secretKey"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>API Key</FormLabel>
+ <FormDescription>
+ {isLangfuseCloud
+ ? "Your API keys are stored encrypted on our servers."
+ : "Your API keys are stored encrypted in your database."}
</FormDescription>
<FormControl>
<Input
@@ -1051,7 +1179,7 @@ export function CreateLLMApiKeyForm({
placeholder={
mode === "update"
? existingKey?.displaySecretKey
- : '{"type": "service_account", ...}'
+ : undefined
}
autoComplete="off"
spellCheck="false"
@@ -1064,172 +1192,24 @@ export function CreateLLMApiKeyForm({
/>
)}
- {/* ADC info box for self-hosted */}
- {!isLangfuseCloud &&
- form.watch("secretKey") ===
- VERTEXAI_USE_DEFAULT_CREDENTIALS && (
- <div className="text-muted-foreground space-y-2 border-l-2 border-blue-200 pl-4 text-sm">
- <p>
- <strong>Application Default Credentials (ADC):</strong>{" "}
- When enabled, the system will automatically check for
- credentials in this order:
- </p>
- <ul className="ml-2 list-inside list-disc space-y-1">
- <li>
- Environment variable (GOOGLE_APPLICATION_CREDENTIALS)
- </li>
- <li>
- gcloud CLI credentials (gcloud auth application-default
- login)
- </li>
- <li>GKE Workload Identity</li>
- <li>Cloud Run service account</li>
- <li>GCE instance service account (metadata service)</li>
- </ul>
- <p>
- <a
- href="https://cloud.google.com/docs/authentication/application-default-credentials"
- target="_blank"
- rel="noopener noreferrer"
- className="text-blue-600 underline hover:text-blue-800"
- >
- Learn more about GCP Application Default Credentials →
- </a>
- </p>
- </div>
- )}
- </>
- ) : (
- <FormField
- control={form.control}
- name="secretKey"
- render={({ field }) => (
- <FormItem>
- <FormLabel>API Key</FormLabel>
- <FormDescription>
- {isLangfuseCloud
- ? "Your API keys are stored encrypted on our servers."
- : "Your API keys are stored encrypted in your database."}
- </FormDescription>
- <FormControl>
- <Input
- {...field}
- placeholder={
- mode === "update"
- ? existingKey?.displaySecretKey
- : undefined
- }
- autoComplete="off"
- spellCheck="false"
- autoCapitalize="off"
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
-
- {/* Azure Base URL - Always required for Azure */}
- {currentAdapter === LLMAdapter.Azure && (
- <FormField
- control={form.control}
- name="baseURL"
- render={({ field }) => (
- <FormItem>
- <FormLabel>API Base URL</FormLabel>
- <FormDescription>
- Please add the base URL in the following format (or
- compatible API):
- https://&#123;instanceName&#125;.openai.azure.com/openai/deployments
- </FormDescription>
- <FormControl>
- <Input
- {...field}
- placeholder="https://your-instance.openai.azure.com/openai/deployments"
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
-
- {/* Custom models: top-level for Azure/Bedrock */}
- {isCustomModelsRequired(currentAdapter) && renderCustomModelsField()}
-
- {/* Extra headers - show for Azure in main section (Azure has no advanced settings) */}
- {currentAdapter === LLMAdapter.Azure && renderExtraHeadersField()}
-
- {hasAdvancedSettings(currentAdapter) && (
- <div className="flex items-center">
- <Button
- type="button"
- variant="link"
- size="sm"
- className="flex items-center pl-0"
- onClick={() => setShowAdvancedSettings(!showAdvancedSettings)}
- >
- <span>
- {showAdvancedSettings
- ? "Hide advanced settings"
- : "Show advanced settings"}
- </span>
- <ChevronDown
- className={`ml-1 h-4 w-4 transition-transform ${showAdvancedSettings ? "rotate-180" : "rotate-0"}`}
- />
- </Button>
- </div>
- )}
-
- {hasAdvancedSettings(currentAdapter) && showAdvancedSettings && (
- <div className="space-y-4 border-t pt-4">
- {/* baseURL */}
- <FormField
- control={form.control}
- name="baseURL"
- render={({ field }) => (
- <FormItem>
- <FormLabel>API Base URL</FormLabel>
- <FormDescription>
- Leave blank to use the default base URL for the given LLM
- adapter.{" "}
- {currentAdapter === LLMAdapter.OpenAI && (
- <span>OpenAI default: https://api.openai.com/v1</span>
- )}
- {currentAdapter === LLMAdapter.Anthropic && (
- <span>
- Anthropic default: https://api.anthropic.com
- (excluding /v1/messages)
- </span>
- )}
- </FormDescription>
-
- <FormControl>
- <Input {...field} placeholder="default" />
- </FormControl>
-
- <FormMessage />
- </FormItem>
- )}
- />
-
- {/* VertexAI Location */}
- {currentAdapter === LLMAdapter.VertexAI && (
+ {/* Azure Base URL - Always required for Azure */}
+ {currentAdapter === LLMAdapter.Azure && (
<FormField
control={form.control}
- name="vertexAILocation"
+ name="baseURL"
render={({ field }) => (
<FormItem>
- <FormLabel>Location (Optional)</FormLabel>
+ <FormLabel>API Base URL</FormLabel>
<FormDescription>
- Google Cloud region (e.g., global, us-central1,
- europe-west4). Defaults to{" "}
- <span className="font-medium">global</span> as required
- for Gemini 3 models.
+ Please add the base URL in the following format (or
+ compatible API):
+ https://&#123;instanceName&#125;.openai.azure.com/openai/deployments
</FormDescription>
<FormControl>
- <Input {...field} placeholder="global" />
+ <Input
+ {...field}
+ placeholder="https://your-instance.openai.azure.com/openai/deployments"
+ />
</FormControl>
<FormMessage />
</FormItem>
@@ -1237,85 +1217,184 @@ export function CreateLLMApiKeyForm({
/>
)}
- {/* OpenAI Responses API */}
- {currentAdapter === LLMAdapter.OpenAI && (
- <FormField
- control={form.control}
- name="openAIUseResponsesApi"
- render={({ field }) => (
- <FormItem>
- <span className="row flex">
- <span className="flex-1">
- <FormLabel>Use Responses API</FormLabel>
- <FormDescription>
- Route OpenAI requests through the Responses API
- instead of Chat Completions.
- </FormDescription>
- </span>
+ {/* Custom models: top-level for Azure/Bedrock */}
+ {isCustomModelsRequired(currentAdapter) &&
+ renderCustomModelsField()}
+
+ {/* Extra headers - show for Azure in main section (Azure has no advanced settings) */}
+ {currentAdapter === LLMAdapter.Azure && renderExtraHeadersField()}
+
+ {hasAdvancedSettings(currentAdapter) && (
+ <div className="flex items-center">
+ <Button
+ type="button"
+ variant="link"
+ size="sm"
+ className="flex items-center pl-0"
+ onClick={() =>
+ setShowAdvancedSettings(!showAdvancedSettings)
+ }
+ >
+ <span>
+ {showAdvancedSettings
+ ? "Hide advanced settings"
+ : "Show advanced settings"}
+ </span>
+ <ChevronDown
+ className={`ml-1 h-4 w-4 transition-transform ${showAdvancedSettings ? "rotate-180" : "rotate-0"}`}
+ />
+ </Button>
+ </div>
+ )}
+
+ {hasAdvancedSettings(currentAdapter) && showAdvancedSettings && (
+ <div className="space-y-4 border-t pt-4">
+ {/* baseURL */}
+ <FormField
+ control={form.control}
+ name="baseURL"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>API Base URL</FormLabel>
+ <FormDescription>
+ Leave blank to use the default base URL for the given
+ LLM adapter.{" "}
+ {currentAdapter === LLMAdapter.OpenAI && (
+ <span>
+ OpenAI default: https://api.openai.com/v1
+ </span>
+ )}
+ {currentAdapter === LLMAdapter.Anthropic && (
+ <span>
+ Anthropic default: https://api.anthropic.com
+ (excluding /v1/messages)
+ </span>
+ )}
+ </FormDescription>
<FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
+ <Input {...field} placeholder="default" />
</FormControl>
- </span>
- <FormMessage />
- </FormItem>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ {/* VertexAI Location */}
+ {currentAdapter === LLMAdapter.VertexAI && (
+ <FormField
+ control={form.control}
+ name="vertexAILocation"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Location (Optional)</FormLabel>
+ <FormDescription>
+ Google Cloud region (e.g., global, us-central1,
+ europe-west4). Defaults to{" "}
+ <span className="font-medium">global</span> as
+ required for Gemini 3 models.
+ </FormDescription>
+ <FormControl>
+ <Input {...field} placeholder="global" />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
)}
- />
- )}
- {/* Extra Headers */}
- {[LLMAdapter.OpenAI, LLMAdapter.Anthropic].includes(
- currentAdapter,
- ) && renderExtraHeadersField()}
+ {/* OpenAI Responses API */}
+ {currentAdapter === LLMAdapter.OpenAI && (
+ <FormField
+ control={form.control}
+ name="openAIUseResponsesApi"
+ render={({ field }) => (
+ <FormItem>
+ <span className="row flex">
+ <span className="flex-1">
+ <FormLabel>Use Responses API</FormLabel>
+ <FormDescription>
+ Route OpenAI requests through the Responses API
+ instead of Chat Completions.
+ </FormDescription>
+ </span>
- {/* With default models */}
- <FormField
- control={form.control}
- name="withDefaultModels"
- render={({ field }) => (
- <FormItem>
- <span className="row flex">
- <span className="flex-1">
- <FormLabel>Enable default models</FormLabel>
- <FormDescription>
- Default models for the selected adapter will be
- available in Langfuse features.
- </FormDescription>
- </span>
+ <FormControl>
+ <Switch
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ </FormControl>
+ </span>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </span>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ )}
- <FormMessage />
- </FormItem>
- )}
- />
+ {/* Extra Headers */}
+ {[LLMAdapter.OpenAI, LLMAdapter.Anthropic].includes(
+ currentAdapter,
+ ) && renderExtraHeadersField()}
- {/* Custom model names */}
- {!isCustomModelsRequired(currentAdapter) &&
- renderCustomModelsField()}
- </div>
+ {/* With default models */}
+ <FormField
+ control={form.control}
+ name="withDefaultModels"
+ render={({ field }) => (
+ <FormItem>
+ <span className="row flex">
+ <span className="flex-1">
+ <FormLabel>Enable default models</FormLabel>
+ <FormDescription>
+ Default models for the selected adapter will be
+ available in Langfuse features.
+ </FormDescription>
+ </span>
+
+ <FormControl>
+ <Switch
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ </FormControl>
+ </span>
+
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ {/* Custom model names */}
+ {!isCustomModelsRequired(currentAdapter) &&
+ renderCustomModelsField()}
+ </div>
+ )}
+ </>
)}
</DialogBody>
<DialogFooter>
<div className="flex flex-col gap-4">
- <Button
- type="submit"
- className="w-full"
- loading={form.formState.isSubmitting}
- >
- {mode === "create" ? "Create connection" : "Save changes"}
- </Button>
+ {showOtherModelInfo ? (
+ <Button
+ type="button"
+ className="w-full"
+ onClick={() => setAdapterSelectOpen(true)}
+ >
+ Select an adapter
+ </Button>
+ ) : (
+ <Button
+ type="submit"
+ className="w-full"
+ loading={form.formState.isSubmitting}
+ >
+ {mode === "create" ? "Create connection" : "Save changes"}
+ </Button>
+ )}
{form.formState.errors.root && (
<FormMessage>{form.formState.errors.root.message}</FormMessage>
)}