Skip to content

Your lightweight open-source personal agent.

fix(webui): move API settings into advanced options

chengyongru130fbcb84258
diff --git a/docs/configuration.md b/docs/configuration.md
index 9cecfbf01..31533d05a 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -1458,7 +1458,7 @@ For the built-in `custom` connection or any named custom provider, declare the p
`supportedApis` is a nonempty list of `chat_completions`, `responses`, and/or `anthropic_messages`. `preferredApi` must belong to that list and defaults to its first entry. A model preset using Auto inherits this default. A preset's explicit API list must be a subset of the connection's list. A connection can accept both Anthropic and OpenAI formats; automatic fallback stays within the selected API family.
-The WebUI custom provider creation and editing forms expose **Supported APIs** and **Default API**. New connections start with Chat Completions; select the protocols your endpoint accepts. Existing connections without an `api` declaration retain their previous automatic routing. Use **Set supported APIs** to add a declaration. Removing a protocol used by an existing explicit model configuration is rejected; update the model configuration first.
+The WebUI custom provider creation and editing forms expose **Supported APIs** and **Default API** under **Advanced options**, collapsed by default. New connections start with Chat Completions; select the protocols your endpoint accepts. Existing connections without an `api` declaration retain their previous automatic routing. Use **Set supported APIs** to add a declaration. Removing a protocol used by an existing explicit model configuration is rejected; update the model configuration first.
### Legacy OpenAI API selector migration
@@ -1508,7 +1508,7 @@ A custom preset declaring `anthropic_messages` uses the Anthropic adapter for me
Omit `api` or set it to `null` for automatic routing. An explicit model declaration overrides the OpenAI connection default. Automatic Copilot routing uses the account's last successfully discovered `supported_endpoints` when available; other automatic routes use registry defaults. Custom gateways use their connection API default when declared, otherwise Chat Completions. A preset can override that default only within the connection's declared supported APIs. Protocol behavior such as reasoning replay and native compaction remains provider-owned; declaring Responses support does not enable OpenAI-native compaction on a custom gateway.
-In the WebUI, open **Settings → Models → a preset → API connection**. Choose **Auto**, **Responses**, **Chat Completions**, or **Anthropic Messages**, according to the host's declared adapter support. Auto shows the default API in parentheses, such as **Auto (Responses)**, and updates when the provider, model, or reasoning setting changes. The gateway resolves this default using the same rules as model requests, without probing remote endpoints. The label describes the default preference; compatibility failures can still activate permitted Chat fallback. Hosts that do not advertise API resolution show **Auto** without a resolved label. Selecting Responses also reveals **Try Chat Completions if Responses is unsupported**, which starts off when selecting Responses and requires the same model to support both endpoints.
+In the WebUI, open **Settings → Models → a preset → Advanced options → API connection**. Advanced options is collapsed by default; opening or closing it preserves the preset's API declaration. Choose **Auto**, **Responses**, **Chat Completions**, or **Anthropic Messages**, according to the host's declared adapter support. Auto shows the default API in parentheses, such as **Auto (Responses)**, and updates when the provider, model, or reasoning setting changes while Advanced options is open. The gateway resolves this default using the same rules as model requests, without probing remote endpoints. The label describes the default preference; compatibility failures can still activate permitted Chat fallback. Hosts that do not advertise API resolution show **Auto** without a resolved label. Selecting Responses also reveals **Try Chat Completions if Responses is unsupported**, which starts off when selecting Responses and requires the same model to support both endpoints.
Every provider adapter declares its request formats in `nanobot/providers/registry.py`. OpenAI Codex, xAI Grok subscriptions, and the Azure OpenAI adapter use Responses; Anthropic uses Messages, and Bedrock uses Converse. The WebUI shows the protocol name for these fixed connections instead of an editable selector. Preset declarations cannot enable a format the adapter does not implement. An OpenAI-compatible adapter implementing both formats does not guarantee that a particular remote model supports both.
diff --git a/webui/src/components/settings/models/ModelsSettings.tsx b/webui/src/components/settings/models/ModelsSettings.tsx
index bfec55d58..552c1451d 100644
--- a/webui/src/components/settings/models/ModelsSettings.tsx
+++ b/webui/src/components/settings/models/ModelsSettings.tsx
@@ -238,6 +238,7 @@ export function ModelsSettings({
const tx = (key: string, fallback: string, values?: Record<string, unknown>) =>
t(key, { defaultValue: fallback, ...(values ?? {}) });
const [editorOpen, setEditorOpen] = useState(false);
+ const [advancedOpen, setAdvancedOpen] = useState(false);
const resolvedAutomaticAPI = useAutomaticModelAPI({
token,
provider: form.provider,
@@ -245,13 +246,12 @@ export function ModelsSettings({
reasoningEffort: form.reasoningEffort,
providers: settings.providers,
supported: settings.model_api_resolution_supported === true,
- editorOpen,
+ editorOpen: editorOpen && advancedOpen,
});
const editorTriggerRef = useRef<HTMLElement | null>(null);
const presetNameInputRef = useRef<HTMLInputElement>(null);
const suggestedPresetNameRef = useRef<string | null>(null);
const [editorRowKey, setEditorRowKey] = useState<string | null>(null);
- const [advancedOpen, setAdvancedOpen] = useState(false);
const advancedId = useId();
const [draggedCallOrderIndex, setDraggedCallOrderIndex] = useState<number | null>(null);
const [dragOverCallOrderIndex, setDragOverCallOrderIndex] = useState<number | null>(null);
@@ -517,14 +517,6 @@ export function ModelsSettings({
}}
/>
</SettingsRow>
- <ModelAPIControl
- provider={selectedProvider ?? settings.providers.find(
- (provider) => provider.name === (resolvedAutomaticAPI?.provider ?? selectedPreset?.resolved_provider),
- )}
- automaticAPI={resolvedAutomaticAPI?.api}
- value={form.api}
- onChange={(api) => setForm((prev) => ({ ...prev, api }))}
- />
<button
type="button"
aria-expanded={advancedOpen}
@@ -557,14 +549,24 @@ export function ModelsSettings({
</span>
</button>
<DisclosureContent id={advancedId} open={advancedOpen}>
- <div className="bg-muted/12 px-4 py-4 sm:px-5">
- <ModelAdvancedFields
- maxTokens={form.maxTokens}
- contextWindowTokens={form.contextWindowTokens}
- temperature={form.temperature}
- reasoningEffort={form.reasoningEffort}
- onChange={(value) => setForm((prev) => ({ ...prev, ...value }))}
+ <div className="bg-muted/12">
+ <ModelAPIControl
+ provider={selectedProvider ?? settings.providers.find(
+ (provider) => provider.name === (resolvedAutomaticAPI?.provider ?? selectedPreset?.resolved_provider),
+ )}
+ automaticAPI={resolvedAutomaticAPI?.api}
+ value={form.api}
+ onChange={(api) => setForm((prev) => ({ ...prev, api }))}
/>
+ <div className="px-4 py-4 sm:px-5">
+ <ModelAdvancedFields
+ maxTokens={form.maxTokens}
+ contextWindowTokens={form.contextWindowTokens}
+ temperature={form.temperature}
+ reasoningEffort={form.reasoningEffort}
+ onChange={(value) => setForm((prev) => ({ ...prev, ...value }))}
+ />
+ </div>
</div>
</DisclosureContent>
<div className="flex min-h-[58px] flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5">
diff --git a/webui/src/components/settings/models/ProviderSettings.tsx b/webui/src/components/settings/models/ProviderSettings.tsx
index 1709b8adb..298ff2335 100644
--- a/webui/src/components/settings/models/ProviderSettings.tsx
+++ b/webui/src/components/settings/models/ProviderSettings.tsx
@@ -459,18 +459,20 @@ function ProviderAdvancedOptions({
fields,
form,
onChange,
+ children,
footer,
}: {
fields: ProviderAdvancedField[];
form: ProviderForm;
onChange: (value: Partial<ProviderForm>) => void;
+ children?: ReactNode;
footer?: ReactNode;
}) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const enabled = new Set(fields);
const contentId = useId();
- if (enabled.size === 0) return null;
+ if (enabled.size === 0 && !children) return null;
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
const thinkingStyleOptions = [
@@ -501,7 +503,8 @@ function ProviderAdvancedOptions({
/>
</button>
<DisclosureContent id={contentId} open={open}>
- <div className="py-3">
+ <div className="space-y-3 py-3">
+ {children}
<div className="grid gap-3 md:grid-cols-2">
{enabled.has("thinking_style") ? (
<label className="block space-y-1.5">
@@ -1003,24 +1006,25 @@ export function ProvidersSettings({
form={form}
onChange={(value) => onChangeProviderForm(provider.name, value)}
/>
- {provider.provider_api_configurable && (provider.name === "openai" ? (
- <ModelAPIControl
- provider={provider}
- title={t("settings.providers.defaultAPI")}
- value={form.api}
- onChange={(api) => onChangeProviderForm(provider.name, { api })}
- />
- ) : (
- <ProviderAPIControl
- value={form.api}
- onChange={(api) => onChangeProviderForm(provider.name, { api })}
- />
- ))}
<ProviderAdvancedOptions
fields={advancedFields}
form={form}
onChange={(value) => onChangeProviderForm(provider.name, value)}
- />
+ >
+ {provider.provider_api_configurable && (provider.name === "openai" ? (
+ <ModelAPIControl
+ provider={provider}
+ title={t("settings.providers.defaultAPI")}
+ value={form.api}
+ onChange={(api) => onChangeProviderForm(provider.name, { api })}
+ />
+ ) : (
+ <ProviderAPIControl
+ value={form.api}
+ onChange={(api) => onChangeProviderForm(provider.name, { api })}
+ />
+ ))}
+ </ProviderAdvancedOptions>
<div className="flex items-center justify-end gap-2">
<Button
size="sm"
@@ -1156,19 +1160,20 @@ export function ProvidersSettings({
</Button>
</div>
</label>
- {settings.provider_api_configuration_supported && (
- <ProviderAPIControl
- value={customProviderDraft.api}
- onChange={(api) => setCustomProviderDraft((current) => ({ ...current, api }))}
- />
- )}
<ProviderAdvancedOptions
fields={CUSTOM_PROVIDER_ADVANCED_FIELDS}
form={customProviderDraft}
onChange={(value) =>
setCustomProviderDraft((current) => ({ ...current, ...value }))
}
- />
+ >
+ {settings.provider_api_configuration_supported && (
+ <ProviderAPIControl
+ value={customProviderDraft.api}
+ onChange={(api) => setCustomProviderDraft((current) => ({ ...current, api }))}
+ />
+ )}
+ </ProviderAdvancedOptions>
<div className="flex items-center justify-end gap-2">
<Button
size="sm"
diff --git a/webui/src/tests/settings-models.test.tsx b/webui/src/tests/settings-models.test.tsx
index 362a3bef1..baf3a4019 100644
--- a/webui/src/tests/settings-models.test.tsx
+++ b/webui/src/tests/settings-models.test.tsx
@@ -86,6 +86,11 @@ async function togglePresetEditor(name = "primary") {
fireEvent.click(within(row).getAllByRole("button")[0]);
}
+async function openPresetAdvancedOptions() {
+ await togglePresetEditor();
+ fireEvent.click(screen.getByRole("button", { name: /Advanced options/ }));
+}
+
describe("Settings models", () => {
installSettingsViewTestHooks();
@@ -109,6 +114,8 @@ describe("Settings models", () => {
});
renderSettingsView({ initialSection: "models" });
await togglePresetEditor();
+ expect(screen.queryByRole("combobox", { name: "API connection" })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button", { name: /Advanced options/ }));
await openPopover(screen.getByLabelText("API connection"));
expect(screen.getAllByRole("option")).toHaveLength(3);
fireEvent.click(screen.getByRole("option", { name: "Responses" }));
@@ -121,7 +128,7 @@ describe("Settings models", () => {
));
await waitFor(() => expect(screen.getByRole("button", { name: "Save" })).toBeDisabled());
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
expect(screen.getByLabelText("API connection")).toHaveTextContent("Responses");
fireEvent.click(screen.getByRole("switch", { name: "Try Chat Completions if Responses is unsupported" }));
fireEvent.click(screen.getByRole("button", { name: "Save" }));
@@ -132,7 +139,7 @@ describe("Settings models", () => {
));
await waitFor(() => expect(screen.getByRole("button", { name: "Save" })).toBeDisabled());
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
expect(screen.getByRole("switch", { name: "Try Chat Completions if Responses is unsupported" })).toBeChecked();
await openPopover(screen.getByLabelText("API connection"));
fireEvent.click(screen.getByRole("option", { name: "Responses" }));
@@ -166,7 +173,7 @@ describe("Settings models", () => {
return payload;
});
renderSettingsView({ initialSection: "models" });
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
await openPopover(screen.getByLabelText("API connection"));
expect(screen.getAllByRole("option")).toHaveLength(4);
fireEvent.click(screen.getByRole("option", { name: "Anthropic Messages" }));
@@ -179,7 +186,7 @@ describe("Settings models", () => {
));
await waitFor(() => expect(screen.getByRole("button", { name: "Save" })).toBeDisabled());
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
expect(screen.getByLabelText("API connection")).toHaveTextContent("Anthropic Messages");
expect(screen.getByRole("button", { name: "Save" })).toBeDisabled();
await openPopover(screen.getByLabelText("API connection"));
@@ -207,7 +214,7 @@ describe("Settings models", () => {
}));
requestMutationMock.mockResolvedValue(payload);
renderSettingsView({ initialSection: "models", initialSettings: payload });
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
await openPopover(screen.getByRole("button", { name: "anthropic/claude-sonnet-4", exact: true }));
const search = screen.getByRole("combobox", { name: "Choose model" });
fireEvent.change(search, { target: { value: "gpt-4o" } });
@@ -242,13 +249,12 @@ describe("Settings models", () => {
});
vi.stubGlobal("fetch", fetchMock);
renderSettingsView({ initialSection: "models" });
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
await waitFor(() => expect(screen.getByLabelText("API connection")).toHaveTextContent("Auto (Chat Completions)"));
expect(screen.getByRole("button", { name: "Save" })).toBeDisabled();
await openPopover(screen.getByLabelText("API connection"));
expect(screen.getByRole("option", { name: "Auto (Chat Completions)" })).toHaveAttribute("aria-selected", "true");
fireEvent.click(screen.getByRole("option", { name: "Auto (Chat Completions)" }));
- fireEvent.click(screen.getByRole("button", { name: /Advanced options/ }));
fireEvent.change(screen.getByLabelText("Reasoning effort"), { target: { value: "high" } });
await waitFor(() => expect(fetchMock.mock.calls.some(([url]) => String(url).includes("reasoning_effort=high"))).toBe(true));
fireEvent.change(screen.getByLabelText("Reasoning effort"), { target: { value: "none" } });
@@ -275,9 +281,8 @@ describe("Settings models", () => {
});
}));
renderSettingsView({ initialSection: "models" });
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
await waitFor(() => expect(screen.getByLabelText("API connection")).toHaveTextContent("Auto (Chat Completions)"));
- fireEvent.click(screen.getByRole("button", { name: /Advanced options/ }));
fireEvent.change(screen.getByLabelText("Reasoning effort"), { target: { value: "high" } });
await waitFor(() => expect(screen.getByLabelText("API connection")).toHaveTextContent("Auto (Responses)"));
fireEvent.click(screen.getByRole("button", { name: "Save" }));
@@ -297,7 +302,7 @@ describe("Settings models", () => {
? jsonResponse({ provider: "openai", api }) : jsonResponse(payload));
vi.stubGlobal("fetch", fetchMock);
renderSettingsView({ initialSection: "models" });
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
await waitFor(() => expect(fetchMock.mock.calls.some(([url]) => String(url).includes("/model-api?"))).toBe(true));
await act(async () => { await Promise.resolve(); });
expect(screen.getByLabelText("API connection")).toHaveTextContent(/^Auto$/);
@@ -311,7 +316,7 @@ describe("Settings models", () => {
providers: [{ name: "openai", label: "OpenAI", configured: true, request_apis: requestAPIs }],
})));
renderSettingsView({ initialSection: "models" });
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
expect(screen.queryByRole("combobox", { name: "API connection" })).not.toBeInTheDocument();
});
@@ -328,7 +333,8 @@ describe("Settings models", () => {
requestMutationMock.mockResolvedValue(payload);
renderSettingsView({ initialSection: "models" });
await togglePresetEditor();
- expect(screen.getByLabelText("API connection")).toHaveTextContent("Chat Completions");
+ expect(screen.queryByRole("combobox", { name: "API connection" })).not.toBeInTheDocument();
+ expect(screen.getByRole("button", { name: /Advanced options/ })).toHaveAttribute("aria-expanded", "false");
expect(screen.getByRole("button", { name: "Save" })).toBeDisabled();
fireEvent.change(screen.getByLabelText("Preset name"), { target: { value: "Renamed" } });
fireEvent.click(screen.getByRole("button", { name: "Save" }));
@@ -348,7 +354,7 @@ describe("Settings models", () => {
payload.model_presets[0].resolved_provider = provider;
vi.stubGlobal("fetch", vi.fn(async () => jsonResponse(payload)));
renderSettingsView({ initialSection: "models" });
- await togglePresetEditor();
+ await openPresetAdvancedOptions();
expect(screen.getByText(apiLabel, { exact: true })).toBeVisible();
expect(screen.queryByRole("combobox", { name: "API connection" })).not.toBeInTheDocument();
expect(screen.queryByRole("switch")).not.toBeInTheDocument();
diff --git a/webui/src/tests/settings-providers.test.tsx b/webui/src/tests/settings-providers.test.tsx
index 346b30be5..4c885ed0e 100644
--- a/webui/src/tests/settings-providers.test.tsx
+++ b/webui/src/tests/settings-providers.test.tsx
@@ -1011,15 +1011,19 @@ describe("Settings providers", () => {
await user.click(screen.getByRole("button", { name: "Custom" }));
await user.type(screen.getByPlaceholderText("My model provider"), "Tenant");
await user.type(screen.getByPlaceholderText("https://api.example.com/v1"), "https://tenant.test");
+ expect(screen.queryByRole("group", { name: "Supported APIs" })).not.toBeInTheDocument();
+ await user.click(screen.getByRole("button", { name: "Advanced options" }));
expect(screen.getByRole("switch", { name: "Chat Completions" })).toBeDisabled();
await user.click(screen.getByRole("switch", { name: "Anthropic Messages" }));
await user.click(screen.getByRole("switch", { name: "Chat Completions" }));
expect(screen.getByRole("combobox", { name: "Default API" })).toHaveTextContent("Anthropic Messages");
expect(screen.getByRole("switch", { name: "Anthropic Messages" })).toBeDisabled();
+ await user.click(screen.getByRole("button", { name: "Advanced options" }));
await user.click(screen.getByRole("button", { name: "Save provider" }));
await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
expect(requestMutationMock).toHaveBeenCalledWith("settings.provider.create", expect.objectContaining({ api }), 20_000);
await user.click(screen.getByRole("button", { name: "Tenant", exact: true }));
+ await user.click(screen.getByRole("button", { name: "Advanced options" }));
expect(screen.getByRole("combobox", { name: "Default API" })).toHaveTextContent("Anthropic Messages");
await user.click(screen.getByRole("switch", { name: "Responses" }));
await user.click(screen.getByRole("combobox", { name: "Default API" }));
@@ -1029,6 +1033,7 @@ describe("Settings providers", () => {
provider: "tenant", api: { supported_apis: ["anthropic_messages", "responses"], preferred_api: "responses" },
}), 20_000));
await user.click(screen.getByRole("button", { name: "Tenant", exact: true }));
+ await user.click(screen.getByRole("button", { name: "Advanced options" }));
expect(screen.getByRole("combobox", { name: "Default API" })).toHaveTextContent("Responses");
});
@@ -1036,6 +1041,7 @@ describe("Settings providers", () => {
renderSettingsView({ initialSection: "models", initialSettings: settingsPayload() });
fireEvent.click(screen.getByRole("button", { name: "Add provider" }));
fireEvent.click(screen.getByRole("button", { name: "Custom" }));
+ fireEvent.click(screen.getByRole("button", { name: "Advanced options" }));
expect(screen.queryByRole("combobox", { name: "Default API" })).not.toBeInTheDocument();
expect(screen.queryByRole("group", { name: "Supported APIs" })).not.toBeInTheDocument();
});
@@ -1054,6 +1060,8 @@ describe("Settings providers", () => {
});
renderSettingsView({ initialSection: "models", initialSettings: payload });
await user.click(screen.getByRole("button", { name: "OpenAI", exact: true }));
+ expect(screen.queryByRole("combobox", { name: "Default API" })).not.toBeInTheDocument();
+ await user.click(screen.getByRole("button", { name: "Advanced options" }));
expect(screen.getByRole("combobox", { name: "Default API" })).toHaveTextContent("Responses");
await user.click(screen.getByRole("combobox", { name: "Default API" }));
await user.click(screen.getByRole("option", { name: "Chat Completions", exact: true }));
@@ -1063,6 +1071,7 @@ describe("Settings providers", () => {
provider: "openai", api: { supported_apis: ["chat_completions"], preferred_api: "chat_completions" },
}), 20_000);
await user.click(screen.getByRole("button", { name: "OpenAI", exact: true }));
+ await user.click(screen.getByRole("button", { name: "Advanced options" }));
expect(screen.getByRole("combobox", { name: "Default API" })).toHaveTextContent("Chat Completions");
await user.click(screen.getByRole("combobox", { name: "Default API" }));
await user.click(screen.getByRole("option", { name: "Auto", exact: true }));
@@ -1072,6 +1081,7 @@ describe("Settings providers", () => {
provider: "openai", api: null,
}), 20_000);
await user.click(screen.getByRole("button", { name: "OpenAI", exact: true }));
+ await user.click(screen.getByRole("button", { name: "Advanced options" }));
expect(screen.getByRole("combobox", { name: "Default API" })).toHaveTextContent("Auto");
});