Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(providers): support custom endpoints without API keys

vastsa76c4afaff8d7
diff --git a/apps/desktop/src/components/settings/PluginProviderKeySetupForm.tsx b/apps/desktop/src/components/settings/PluginProviderKeySetupForm.tsx
index 38eb47443..93e089974 100644
--- a/apps/desktop/src/components/settings/PluginProviderKeySetupForm.tsx
+++ b/apps/desktop/src/components/settings/PluginProviderKeySetupForm.tsx
@@ -106,6 +106,8 @@ export function PluginProviderKeySetupForm({
nameRef={nameRef}
apiKey={apiKey}
onApiKeyChange={setApiKey}
+ authKind="api_key_and_base_url"
+ onAuthKindChange={() => {}}
name={provider.name}
onNameChange={() => {}}
baseUrl={provider.baseUrl ?? ""}
diff --git a/apps/desktop/src/components/settings/ProviderConnectionFields.tsx b/apps/desktop/src/components/settings/ProviderConnectionFields.tsx
index 5b3e81f9f..15808f43d 100644
--- a/apps/desktop/src/components/settings/ProviderConnectionFields.tsx
+++ b/apps/desktop/src/components/settings/ProviderConnectionFields.tsx
@@ -1,6 +1,6 @@
/**
* The connection half of the AI service form: which service, its key, and for
- * a custom endpoint the name, URL and API format (D310, D625).
+ * a custom endpoint the name, URL, authentication and API format (D310, D625).
*
* The chosen service reads as a settled fact with a Change action rather than
* an open menu. Whether the service answered is announced by the probe itself
@@ -10,12 +10,14 @@
import type { RefObject } from "react";
import { useTranslation } from "react-i18next";
import type { CatalogApiStyle } from "@pi-desktop/shared";
-import { Field, Input } from "../ui";
+import { Checkbox, Field, Input } from "../ui";
import { SettingsMenuSelect } from "./SettingsMenuSelect";
import { ServiceMonogram } from "./ServiceMonogram";
import { endpointLabel } from "./service-catalog";
import { API_STYLE_LABEL_KEYS, CUSTOM_PROVIDER_API_STYLES } from "./provider-api-style";
+export type ProviderAuthKind = "api_key_and_base_url" | "none";
+
export type ProviderConnectionFieldsProps = {
named: boolean;
custom: boolean;
@@ -33,6 +35,8 @@ export type ProviderConnectionFieldsProps = {
nameRef: RefObject<HTMLInputElement | null>;
apiKey: string;
onApiKeyChange: (value: string) => void;
+ authKind: ProviderAuthKind;
+ onAuthKindChange: (value: ProviderAuthKind) => void;
name: string;
onNameChange: (value: string) => void;
baseUrl: string;
@@ -61,6 +65,8 @@ export function ProviderConnectionFields({
nameRef,
apiKey,
onApiKeyChange,
+ authKind,
+ onAuthKindChange,
name,
onNameChange,
baseUrl,
@@ -165,17 +171,33 @@ export function ProviderConnectionFields({
</div>
</div>
<div className="provider-setup-field-row provider-setup-custom-auth-row">
- <Field label={t("settings.apiKey")} hint={keyHint}>
- <Input
- ref={apiKeyRef}
- type="password"
- value={apiKey}
- placeholder="sk-…"
- className="font-mono text-sm-plus"
- autoComplete="off"
- onChange={(event) => onApiKeyChange(event.target.value)}
+ <div className="provider-setup-key">
+ {authKind === "none" ? (
+ <div className="text-sm text-text-secondary">
+ {t("settings.noApiKeyRequiredHint")}
+ </div>
+ ) : (
+ <Field label={t("settings.apiKey")} hint={keyHint}>
+ <Input
+ ref={apiKeyRef}
+ type="password"
+ value={apiKey}
+ placeholder="sk-…"
+ className="font-mono text-sm-plus"
+ autoComplete="off"
+ onChange={(event) => onApiKeyChange(event.target.value)}
+ />
+ </Field>
+ )}
+ <Checkbox
+ label={t("settings.noApiKeyRequired")}
+ checked={authKind === "none"}
+ disabled={saving}
+ onChange={(event) =>
+ onAuthKindChange(event.target.checked ? "none" : "api_key_and_base_url")
+ }
/>
- </Field>
+ </div>
<Field
label={t("settings.apiStyle")}
hint={apiStyleNote ?? (accountOnlyApiStyle ? t(requiresApiStyleChoice
diff --git a/apps/desktop/src/components/settings/ProviderSetupDialog.tsx b/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
index 169660092..a8ffb6e5e 100644
--- a/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
+++ b/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
@@ -3,9 +3,10 @@
*
* A new service opens on the service chooser; picking a tile moves to the
* form. Named services: paste a key and the recommended models are chosen as
- * soon as the service answers. Custom: name, URL, key and API format on the
- * common path. The service's own list is on the left and the models this
- * credential will run on the right, both visible from the first paint: a
+ * soon as the service answers. The custom form keeps its name, URL,
+ * authentication and API format on the common path. The service's own list is
+ * on the left and the models this credential will run on the right, both
+ * visible from the first paint: a
* recommended model is a starting point, never the only thing on screen.
*/
import { useEffect, useRef, useState } from "react";
@@ -27,7 +28,10 @@ import { Button, Field, HelpIcon, Input, portalOverlay } from "../ui";
import { ProviderHeadersEditor } from "./ProviderHeadersEditor";
import { useProviderModels } from "./useProviderModels";
import { ModelSelectionPanes, useModelSelection } from "./ModelSelectionPanes";
-import { ProviderConnectionFields } from "./ProviderConnectionFields";
+import {
+ ProviderConnectionFields,
+ type ProviderAuthKind,
+} from "./ProviderConnectionFields";
import { useProbeFeedback } from "./useProbeFeedback";
import { ServiceChooser } from "./ServiceChooser";
import { PluginProviderKeySetupForm } from "./PluginProviderKeySetupForm";
@@ -130,6 +134,10 @@ export function ProviderSetupDialog({
const [name, setName] = useState(() => initialDraft?.name ?? initialName(provider));
const [baseUrl, setBaseUrl] = useState(() => initialDraft?.baseUrl ?? initialBaseUrl(provider));
const [apiKey, setApiKey] = useState("");
+ const [authKind, setAuthKind] = useState<ProviderAuthKind>(() =>
+ provider?.authKind === "none" ? "none" : "api_key_and_base_url",
+ );
+ const [authKindTouched, setAuthKindTouched] = useState(false);
const [apiStyle, setApiStyle] = useState<CatalogApiStyle>(() =>
initialDraft?.apiStyle ?? normalizeApiStyle(provider?.apiStyle),
);
@@ -285,6 +293,10 @@ export function ProviderSetupDialog({
setApiStyleTouched(false);
const preset = NAMED_ENDPOINT_PRESETS.find((item) => item.id === next);
if (!preset) {
+ if (next !== CUSTOM_SERVICE) {
+ setAuthKind("api_key_and_base_url");
+ setAuthKindTouched(true);
+ }
if (next === CUSTOM_SERVICE && apiStyle === OPENCODE_GO_API_STYLE) {
setApiStyle("chat_completions");
}
@@ -295,6 +307,8 @@ export function ProviderSetupDialog({
if (!currentName || currentName === previous?.name) setName(preset.name);
setBaseUrl(preset.baseUrl);
setApiStyle(preset.apiStyle);
+ setAuthKind("api_key_and_base_url");
+ setAuthKindTouched(true);
focusAfterServiceChange(next);
};
@@ -388,6 +402,7 @@ export function ProviderSetupDialog({
models: persisted,
apiStyle: resolvedApiStyle,
headers,
+ ...(authKindTouched ? { authKind } : {}),
...(apiKey ? { secretValue: apiKey } : {}),
});
await onSaved(result.provider ?? provider, persisted, imageModelIdsToSave);
@@ -398,10 +413,10 @@ export function ProviderSetupDialog({
type: "openai_compatible",
protocol: "openai_compatible",
baseUrl: providerBaseUrl,
- authKind: "api_key_and_base_url",
+ authKind: custom ? authKind : "api_key_and_base_url",
defaultModelId: persisted[0]?.id,
models: persisted,
- secretValue: apiKey || undefined,
+ ...(apiKey && authKind !== "none" ? { secretValue: apiKey } : {}),
apiStyle: resolvedApiStyle,
headers,
});
@@ -507,6 +522,12 @@ export function ProviderSetupDialog({
nameRef={nameRef}
apiKey={apiKey}
onApiKeyChange={setApiKey}
+ authKind={authKind}
+ onAuthKindChange={(next) => {
+ setAuthKind(next);
+ setAuthKindTouched(true);
+ if (next === "none") setApiKey("");
+ }}
name={name}
onNameChange={setName}
baseUrl={baseUrl}
diff --git a/crates/host-core/src/providers/repository.rs b/crates/host-core/src/providers/repository.rs
index 34a450469..7dc2ed4b3 100644
--- a/crates/host-core/src/providers/repository.rs
+++ b/crates/host-core/src/providers/repository.rs
@@ -346,12 +346,19 @@ pub fn update_provider(
// OAuth credential, so reusing it here would stamp an api_key ref onto a
// provider that only ever signed in with a vendor account.
let api_key_ref = secret_ref_for_provider(&input.id);
- let mut secret_ref = secrets.has(&api_key_ref).then(|| api_key_ref.clone());
+ let effective_auth_kind = input
+ .auth_kind
+ .as_deref()
+ .unwrap_or(current.auth_kind.as_str());
+ let clear_api_key = effective_auth_kind == "none";
+ let mut secret_ref = (!clear_api_key && secrets.has(&api_key_ref)).then(|| api_key_ref.clone());
- if let Some(secret) = input.secret_value.as_ref().filter(|s| !s.is_empty()) {
- let backend = secrets.set(&api_key_ref, secret)?;
- upsert_secret_meta(db, &api_key_ref, &input.id, &backend)?;
- secret_ref = Some(api_key_ref);
+ if !clear_api_key {
+ if let Some(secret) = input.secret_value.as_ref().filter(|s| !s.is_empty()) {
+ let backend = secrets.set(&api_key_ref, secret)?;
+ upsert_secret_meta(db, &api_key_ref, &input.id, &backend)?;
+ secret_ref = Some(api_key_ref.clone());
+ }
}
// `Some(None)` clears an explicit levels override; plain `None` leaves it.
let levels_update = if input.supported_thinking_levels.is_some() {
@@ -388,6 +395,13 @@ pub fn update_provider(
None => config_json,
};
+ if clear_api_key {
+ secrets.delete(&api_key_ref)?;
+ db.conn()
+ .prepare_cached("DELETE FROM secrets_meta WHERE secret_ref = ?1")?
+ .execute(params![api_key_ref])?;
+ }
+
db.conn()
.prepare_cached(
"UPDATE providers SET
@@ -400,7 +414,7 @@ pub fn update_provider(
default_model_id = COALESCE(?7, default_model_id),
api_style = COALESCE(?8, api_style),
enabled = COALESCE(?9, enabled),
- secret_ref = COALESCE(?10, secret_ref),
+ secret_ref = CASE WHEN ?14 THEN NULL ELSE COALESCE(?10, secret_ref) END,
config_json = COALESCE(?11, config_json),
updated_at = ?12
WHERE id = ?13",
@@ -423,7 +437,8 @@ pub fn update_provider(
secret_ref,
config_json,
now_ms(),
- input.id
+ input.id,
+ clear_api_key
])?;
// A save that drops bindings also forgets their cached rows. The cache is
// the service's answer, and a model the user removed is no longer part of
diff --git a/crates/host-core/src/providers/tests.rs b/crates/host-core/src/providers/tests.rs
index 6ddf7d8d5..6e953e1fd 100644
--- a/crates/host-core/src/providers/tests.rs
+++ b/crates/host-core/src/providers/tests.rs
@@ -9,6 +9,86 @@ fn test_context() -> (tempfile::TempDir, Database, SecretStore) {
(dir, db, secrets)
}
+#[test]
+fn switching_provider_to_no_auth_clears_its_api_key() {
+ let (_dir, db, secrets) = test_context();
+ let provider = create_provider(
+ &db,
+ &secrets,
+ ProviderCreateInput {
+ name: "Custom gateway".into(),
+ vendor_key: Some("custom".into()),
+ provider_type: Some("openai_compatible".into()),
+ protocol: Some("openai_compatible".into()),
+ base_url: Some("http://127.0.0.1:11434/v1".into()),
+ auth_kind: Some("api_key_and_base_url".into()),
+ models: None,
+ default_model_id: Some("local-chat".into()),
+ secret_value: Some("fixture-api-key".into()),
+ api_style: Some("chat_completions".into()),
+ oauth_account_label: None,
+ headers: None,
+ context_window: None,
+ max_output_tokens: None,
+ temperature: None,
+ supports_reasoning: None,
+ supported_thinking_levels: None,
+ },
+ )
+ .unwrap();
+ let api_key_ref = secret_ref_for_provider(&provider.id);
+ assert!(provider.has_secret);
+ assert!(secrets.has(&api_key_ref));
+ let oauth_ref = secret_ref_for_provider_oauth(&provider.id);
+ secrets.set(&oauth_ref, "fixture-oauth-credential").unwrap();
+
+ let updated = update_provider(
+ &db,
+ &secrets,
+ ProviderUpdateInput {
+ id: provider.id.clone(),
+ name: None,
+ vendor_key: None,
+ provider_type: None,
+ protocol: None,
+ base_url: None,
+ auth_kind: Some("none".into()),
+ models: None,
+ default_model_id: None,
+ secret_value: None,
+ api_style: None,
+ oauth_account_label: None,
+ headers: None,
+ context_window: None,
+ max_output_tokens: None,
+ temperature: None,
+ supports_reasoning: None,
+ supported_thinking_levels: None,
+ enabled: None,
+ },
+ )
+ .unwrap()
+ .unwrap();
+
+ assert_eq!(updated.auth_kind, "none");
+ assert!(updated.has_secret);
+ assert!(updated.has_oauth);
+ assert!(!secrets.has(&api_key_ref));
+ assert_eq!(
+ secrets.get(&oauth_ref).unwrap().as_deref(),
+ Some("fixture-oauth-credential")
+ );
+ let stored_secret_ref: Option<String> = db
+ .conn()
+ .query_row(
+ "SELECT secret_ref FROM providers WHERE id = ?1",
+ params![provider.id],
+ |row| row.get(0),
+ )
+ .unwrap();
+ assert_eq!(stored_secret_ref, None);
+}
+
#[test]
fn reasoning_override_roundtrips_and_preserves_provider_config() {
let (_dir, db, secrets) = test_context();
diff --git a/docs/spec/03-runtime/12-provider-config-schema.md b/docs/spec/03-runtime/12-provider-config-schema.md
index 611bcfd07..ad2bf9087 100644
--- a/docs/spec/03-runtime/12-provider-config-schema.md
+++ b/docs/spec/03-runtime/12-provider-config-schema.md
@@ -695,6 +695,11 @@ The canonical DDL lives in [04-data-storage](04-data-storage.md) (D086). Summary
11. Legacy `supportedThinkingLevels`, when present, must still validate as an
array of canonical thinking levels but has no runtime effect
+User-created custom endpoints may use `authKind=none`. Updating an editable
+provider to this auth kind removes its API-key secret from the secret store and
+clears `secret_ref`; OAuth credentials use their separate lifecycle. The
+runtime sends no API-key or Authorization credential for a `none` provider.
+
## 11. Secret ref format
```text
diff --git a/docs/spec/03-runtime/13-model-catalog-and-selection.md b/docs/spec/03-runtime/13-model-catalog-and-selection.md
index c86fb024d..c84998ef4 100644
--- a/docs/spec/03-runtime/13-model-catalog-and-selection.md
+++ b/docs/spec/03-runtime/13-model-catalog-and-selection.md
@@ -24,9 +24,13 @@ entitled to it.
`ProviderSetupDialog` is a single form, not a wizard:
-- **Name**, **Base URL** and **API Key** are all on screen at once. An empty key
- when editing means “keep the stored one”; `secretValue` is only sent when the
- user typed something.
+- **Name**, **Base URL** and the applicable authentication controls are on
+ screen at once. The custom endpoint's **No API key required** checkbox is off
+ by default; checking it saves `authKind: "none"`, sends no `secretValue`, and
+ removes any previously saved API key when editing. Requests from that provider
+ omit API-key and Authorization credentials. Named service presets continue to
+ require their API key. In API-key mode, an empty key when editing means “keep
+ the stored one”; `secretValue` is only sent when the user typed something.
- The models section lists what the service returned. `useProviderModels`
debounces edits by 600 ms, guards against out-of-order replies with a
monotonic request sequence, and needs no API key so local and no-auth
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index 4008c550a..73e75c276 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -453,7 +453,11 @@ a usage tab.
and model IDs. A selection opens the Host-owned API-key form; after saving,
that provider remains in the service list and leaves the chooser.
- the add/edit dialog configures connection identity (name, endpoint, API
- style, and secret). It shrinks to the overlay on a narrow window, and a
+ style, and authentication). Custom endpoints default to API-key mode and
+ offer a **No API key required** checkbox; choosing it stores `authKind:
+ "none"` and removes any saved API key when editing. Named service presets
+ continue to use API-key authentication. The dialog shrinks to the overlay
+ on a narrow window, and a
focused credential field keeps its 2px accent ring inside the dialog
instead of clipping against the scrolling body. It then selects one or
more models from a searchable multi-select catalog. The discovered-list
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 5937efc35..f0109eef5 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -1052,6 +1052,17 @@ identify the platform validation still needed.
- **Milestone**: M2
- **Status**: Manual model-picker acceptance; chooser-to-key-form selection is covered by `apps/desktop/test/plugin-provider-catalog-user-path.test.mjs`; automated protocol smoke covers provider creation and secret handling without plaintext echo.
+#### E2E-PROVIDER-custom-endpoint-no-api-key: Configure a custom service without credentials
+
+- **Preconditions**: Isolated settings profile and a local OpenAI-compatible fixture that lists a model without credentials; no live or paid provider.
+- **Steps**: 1) Open Settings → Model configuration → Add provider → Custom endpoint. 2) Enter a name and the fixture URL; check **No API key required**. 3) Confirm model discovery succeeds without a key, select the returned model, and save. 4) Confirm the provider and model are offered by chat/default-model and subagent selectors. 5) Edit an API-key provider, select **No API key required**, save, and inspect the provider's stored auth kind and credential state. 6) Send a request through the no-auth provider fixture.
+- **Expected**: The custom form remains in API-key mode by default. The explicit no-key selection saves `authKind: "none"` without `secretValue`; editing to this mode removes the provider's existing API key. The enabled provider with `hasSecret: false` remains selectable for chat, defaults, subagents, and image generation where its model supports that operation. Runtime requests contain no API-key or Authorization credentials.
+- **Automation**: `pnpm test:e2e:provider-api-style` renders the production setup form in English and Simplified Chinese with a stubbed model-discovery/API boundary and verifies create/update payloads and chat/default/subagent selector eligibility. `pnpm --filter @pi-desktop/agent-runtime test -- provider-binding.test.ts` verifies request headers; `apps/desktop/test/image-generation-default.test.mjs` covers no-auth image-model availability; `cargo test -p host-core --locked switching_provider_to_no_auth_clears_its_api_key` verifies Host persistence and secret removal.
+- **Specs linked**: `03-runtime/11-provider-model-system.md`, `03-runtime/12-provider-config-schema.md`, `03-runtime/13-model-catalog-and-selection.md`, `04-ux/06-settings-ia.md`.
+- **Acceptance**: B (model configuration), F (provider persistence), Security.
+- **Milestone**: M2.
+- **Status**: Automated coverage uses a deterministic stub for model discovery and fetch. The full local-endpoint send flow remains available for manual acceptance; no paid provider or user profile is used.
+
#### E2E-PROVIDER-defaults-survive-an-added-provider: An added provider leaves the app defaults alone
- **Preconditions**: App running; provider A saved and set as the app default model; a second provider B serving different models; one image-capable model configured on A and another on a different service.
@@ -9752,19 +9763,19 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
| E / F / Quality — MCP server timeout override | E2E-261 |
| A — App startup | E2E-001, E2E-002, E2E-003, E2E-004, E2E-067, E2E-076, E2E-079, E2E-092, E2E-097, E2E-143, E2E-150, E2E-168, E2E-204 |
| A / C / F / Quality — Tray session navigation | E2E-TRAY-bounded-session-navigation |
-| B — Model config | E2E-005, E2E-006, E2E-007, E2E-038, E2E-050, E2E-052, E2E-055, E2E-066, E2E-080, E2E-082, E2E-102c, E2E-102d, E2E-102e, E2E-151, E2E-154, E2E-163, E2E-166, E2E-172, E2E-174, E2E-197, E2E-005G, E2E-005J, E2E-199, E2E-201, E2E-202, E2E-203, E2E-205, E2E-206, E2E-209, E2E-PLUGIN-provider-catalog-add-service |
+| B — Model config | E2E-005, E2E-PROVIDER-custom-endpoint-no-api-key, E2E-006, E2E-007, E2E-038, E2E-050, E2E-052, E2E-055, E2E-066, E2E-080, E2E-082, E2E-102c, E2E-102d, E2E-102e, E2E-151, E2E-154, E2E-163, E2E-166, E2E-172, E2E-174, E2E-197, E2E-005G, E2E-005J, E2E-199, E2E-201, E2E-202, E2E-203, E2E-205, E2E-206, E2E-209, E2E-PLUGIN-provider-catalog-add-service |
| C — Conversation & stream | E2E-CHAT-long-history-stream-keeps-responsive, E2E-CHAT-running-status-survives-output-pauses, E2E-008, E2E-008d, E2E-008e, E2E-008a, E2E-009, E2E-010, E2E-011, E2E-011a, E2E-011b, E2E-011d, E2E-011e, E2E-011g, E2E-031, E2E-040, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-052, E2E-053, E2E-054, E2E-055, E2E-059, E2E-059a, E2E-060c, E2E-060d, E2E-061, E2E-061a, E2E-062, E2E-064, E2E-065, E2E-068, E2E-071, E2E-073, E2E-074, E2E-075, E2E-081, E2E-083, E2E-084, E2E-086, E2E-087, E2E-088, E2E-088b, E2E-089, E2E-090, E2E-COMPOSER-narrow-controls, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-106, E2E-109, E2E-111, E2E-114, E2E-116, E2E-117, E2E-118, E2E-119, E2E-120, E2E-121, E2E-218, E2E-259, E2E-219, E2E-AGENTS-001, E2E-142, E2E-144, E2E-145, E2E-146, E2E-146a, E2E-147, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-161, E2E-162, E2E-166, E2E-172, E2E-173, E2E-174, E2E-177, E2E-178, E2E-179, E2E-180, E2E-182, E2E-183, E2E-187, E2E-198, E2E-199, E2E-202, E2E-203, E2E-207, E2E-208, E2E-CHAT-content-width-handles, E2E-250, E2E-102i, E2E-PLUGIN-session-orchestrator-real-workers, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-SUBAGENT-resume-a-settled-delegation |
| C — Conversation & stream (composer drafts) | E2E-011c, E2E-011c-1 |
| D — Workspace | E2E-012, E2E-013, E2E-022B, E2E-024I, E2E-047, E2E-049, E2E-057, E2E-058, E2E-060, E2E-068, E2E-075, E2E-078, E2E-153, E2E-158, E2E-182, E2E-187, E2E-252 |
| C / D / Quality — Project session history resets after collapse | E2E-263 |
| D — Workspace (project ordering) | E2E-253 |
| E — Tools & permissions | E2E-008a, E2E-014, E2E-015, E2E-016, E2E-017, E2E-018, E2E-019, E2E-024I, E2E-024K, E2E-040, E2E-049, E2E-074, E2E-093, E2E-097, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102d, E2E-102e, E2E-102g, E2E-103, E2E-105, E2E-106, E2E-107, E2E-111, E2E-112, E2E-113, E2E-114, E2E-115, E2E-116, E2E-119, E2E-121, E2E-122, E2E-142, E2E-145, E2E-147, E2E-155, E2E-158, E2E-166, E2E-181, E2E-PLUGIN-imported-pi-package-skills |
-| F — Persistence | E2E-020, E2E-021, E2E-021a, E2E-038, E2E-SETTINGS-inline-capability-imports, E2E-040, E2E-042, E2E-047, E2E-048, E2E-051, E2E-054, E2E-056, E2E-061, E2E-062, E2E-064, E2E-066, E2E-068, E2E-071, E2E-072, E2E-073, E2E-082, E2E-084, E2E-096, E2E-098, E2E-102, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-102i, E2E-103, E2E-AGENTS-001, E2E-061a, E2E-073a, E2E-104, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-118, E2E-119, E2E-120, E2E-121, E2E-123, E2E-142, E2E-146, E2E-146a, E2E-148, E2E-151, E2E-158, E2E-160, E2E-168, E2E-171, E2E-177, E2E-178, E2E-183, E2E-186, E2E-005J, E2E-PLUGIN-session-orchestrator-real-workers, E2E-PLUGIN-provider-catalog-add-service, E2E-SESSION-outbox-unclassifiable-failure-does-not-stall-the-queue |
+| F — Persistence | E2E-020, E2E-021, E2E-021a, E2E-038, E2E-SETTINGS-inline-capability-imports, E2E-040, E2E-042, E2E-047, E2E-048, E2E-051, E2E-054, E2E-056, E2E-061, E2E-062, E2E-064, E2E-066, E2E-068, E2E-071, E2E-072, E2E-073, E2E-082, E2E-084, E2E-096, E2E-098, E2E-102, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-102i, E2E-103, E2E-AGENTS-001, E2E-061a, E2E-073a, E2E-104, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-118, E2E-119, E2E-120, E2E-121, E2E-123, E2E-142, E2E-146, E2E-146a, E2E-148, E2E-151, E2E-158, E2E-160, E2E-168, E2E-171, E2E-177, E2E-178, E2E-183, E2E-186, E2E-005J, E2E-PROVIDER-custom-endpoint-no-api-key, E2E-PLUGIN-session-orchestrator-real-workers, E2E-PLUGIN-provider-catalog-add-service, E2E-SESSION-outbox-unclassifiable-failure-does-not-stall-the-queue |
| F — Persistence (project ordering) | E2E-251 |
| G / Security — Fetch redirect policy | E2E-PLUGIN-fetch-redirect-policy |
| G — Plugins | E2E-022, E2E-022A, E2E-022B, E2E-022C, E2E-023, E2E-024, E2E-024B, E2E-024C, E2E-024D, E2E-024AA, E2E-024E, E2E-024W, E2E-024F, E2E-024G, E2E-024H, E2E-024I, E2E-024J, E2E-024K, E2E-024L, E2E-024M, E2E-024N, E2E-024O, E2E-024P, E2E-025, E2E-026, E2E-105, E2E-117, E2E-120, E2E-122, E2E-123, E2E-024Q, E2E-148, E2E-152, E2E-153, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-imported-pi-package-wrapper, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-global-shortcut-owns-only-its-own-command, E2E-PLUGIN-permission-gate-for-real-time-capabilities, E2E-PLUGIN-background-audio-and-realtime-connection, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-PLUGIN-provider-catalog-add-service |
| H — Diagnostics | E2E-027, E2E-031, E2E-034, E2E-042, E2E-096, E2E-098, E2E-104, E2E-107, E2E-108, E2E-109, E2E-110, E2E-113, E2E-115, E2E-116, E2E-118, E2E-121, E2E-146, E2E-146a, E2E-155, E2E-159, E2E-176, E2E-194, E2E-195 |
-| Security | E2E-SETTINGS-inline-capability-imports, E2E-028, E2E-029, E2E-030, E2E-024J, E2E-024K, E2E-024M, E2E-049, E2E-068, E2E-086, E2E-102c, E2E-102d, E2E-102e, E2E-105, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-113, E2E-115, E2E-116, E2E-117, E2E-119, E2E-121, E2E-122, E2E-123, E2E-142, E2E-148, E2E-151, E2E-153, E2E-158, E2E-187, E2E-196c, E2E-196b, E2E-196, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-PLUGIN-provider-catalog-add-service |
+| Security | E2E-SETTINGS-inline-capability-imports, E2E-028, E2E-029, E2E-030, E2E-024J, E2E-024K, E2E-024M, E2E-049, E2E-068, E2E-086, E2E-102c, E2E-102d, E2E-102e, E2E-105, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-113, E2E-115, E2E-116, E2E-117, E2E-119, E2E-121, E2E-122, E2E-123, E2E-142, E2E-148, E2E-151, E2E-153, E2E-158, E2E-187, E2E-196c, E2E-196b, E2E-196, E2E-PROVIDER-custom-endpoint-no-api-key, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-PLUGIN-provider-catalog-add-service |
| Quality | E2E-SETTINGS-inline-capability-imports, E2E-CHAT-long-history-stream-keeps-responsive, E2E-CHAT-running-status-survives-output-pauses, E2E-032, E2E-033, E2E-039, E2E-043, E2E-044, E2E-045, E2E-046, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-050, E2E-053, E2E-055, E2E-056, E2E-057, E2E-058, E2E-059, E2E-060, E2E-061, E2E-062, E2E-063, E2E-064, E2E-065, E2E-066, E2E-067, E2E-068, E2E-069, E2E-070, E2E-071, E2E-072, E2E-073, E2E-074, E2E-075, E2E-076, E2E-077, E2E-078, E2E-079, E2E-080, E2E-081, E2E-082, E2E-083, E2E-084, E2E-085, E2E-086, E2E-092, E2E-093, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102e, E2E-103, E2E-AGENTS-001, E2E-021a, E2E-024N, E2E-059a, E2E-060b, E2E-060c, E2E-061a, E2E-073a, E2E-111, E2E-114, E2E-117, E2E-118, E2E-119, E2E-120, E2E-122, E2E-123, E2E-142, E2E-143, E2E-144, E2E-145, E2E-146, E2E-147, E2E-148, E2E-150, E2E-151, E2E-153, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-168, E2E-172, E2E-173, E2E-174, E2E-011g, E2E-176, E2E-177, E2E-178, E2E-179, E2E-180, E2E-181, E2E-182, E2E-183, E2E-186, E2E-187, E2E-194, E2E-195, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-196, E2E-201, E2E-204, E2E-202, E2E-203, E2E-205, E2E-206, E2E-207, E2E-208, E2E-209, E2E-210, E2E-UPDATE-preference-and-once-only-reminder, E2E-218, E2E-259, E2E-219, E2E-250, E2E-252, E2E-102i, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation, E2E-PLUGIN-provider-catalog-add-service |
| Quality (project ordering) | E2E-253 |
| C — Conversation & stream (IME slash alias) | E2E-255 |
diff --git a/packages/agent-runtime/src/one-shot-complete.ts b/packages/agent-runtime/src/one-shot-complete.ts
index 8b99ca6ff..84937c10f 100644
--- a/packages/agent-runtime/src/one-shot-complete.ts
+++ b/packages/agent-runtime/src/one-shot-complete.ts
@@ -118,6 +118,7 @@ export async function completeOneShot(
providerHeaders = response?.headers;
providerFailure = failure;
}),
+ provider.authKind,
),
},
{
diff --git a/packages/agent-runtime/src/provider-binding.test.ts b/packages/agent-runtime/src/provider-binding.test.ts
index 00bbe1116..61def1497 100644
--- a/packages/agent-runtime/src/provider-binding.test.ts
+++ b/packages/agent-runtime/src/provider-binding.test.ts
@@ -201,6 +201,91 @@ describe("Anthropic runtime endpoint", () => {
expect(request?.headers.get("Authorization")).toBeNull();
});
+ it("sends no API-key or Authorization header for a no-auth provider", async () => {
+ const provider: RuntimeProviderConfig = {
+ ...keyedProvider,
+ id: "local-no-auth",
+ name: "Local gateway",
+ baseUrl: "http://127.0.0.1:11434/v1",
+ apiKey: "stale-fixture-key",
+ authKind: "none",
+ };
+ const model = buildProviderModel(provider);
+ let request: Request | undefined;
+ const fetch = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
+ request = new Request(input, init);
+ return new Response(
+ JSON.stringify({ error: { message: "fixture response" } }),
+ { status: 400, headers: { "content-type": "application/json" } },
+ );
+ });
+ const requestFetch = providerRequestFetch(model.api, fetch, provider.authKind);
+ expect(requestFetch).toBeDefined();
+ if (!requestFetch) throw new Error("OpenAI-compatible requests must accept custom fetch");
+
+ const result = await createProviderModels(provider, model)
+ .streamSimple(
+ model,
+ {
+ systemPrompt: "system",
+ messages: [{ role: "user", content: "hello", timestamp: 1 }],
+ tools: [],
+ },
+ { fetch: requestFetch, maxRetries: 0 },
+ )
+ .result();
+
+ expect(result.stopReason).toBe("error");
+ expect(request).toBeDefined();
+ if (!request) throw new Error("Expected the no-auth request to reach fetch");
+ expect(request.headers.get("x-api-key")).toBeNull();
+ expect(request.headers.get("Authorization")).toBeNull();
+ });
+
+ it("does not send an API-key value for a no-auth Google protocol provider", async () => {
+ const provider: RuntimeProviderConfig = {
+ ...keyedProvider,
+ id: "local-google-no-auth",
+ name: "Local Google gateway",
+ baseUrl: "http://127.0.0.1:9000/v1beta",
+ modelId: "gemini-local",
+ apiKey: "stale-fixture-key",
+ authKind: "none",
+ apiStyle: "google_generative_ai",
+ };
+ const model = buildProviderModel(provider);
+ let request: Request | undefined;
+ const fetch = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
+ request = new Request(input, init);
+ return new Response("{}", {
+ status: 400,
+ headers: { "content-type": "application/json" },
+ });
+ });
+ vi.stubGlobal("fetch", fetch);
+ try {
+ const result = await createProviderModels(provider, model)
+ .streamSimple(
+ model,
+ {
+ systemPrompt: "system",
+ messages: [{ role: "user", content: "hello", timestamp: 1 }],
+ tools: [],
+ },
+ { maxRetries: 0 },
+ )
+ .result();
+ expect(result.stopReason).toBe("error");
+ } finally {
+ vi.unstubAllGlobals();
+ }
+
+ expect(request).toBeDefined();
+ if (!request) throw new Error("Expected the no-auth Google request to reach fetch");
+ expect(request.headers.get("x-goog-api-key")).toBe("");
+ expect(request.headers.get("Authorization")).toBeNull();
+ });
+
it("does not send the mid-conversation tool-change beta for a models.dev Claude gateway", async () => {
const provider: RuntimeProviderConfig = {
...keyedProvider,
diff --git a/packages/agent-runtime/src/provider-binding.ts b/packages/agent-runtime/src/provider-binding.ts
index 0618a651f..2abbf9e43 100644
--- a/packages/agent-runtime/src/provider-binding.ts
+++ b/packages/agent-runtime/src/provider-binding.ts
@@ -111,17 +111,44 @@ export function adapterAcceptsCustomFetch(api: Api | undefined): boolean {
return api !== "google-generative-ai" && api !== "google-vertex";
}
+const NO_AUTH_REQUEST_KEY = "pi-desktop-no-auth";
+
+function withoutNoAuthCredential(fetchFn: FetchFunction): FetchFunction {
+ return (input, init) => {
+ const headers = new Headers(
+ init?.headers ?? (input instanceof Request ? input.headers : undefined),
+ );
+ for (const [name, value] of headers) {
+ const trimmedValue = value.trim();
+ const bearerValue = trimmedValue.slice(0, 7).toLowerCase() === "bearer "
+ ? trimmedValue.slice(7).trim()
+ : undefined;
+ if (
+ trimmedValue === NO_AUTH_REQUEST_KEY ||
+ (name === "authorization" && bearerValue === NO_AUTH_REQUEST_KEY)
+ ) {
+ headers.delete(name);
+ }
+ }
+ return fetchFn(input, { ...(init ?? {}), headers });
+ };
+}
+
/**
* The `fetch` one request may hand to `api`'s adapter: the caller's wrapper
* where the adapter accepts one, otherwise nothing. Callers keep building the
* wrapper (response capture, header override); this only decides whether it
- * reaches the adapter.
+ * reaches the adapter. No-auth requests also strip pi-ai's required placeholder
+ * credential before the request leaves the runtime.
*/
export function providerRequestFetch(
api: Api | undefined,
fetchFn: FetchFunction | undefined,
+ authKind?: string,
): FetchFunction | undefined {
- return adapterAcceptsCustomFetch(api) ? fetchFn : undefined;
+ if (!adapterAcceptsCustomFetch(api)) return undefined;
+ if (authKind !== "none") return fetchFn;
+ return withoutNoAuthCredential(fetchFn ?? globalThis.fetch.bind(globalThis));
}
/** Map a stored provider apiStyle onto a pi-ai wire API. Unknown styles fall
@@ -175,11 +202,11 @@ export function apiBindingForStyle(apiStyle?: string): ApiBinding {
}
}
-/** The key pi-ai signs requests with; `none` auth still needs a placeholder. */
+/** The API key pi-ai signs requests with; no-auth uses a stripped placeholder. */
export function providerRequestKey(provider: RuntimeProviderConfig): string {
- return (
- provider.apiKey || (provider.authKind === "none" ? "pi-desktop-no-auth" : "")
- );
+ return provider.authKind === "none"
+ ? NO_AUTH_REQUEST_KEY
+ : provider.apiKey;
}
/**
@@ -343,6 +370,9 @@ export function buildProviderModel(
const modelHeaders = {
...(copilotDefaults ?? {}),
...(catalogModel.headers ?? {}),
+ ...(provider.authKind === "none" && binding.api === "google-generative-ai"
+ ? { "x-goog-api-key": "" }
+ : {}),
};
const thinkingProtocolCompat = catalogModel.thinkingProtocol
? { forceAdaptiveThinking: catalogModel.thinkingProtocol === "adaptive" }
diff --git a/packages/agent-runtime/src/runtime.ts b/packages/agent-runtime/src/runtime.ts
index 752044810..2ef3ab783 100644
--- a/packages/agent-runtime/src/runtime.ts
+++ b/packages/agent-runtime/src/runtime.ts
@@ -2100,6 +2100,7 @@ Do not invent objections or turn speculative risks into blockers. Stop when the
: undefined;
},
),
+ this.provider.authKind,
),
onResponse: async (response, responseModel) => {
this.providerResponseStatus = response.status;
diff --git a/packages/agent-runtime/src/subagent-model-binding.ts b/packages/agent-runtime/src/subagent-model-binding.ts
index 11c84a605..f9f7e251c 100644
--- a/packages/agent-runtime/src/subagent-model-binding.ts
+++ b/packages/agent-runtime/src/subagent-model-binding.ts
@@ -85,6 +85,7 @@ export function subagentModelBinding(opts: {
? response?.headers
: undefined;
}),
+ opts.provider.authKind,
),
},
{
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index e4e2682c6..700cc1f10 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1392,6 +1392,8 @@ sklm: {
"copyProviderHint": "Erstellt einen unabhängigen Dienst. API-Schlüssel, Kontoanmeldungen und benutzerdefinierte Header werden nicht kopiert. Das Standardmodell bleibt unverändert.",
"editProviderTitle": "AI-Anbieter bearbeiten",
"apiKeyKeepHint": "Lassen Sie das Feld leer, um den gespeicherten Schlüssel beizubehalten.",
+ "noApiKeyRequired": "Kein API-Schlüssel erforderlich",
+ "noApiKeyRequiredHint": "Anfragen enthalten weder API-Schlüssel noch Authorization-Zugangsdaten. Beim Speichern wird ein bereits für diesen Anbieter gespeicherter API-Schlüssel gelöscht.",
"apiStyle": "API-Format",
"apiStyleChatCompletions": "OpenAI-Chat-Abschlüsse",
"apiStyleOpenCodeGo": "OpenCode Go",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index a71fdba3f..36506239b 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1409,6 +1409,8 @@ sklm: {
"copyProviderHint": "Creates an independent service. API keys, account logins and custom headers are not copied. Your default model stays unchanged.",
editProviderTitle: "Edit AI provider",
apiKeyKeepHint: "Leave blank to keep the saved key.",
+ noApiKeyRequired: "No API key required",
+ noApiKeyRequiredHint: "Requests won't include an API-key or Authorization credential. Saving this setting removes any API key already stored for this provider.",
apiStyle: "API format",
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index d98ca6fb8..fb5b4469a 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1392,6 +1392,8 @@ sklm: {
"copyProviderHint": "Crea un servicio independiente. No se copian las claves API, los inicios de sesión ni las cabeceras personalizadas. El modelo predeterminado no cambia.",
"editProviderTitle": "Editar proveedor de IA",
"apiKeyKeepHint": "Déjelo en blanco para conservar la clave guardada.",
+ "noApiKeyRequired": "No se requiere una clave API",
+ "noApiKeyRequiredHint": "Las solicitudes no incluirán credenciales de clave API ni de Authorization. Al guardar, se eliminará cualquier clave API guardada para este proveedor.",
"apiStyle": "Formato API",
"apiStyleChatCompletions": "Finalizaciones de OpenAI Chat",
"apiStyleOpenCodeGo": "OpenCode Go",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index ff94f9e34..305315a0a 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1392,6 +1392,8 @@ sklm: {
"copyProviderHint": "Crée un service indépendant. Les clés API, connexions aux comptes et en-têtes personnalisés ne sont pas copiés. Le modèle par défaut reste inchangé.",
"editProviderTitle": "Modifier le fournisseur d'IA",
"apiKeyKeepHint": "Laissez vide pour conserver la clé enregistrée.",
+ "noApiKeyRequired": "Aucune clé API requise",
+ "noApiKeyRequiredHint": "Les requêtes n'incluront aucune clé API ni aucun identifiant Authorization. L'enregistrement supprimera toute clé API déjà stockée pour ce fournisseur.",
"apiStyle": "Format API",
"apiStyleChatCompletions": "Achèvements de discussion OpenAI",
"apiStyleOpenCodeGo": "OpenCode Go",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 944b39e46..bdb203c2d 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1405,6 +1405,8 @@ sklm: {
"copyProviderHint": "독립적인 서비스를 만듭니다. API 키, 계정 로그인 및 사용자 지정 헤더는 복사하지 않습니다. 기본 모델은 변경되지 않습니다.",
editProviderTitle: "AI 프로바이더 편집",
apiKeyKeepHint: "저장된 키를 유지하려면 비워 두세요.",
+ noApiKeyRequired: "API 키 필요 없음",
+ noApiKeyRequiredHint: "요청에 API 키나 Authorization 자격 증명을 포함하지 않습니다. 저장하면 이 프로바이더에 이미 저장된 API 키가 삭제됩니다.",
apiStyle: "API 형식",
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index 17ec40237..8fc598e42 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -1362,6 +1362,8 @@ export const ptBR = {
copyProviderHint: "Cria um serviço independente. Chaves de API, logins de contas e cabeçalhos personalizados não são copiados. O modelo padrão permanece inalterado.",
editProviderTitle: "Editar provedor de IA",
apiKeyKeepHint: "Deixe em branco para manter a chave salva.",
+ noApiKeyRequired: "Não requer chave de API",
+ noApiKeyRequiredHint: "As solicitações não incluirão credenciais de API key nem de Authorization. Ao salvar, qualquer chave de API já armazenada para este provedor será removida.",
apiStyle: "Formato API",
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 6f719b9bb..cb1c4277f 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1399,6 +1399,8 @@ sklm: {
"copyProviderHint": "Bağımsız bir hizmet oluşturur. API anahtarları, hesap girişleri ve özel başlıklar kopyalanmaz. Varsayılan model değişmez.",
editProviderTitle: "AI servisini düzenle",
apiKeyKeepHint: "Kayıtlı anahtarı korumak için boş bırakın.",
+ noApiKeyRequired: "API anahtarı gerekmiyor",
+ noApiKeyRequiredHint: "İsteklerde API anahtarı veya Authorization kimlik bilgisi bulunmaz. Kaydettiğinizde bu sağlayıcı için kayıtlı API anahtarı silinir.",
apiStyle: "API biçimi",
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index f6de34730..c01850857 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1387,6 +1387,8 @@ sklm: {
"copyProviderHint": "创建独立的服务配置,不复制 API 密钥、账号登录信息或自定义请求头。当前默认模型保持不变。",
editProviderTitle: "编辑 AI 服务",
apiKeyKeepHint: "留空则保留已保存的密钥。",
+ noApiKeyRequired: "无需 API 密钥",
+ noApiKeyRequiredHint: "请求不会携带 API 密钥或 Authorization 凭证。保存时会删除此服务已保存的 API 密钥。",
apiStyle: "接口格式",
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index e37f8337a..6ec4eabe3 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1387,6 +1387,8 @@ sklm: {
"copyProviderHint": "建立獨立的服務設定,不複製 API 金鑰、帳號登入資訊或自訂請求標頭。目前的預設模型保持不變。",
editProviderTitle: "編輯 AI 服務",
apiKeyKeepHint: "留空則保留已儲存的金鑰。",
+ noApiKeyRequired: "不需要 API 金鑰",
+ noApiKeyRequiredHint: "請求不會附帶 API 金鑰或 Authorization 憑證。儲存時會刪除此服務已儲存的 API 金鑰。",
apiStyle: "介面格式",
apiStyleChatCompletions: "OpenAI Chat Completions",
apiStyleOpenCodeGo: "OpenCode Go",
diff --git a/scripts/e2e/provider-api-style.tsx b/scripts/e2e/provider-api-style.tsx
index 69aac366d..bb90c3f9b 100644
--- a/scripts/e2e/provider-api-style.tsx
+++ b/scripts/e2e/provider-api-style.tsx
@@ -6,6 +6,8 @@ import { catalogs } from "@pi-desktop/i18n";
import type { ProviderPublic, ProviderCreateInput, ProviderUpdateInput } from "@pi-desktop/shared";
import { ProviderSetupDialog, type ProviderSetupDialogProps } from "../../apps/desktop/src/components/settings/ProviderSetupDialog";
import { VendorAccountDialog, type VendorAccountForm } from "../../apps/desktop/src/components/settings/VendorAccountDialog";
+import { defaultModelOptions, providerServesChatModels } from "../../apps/desktop/src/components/settings/default-model";
+import { subagentModelChoices } from "../../apps/desktop/src/components/settings/subagent-models";
import { API_STYLE_LABEL_KEYS, CUSTOM_PROVIDER_API_STYLES } from "../../apps/desktop/src/components/settings/provider-api-style";
import { copyProviderConfiguration } from "../../apps/desktop/src/components/settings/provider-copy";
import { CUSTOM_SERVICE } from "../../apps/desktop/src/components/settings/service-catalog";
@@ -40,15 +42,34 @@ globalThis.providerApiStyleProbe = async () => {
const creates: ProviderCreateInput[] = [];
const updates: ProviderUpdateInput[] = [];
const discoveries: Parameters<typeof api.listProviderModels>[0][] = [];
+ let savedProvider: ProviderPublic | undefined;
// Only the API boundary is faked: render the production form/hooks and inspect
// exact save payloads. This does not validate Host persistence or live OAuth.
api.createProvider = async (input) => {
creates.push(structuredClone(input));
- return { provider: { ...fixture(input.apiStyle!), ...input, id: "copy" } };
+ const saved: ProviderPublic = {
+ ...fixture(input.apiStyle ?? "chat_completions"),
+ id: `created-${creates.length}`,
+ name: input.name,
+ vendorKey: input.vendorKey ?? "custom",
+ type: input.type ?? "openai_compatible",
+ protocol: input.protocol ?? "openai_compatible",
+ baseUrl: input.baseUrl,
+ authKind: input.authKind ?? "api_key_and_base_url",
+ hasSecret: Boolean(input.secretValue),
+ hasOauth: false,
+ models: input.models ?? [],
+ };
+ return { provider: saved };
};
api.updateProvider = async (input) => {
updates.push(structuredClone(input));
- return { provider: { ...fixture(input.apiStyle!), ...input } };
+ return { provider: {
+ ...fixture(input.apiStyle ?? "chat_completions"),
+ ...input,
+ authKind: input.authKind ?? "api_key_and_base_url",
+ hasSecret: input.authKind === "none" ? false : true,
+ } };
};
api.listProviderModels = async (input) => {
discoveries.push(structuredClone(input));
@@ -59,6 +80,13 @@ globalThis.providerApiStyleProbe = async () => {
supportedThinkingLevels: ["low", "medium", "high"], contextWindow: 1000000, maxTokens: 65536,
}], source: "remote" };
}
+ if (input.baseUrl === "http://127.0.0.1:11434/v1") {
+ return { models: [{
+ modelId: "local-chat", displayName: "Local Chat", providerId: "",
+ source: "discovered", capabilities: ["text", "tools"],
+ contextWindow: 32768, maxTokens: 4096,
+ }], source: "remote" };
+ }
return { models: [], source: "remote" };
};
/* The root container only mounts React; every production surface under test
@@ -70,7 +98,12 @@ globalThis.providerApiStyleProbe = async () => {
let closes = 0;
const render = (props: Partial<ProviderSetupDialogProps> = {}) => {
flushSync(() => root.render(<I18nextProvider i18n={i18n}>
- <ProviderSetupDialog key={++key} onClose={() => { closes++; }} onSaved={() => {}} {...props} />
+ <ProviderSetupDialog
+ key={++key}
+ onClose={() => { closes++; }}
+ onSaved={(provider) => { savedProvider = structuredClone(provider); }}
+ {...props}
+ />
</I18nextProvider>));
const advanced = document.querySelector<HTMLButtonElement>(".provider-chosen-advanced-toggle");
if (advanced?.getAttribute("aria-expanded") === "false") flushSync(() => advanced.click());
@@ -86,6 +119,13 @@ globalThis.providerApiStyleProbe = async () => {
assert(element, `missing control ${key}`);
return element;
};
+ const setValue = (input: HTMLInputElement, value: string) => {
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, value);
+ input.dispatchEvent(new Event("input", { bubbles: true }));
+ };
+ const labeledCheckbox = (label: string) =>
+ [...document.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')]
+ .find((input) => input.closest("label")?.textContent?.trim() === label);
/* A Field explains itself through the help icon's accessible name, so read the
row's explanations from the affordance that carries them. */
const rowHints = () => [...document.querySelectorAll<HTMLElement>(
@@ -237,6 +277,73 @@ globalThis.providerApiStyleProbe = async () => {
`${locale}: new custom form offers the account format ${style}`);
}
await closeApiStyleMenu();
+ const noKeyControl = labeledCheckbox(i18n.t("settings.noApiKeyRequired"));
+ assert(noKeyControl && !noKeyControl.checked,
+ `${locale}: custom endpoint must default to API-key authentication`);
+ const identityInputs = [...document.querySelectorAll<HTMLInputElement>(
+ ".provider-setup-custom-identity-row input",
+ )];
+ assert(identityInputs.length === 2, `${locale}: custom identity fields are missing`);
+ setValue(identityInputs[0]!, "Local Ollama");
+ setValue(identityInputs[1]!, "http://127.0.0.1:11434/v1");
+ click(noKeyControl);
+ assert(noKeyControl.checked, `${locale}: no-API-key mode did not turn on`);
+ assert(!document.querySelector('input[type="password"]'),
+ `${locale}: no-API-key mode left an API key input visible`);
+ assert(document.documentElement.innerText.includes(i18n.t("settings.noApiKeyRequiredHint")),
+ `${locale}: no-API-key behavior was not explained`);
+ const beforeLocalDiscovery = discoveries.length;
+ await until(() => discoveries.length > beforeLocalDiscovery, "local no-auth discovery");
+ const localProbe = discoveries.at(-1)!;
+ assert(localProbe.baseUrl === "http://127.0.0.1:11434/v1" && !localProbe.apiKey,
+ `${locale}: local model discovery included an API key`);
+ await until(
+ () => Boolean(document.querySelector<HTMLInputElement>(".provider-models-row input")),
+ "local model discovery result",
+ );
+ const localModel = document.querySelector<HTMLInputElement>(".provider-models-row input");
+ assert(localModel, `${locale}: the local service model was not selectable`);
+ if (!localModel.checked) click(localModel);
+ await until(() => !control("settings.saveProvider").disabled, "no-auth provider save enabled");
+ const beforeLocalCreate = creates.length;
+ savedProvider = undefined;
+ click(control("settings.saveProvider"));
+ await until(() => creates.length === beforeLocalCreate + 1 && Boolean(savedProvider),
+ "no-auth provider saved");
+ const savedNoAuth = creates.at(-1)!;
+ assert(savedNoAuth.authKind === "none" && !("secretValue" in savedNoAuth),
+ `${locale}: no-auth selection did not persist without a secret`);
+ assert(savedProvider?.authKind === "none" && savedProvider.hasSecret === false,
+ `${locale}: saved provider is still marked as credentialed`);
+ assert(providerServesChatModels(savedProvider!),
+ `${locale}: saved no-auth provider is not eligible for the default model`);
+ assert(defaultModelOptions([savedProvider!]).some((option) => option.modelId === "local-chat"),
+ `${locale}: no-auth provider is missing from default-model options`);
+ assert(subagentModelChoices([savedProvider!]).some((option) => option.modelId === "local-chat"),
+ `${locale}: no-auth provider is missing from subagent model options`);
+ results.push(`${locale}:custom-endpoint-no-api-key-save-and-selection`);
+
+ const editableKeyProvider = {
+ ...fixture("chat_completions"),
+ id: `key-provider-${locale}`,
+ name: "Key-backed gateway",
+ baseUrl: "http://127.0.0.1:9000/v1",
+ };
+ render({ provider: editableKeyProvider });
+ const editNoKeyControl = labeledCheckbox(i18n.t("settings.noApiKeyRequired"));
+ assert(editNoKeyControl && !editNoKeyControl.checked,
+ `${locale}: API-key provider edit opened in the wrong mode`);
+ click(editNoKeyControl);
+ assert(!document.querySelector('input[type="password"]'),
+ `${locale}: switched no-auth edit still shows an API-key field`);
+ const beforeNoAuthUpdate = updates.length;
+ click(control("settings.saveProvider"));
+ await until(() => updates.length === beforeNoAuthUpdate + 1, "provider changed to no-auth");
+ const noAuthUpdate = updates.at(-1)!;
+ assert(noAuthUpdate.authKind === "none" && !("secretValue" in noAuthUpdate),
+ `${locale}: edit did not persist the no-auth mode without a replacement key`);
+ results.push(`${locale}:edit-provider-switches-to-no-api-key`);
+
results.push(`${locale}:new-custom-options`);
for (const style of ACCOUNT_ONLY_STYLES) {