🙌 OpenHands: AI-Driven Development
fix: hide API key for OpenHands provider on cloud (#16863)
Tim O'Farrell8a2161b404d6
diff --git a/__tests__/components/features/settings/sdk-settings/schema-field.test.tsx b/__tests__/components/features/settings/sdk-settings/schema-field.test.tsxindex 3c541d821d..d40018ad5a 100644--- a/__tests__/components/features/settings/sdk-settings/schema-field.test.tsx+++ b/__tests__/components/features/settings/sdk-settings/schema-field.test.tsx@@ -12,8 +12,8 @@ vi.mock("react-i18next", () => ({SCHEMA$VERIFICATION$CRITIC_API_KEY$HELP_TEXT:"If OpenHands is selected as your active LLM provider, leave this empty because the Critic API Key is the same as your OpenHands Provider LLM Key, which you can find in the",SCHEMA$VERIFICATION$CRITIC_API_KEY$HELP_SUFFIX:- "tab of OpenHands Cloud; otherwise, enter a Critic API Key from that page.",- SETTINGS$NAV_API_KEYS: "API Keys",+ "section of OpenHands Cloud; otherwise, enter a Critic API Key from that page.",+ SETTINGS$OPENHANDS_API_KEY_HELP_LINK: "OpenHands LLM Key",})[key] ?? key,}),}));@@ -94,7 +94,7 @@ describe("SchemaField", () => {expect(help).toHaveTextContent("Critic API Key is the same as your OpenHands Provider LLM Key",);- expect(help).toHaveTextContent("API Keys");+ expect(help).toHaveTextContent("OpenHands LLM Key");expect(help).toHaveClass("text-sm");expect(help).toHaveClass("font-normal");expect(diff --git a/__tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsx b/__tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsxindex c8c8dc5e67..eca4cadb61 100644--- a/__tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsx+++ b/__tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsx@@ -12,6 +12,20 @@ import * as useLlmProfilesHook from "#/hooks/query/use-llm-profiles";import * as useActivateLlmProfileHook from "#/hooks/mutation/use-activate-llm-profile";import * as useSaveLlmProfileHook from "#/hooks/mutation/use-save-llm-profile";import ProfilesService from "#/api/profiles-service/profiles-service.api";+import * as activeBackendContext from "#/contexts/active-backend-context";+import type { Backend } from "#/api/backend-registry/types";++const mockCloudBackend: Backend = {+ id: "cloud-1",+ name: "Cloud Backend",+ host: "https://app.all-hands.dev",+ apiKey: "test-key",+ kind: "cloud",+};++vi.mock("#/hooks/use-can-manage-org-profiles", () => ({+ useCanManageOrgProfiles: () => true,+}));vi.mock("#/routes/llm-settings", async () => {const React = await vi.importActual<typeof import("react")>("react");@@ -891,3 +905,63 @@ describe("shouldReapplyProfileAfterSave", () => {).toBe(false);});});++describe("LlmSettingsLocalView - OpenHands provider on cloud", () => {+ const mockSaveMutateAsync = vi.fn();++ beforeEach(() => {+ vi.clearAllMocks();++ vi.mocked(useLlmProfilesHook.useLlmProfiles).mockReturnValue(+ createMockLlmProfilesReturn({+ data: { profiles: [], active_profile: null },+ }),+ );+ vi.mocked(useActivateLlmProfileHook.useActivateLlmProfile).mockReturnValue(+ createMockMutationReturn<+ ReturnType<typeof useActivateLlmProfileHook.useActivateLlmProfile>+ >(vi.fn()),+ );+ vi.mocked(useSaveLlmProfileHook.useSaveLlmProfile).mockReturnValue(+ createMockMutationReturn<+ ReturnType<typeof useSaveLlmProfileHook.useSaveLlmProfile>+ >(mockSaveMutateAsync),+ );+ // Cloud backend: the OpenHands provider is backed by a server-minted key.+ vi.spyOn(activeBackendContext, "useActiveBackend").mockReturnValue({+ backend: mockCloudBackend,+ } as ReturnType<typeof activeBackendContext.useActiveBackend>);+ // Pre-flight validation is a no-op on cloud (returns null), mirroring the+ // real cloud path; the api_key stripping is what we assert here.+ vi.mocked(ProfilesService.validateProfile).mockResolvedValue(null);+ mockSaveMutateAsync.mockResolvedValue({ success: true });+ });++ it("strips api_key and base_url when saving an OpenHands provider profile", async () => {+ const user = userEvent.setup();+ renderWithProviders(<LlmSettingsLocalView />);++ await user.click(screen.getByTestId("add-llm-profile"));++ // The mocked LlmSettingsScreen seeds an openai model by default; switch to+ // an OpenHands provider model and enter an api_key the save must drop.+ const modelInput = screen.getByTestId("mock-basic-model-input");+ await user.clear(modelInput);+ await user.type(modelInput, "openhands/kimi-k3");++ // Give the profile an explicit name so the save payload is deterministic.+ const nameInput = screen.getByTestId("profile-name-input");+ await user.clear(nameInput);+ await user.type(nameInput, "openhands-profile");++ await user.click(screen.getByTestId("save-profile-btn"));++ await waitFor(() => expect(mockSaveMutateAsync).toHaveBeenCalled());+ const request = mockSaveMutateAsync.mock.calls[0][0].request as {+ llm: Record<string, unknown>;+ };+ expect(request.llm.model).toBe("openhands/kimi-k3");+ expect(request.llm).not.toHaveProperty("api_key");+ expect(request.llm).not.toHaveProperty("base_url");+ });+});diff --git a/__tests__/routes/llm-settings.test.tsx b/__tests__/routes/llm-settings.test.tsxindex 7ed33abb30..e56ca03c22 100644--- a/__tests__/routes/llm-settings.test.tsx+++ b/__tests__/routes/llm-settings.test.tsx@@ -1,5 +1,11 @@import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { fireEvent, render, screen, waitFor } from "@testing-library/react";+import {+ fireEvent,+ render,+ screen,+ waitFor,+ within,+} from "@testing-library/react";import { MemoryRouter } from "react-router";import { beforeEach, describe, expect, it, vi } from "vitest";// Import the named export LlmSettingsScreen directly for testing the form component.@@ -434,6 +440,148 @@ describe("LlmSettingsScreen - provider connection selector", () => {});});+describe("LlmSettingsScreen - OpenHands provider on cloud", () => {+ beforeEach(() => {+ vi.restoreAllMocks();+ vi.spyOn(activeBackendContext, "useActiveBackend").mockReturnValue({+ backend: mockCloudBackend,+ } as ReturnType<typeof activeBackendContext.useActiveBackend>);+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(+ buildSettings({ llm_model: "openhands/kimi-k3", llm_api_key_set: true }),+ );+ });++ it("hides the inline API key and base URL inputs for an OpenHands provider model", async () => {+ renderLlmSettingsScreen({+ embedded: true,+ hideSaveButton: true,+ initialValueOverrides: {+ "llm.model": "openhands/kimi-k3",+ "llm.api_key": "",+ "llm.base_url": "",+ },+ });++ await screen.findByTestId("llm-settings-screen");++ expect(screen.queryByTestId("llm-api-key-input")).not.toBeInTheDocument();+ expect(screen.queryByTestId("base-url-input")).not.toBeInTheDocument();+ // The free-models note is still surfaced so the user understands the model.+ expect(+ screen.getByTestId("openhands-free-models-note"),+ ).toBeInTheDocument();+ });++ it("hides the OpenHands API key help link on cloud (the key is server-minted)", async () => {+ renderLlmSettingsScreen({+ embedded: true,+ hideSaveButton: true,+ initialValueOverrides: {+ "llm.model": "openhands/kimi-k3",+ "llm.api_key": "",+ "llm.base_url": "",+ },+ });++ await screen.findByTestId("llm-settings-screen");++ expect(+ screen.queryByTestId("openhands-api-key-help"),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByTestId("openhands-api-key-help-2"),+ ).not.toBeInTheDocument();+ });++ it("strips api_key and base_url from the saved settings payload", async () => {+ const saveSettingsSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockResolvedValue(true);+ renderLlmSettingsScreen({+ initialValueOverrides: {+ "llm.model": "openhands/kimi-k3",+ "llm.api_key": "should-not-be-sent",+ "llm.base_url": "https://should-not-be-sent.example/v1",+ },+ });++ await screen.findByTestId("llm-settings-screen");+ fireEvent.click(screen.getByTestId("save-button"));++ await waitFor(() => expect(saveSettingsSpy).toHaveBeenCalled());+ const payload = saveSettingsSpy.mock.calls[0][0] as Record<string, unknown>;+ const llmPayload = (payload.agent_settings_diff as Record<string, unknown>)+ .llm as Record<string, unknown>;+ expect(llmPayload.model).toBe("openhands/kimi-k3");+ expect(llmPayload).not.toHaveProperty("api_key");+ expect(llmPayload).not.toHaveProperty("base_url");+ });++ it("still shows the API key input for the OpenHands provider on a local backend", async () => {+ vi.spyOn(activeBackendContext, "useActiveBackend").mockReturnValue({+ backend: mockLocalBackend,+ } as ReturnType<typeof activeBackendContext.useActiveBackend>);+ renderLlmSettingsScreen({+ embedded: true,+ hideSaveButton: true,+ initialValueOverrides: {+ "llm.model": "openhands/kimi-k3",+ "llm.api_key": "",+ "llm.base_url": "",+ },+ });++ await screen.findByTestId("llm-settings-screen");++ // Local mode still collects an inline key for the OpenHands provider.+ expect(screen.getByTestId("llm-api-key-input")).toBeInTheDocument();+ const openHandsHelp = screen.getByTestId("openhands-api-key-help");+ expect(openHandsHelp).toBeInTheDocument();+ // The OpenHands provider help uses the split TEXT/LINK/SUFFIX keys (not+ // the stale single-string "API Keys tab" key) and links to OpenHands+ // Cloud's API Keys page, where the OpenHands LLM Key section lives.+ expect(openHandsHelp).toHaveTextContent(+ "SETTINGS$OPENHANDS_API_KEY_HELP_TEXT",+ );+ expect(openHandsHelp).toHaveTextContent(+ "SETTINGS$OPENHANDS_API_KEY_HELP_LINK",+ );+ expect(openHandsHelp).toHaveTextContent(+ "SETTINGS$OPENHANDS_API_KEY_HELP_SUFFIX",+ );+ expect(openHandsHelp).toHaveTextContent(+ "SETTINGS$SEE_HERE_FOR_MORE_DETAILS",+ );+ expect(openHandsHelp).not.toHaveTextContent("SETTINGS$NAV_API_KEYS");+ const helpLinks = within(openHandsHelp).getAllByRole("link");+ expect(helpLinks).toHaveLength(2);+ expect(helpLinks[0]).toHaveAttribute(+ "href",+ "https://app.all-hands.dev/settings/api-keys",+ );+ expect(helpLinks[1]).toHaveAttribute(+ "href",+ "https://docs.openhands.dev/usage/local-setup#getting-an-api-key",+ );+ });++ it("still shows the API key input for a non-OpenHands provider on cloud", async () => {+ renderLlmSettingsScreen({+ embedded: true,+ hideSaveButton: true,+ initialValueOverrides: {+ "llm.model": "openai/gpt-4o",+ "llm.api_key": "",+ "llm.base_url": "",+ },+ });++ await screen.findByTestId("llm-settings-screen");++ expect(screen.getByTestId("llm-api-key-input")).toBeInTheDocument();+ });+});+describe("LlmSettingsRoute - backend mode rendering", () => {beforeEach(() => {vi.restoreAllMocks();diff --git a/scripts/check-translation-completeness.cjs b/scripts/check-translation-completeness.cjsindex 0baeba37a0..52cbc4a2b0 100755--- a/scripts/check-translation-completeness.cjs+++ b/scripts/check-translation-completeness.cjs@@ -60,6 +60,7 @@ const IDENTICAL_VALUE_ALLOWLIST = new Set(['SETTINGS$MCP_SERVER_TYPE_SSE','SETTINGS$MCP_SERVER_TYPE_STDIO','SETTINGS$NAV_LLM',+ 'SETTINGS$OPENHANDS_API_KEY_HELP_LINK','SETTINGS$SKILLS_PILLS_MORE','SETTINGS$SKILLS_VERSION','SETTINGS$SLACK',diff --git a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsxindex 3bb49e0066..9535c550c2 100644--- a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx+++ b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx@@ -33,6 +33,7 @@ import {deriveProfileNameFromModel,isProfileNameValid,} from "#/utils/derive-profile-name";+import { isOpenHandsProviderModel } from "#/utils/format-model-name";import { SdkSectionSaveControl } from "../sdk-settings/sdk-section-page";import {LLM_AUTH_TYPE_API_KEY,@@ -312,27 +313,40 @@ export function LlmSettingsLocalView() {// cloud the field stays untouched below).if (isLocal) llmConfig.provider_connection_id = null;- // The Basic tab has no base_url field. Preserve an existing hidden value- // when the model did not actually change; if the user chooses a new model,- // drop the old base URL so provider defaults can apply to that model.- if (didChangeModelInBasic) {+ // On cloud the OpenHands provider is backed by a server-minted LLM key,+ // so the profile must not carry an inline api_key / base_url — let the+ // backend attach its own credential when the profile is saved.+ const isCloudOpenHandsProvider =+ !isLocal &&+ isOpenHandsProviderModel(+ typeof llmConfig.model === "string" ? llmConfig.model : "",+ );+ if (isCloudOpenHandsProvider) {+ delete llmConfig.api_key;delete llmConfig.base_url;- }+ } else {+ // The Basic tab has no base_url field. Preserve an existing hidden value+ // when the model did not actually change; if the user chooses a new model,+ // drop the old base URL so provider defaults can apply to that model.+ if (didChangeModelInBasic) {+ delete llmConfig.base_url;+ }- // API key handling: an empty value means "no change" (the UX doesn't- // support clearing a key). In edit mode preserve the existing encrypted- // key from the profile; in create mode omit api_key entirely. A newly- // typed key arrives in `dirtyLlm` and wins.- if (- typeof llmConfig.api_key !== "string" ||- llmConfig.api_key.trim() === ""- ) {- const existingKey =- typeof baseConfig.api_key === "string" ? baseConfig.api_key : "";- if (existingKey) {- llmConfig.api_key = existingKey;- } else {- delete llmConfig.api_key;+ // API key handling: an empty value means "no change" (the UX doesn't+ // support clearing a key). In edit mode preserve the existing encrypted+ // key from the profile; in create mode omit api_key entirely. A newly+ // typed key arrives in `dirtyLlm` and wins.+ if (+ typeof llmConfig.api_key !== "string" ||+ llmConfig.api_key.trim() === ""+ ) {+ const existingKey =+ typeof baseConfig.api_key === "string" ? baseConfig.api_key : "";+ if (existingKey) {+ llmConfig.api_key = existingKey;+ } else {+ delete llmConfig.api_key;+ }}}}diff --git a/src/components/features/settings/sdk-settings/field-help.tsx b/src/components/features/settings/sdk-settings/field-help.tsxindex 8f8aa1398f..63c4c66d52 100644--- a/src/components/features/settings/sdk-settings/field-help.tsx+++ b/src/components/features/settings/sdk-settings/field-help.tsx@@ -16,7 +16,7 @@ export const FIELD_HELP_LINKS: Record<href: string;/** Skip rendering the schema description separately when the help text already includes it. */hideDescription?: boolean;- /** Optional trailing copy rendered after the link (e.g. " tab of OpenHands Cloud."). */+ /** Optional trailing copy rendered after the link (e.g. " section of OpenHands Cloud."). */suffixKey?: string;}> = {@@ -30,7 +30,7 @@ export const FIELD_HELP_LINKS: Record<// LLM key when the critic key is empty."verification.critic_api_key": {textKey: "SCHEMA$VERIFICATION$CRITIC_API_KEY$HELP_TEXT",- linkTextKey: "SETTINGS$NAV_API_KEYS",+ linkTextKey: "SETTINGS$OPENHANDS_API_KEY_HELP_LINK",suffixKey: "SCHEMA$VERIFICATION$CRITIC_API_KEY$HELP_SUFFIX",href: "https://app.all-hands.dev/settings/api-keys",hideDescription: true,diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex fc05f272ba..9f96b10f1f 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -4777,21 +4777,21 @@"ca": "Si OpenHands està seleccionat com a proveïdor LLM actiu, deixeu aquest camp buit perquè Critic API Key és la mateixa clau que OpenHands Provider LLM Key, que podeu trobar a la"},"SCHEMA$VERIFICATION$CRITIC_API_KEY$HELP_SUFFIX": {- "en": "tab of OpenHands Cloud; otherwise, enter a Critic API Key from that page.",- "ja": "タブで確認できます。それ以外の場合は、そのページの Critic API Key を入力してください。",- "zh-CN": "标签页中找到;否则,请从该页面输入 Critic API Key。",- "zh-TW": "標籤頁中找到;否則,請從該頁面輸入 Critic API Key。",- "ko-KR": "탭에서 찾을 수 있습니다. 그렇지 않으면 해당 페이지의 Critic API Key를 입력하세요.",- "no": "-fanen i OpenHands Cloud; ellers skriver du inn en Critic API Key fra den siden.",- "it": "scheda di OpenHands Cloud; altrimenti inserisci una Critic API Key da quella pagina.",- "pt": "guia do OpenHands Cloud; caso contrário, insira uma Critic API Key dessa página.",- "es": "pestaña de OpenHands Cloud; de lo contrario, introduce una Critic API Key desde esa página.",- "ar": "علامة التبويب في OpenHands Cloud؛ وإلا فأدخل Critic API Key من تلك الصفحة.",- "fr": "l'onglet d'OpenHands Cloud ; sinon, saisissez une Critic API Key depuis cette page.",- "tr": "sekmesinde bulabilirsiniz; aksi takdirde o sayfadan bir Critic API Key girin.",- "de": "Tab von OpenHands Cloud finden; andernfalls geben Sie einen Critic API Key von dieser Seite ein.",- "uk": "вкладці OpenHands Cloud; інакше введіть Critic API Key з цієї сторінки.",- "ca": "pestanya d'OpenHands Cloud; si no, introduïu una Critic API Key des d'aquesta pàgina."+ "en": "section of OpenHands Cloud; otherwise, enter a Critic API Key from that page.",+ "ja": "セクションで確認できます。それ以外の場合は、そのページの Critic API Key を入力してください。",+ "zh-CN": "部分中找到;否则,请从该页面输入 Critic API Key。",+ "zh-TW": "區塊中找到;否則,請從該頁面輸入 Critic API Key。",+ "ko-KR": "섹션에서 찾을 수 있습니다. 그렇지 않으면 해당 페이지의 Critic API Key를 입력하세요.",+ "no": "-seksjonen i OpenHands Cloud; ellers skriver du inn en Critic API Key fra den siden.",+ "it": "sezione di OpenHands Cloud; altrimenti inserisci una Critic API Key da quella pagina.",+ "pt": "seção do OpenHands Cloud; caso contrário, insira uma Critic API Key dessa página.",+ "es": "sección de OpenHands Cloud; de lo contrario, introduce una Critic API Key desde esa página.",+ "ar": "القسم في OpenHands Cloud؛ وإلا فأدخل Critic API Key من تلك الصفحة.",+ "fr": "la section d'OpenHands Cloud ; sinon, saisissez une Critic API Key depuis cette page.",+ "tr": "bölümünde bulabilirsiniz; aksi takdirde o sayfadan bir Critic API Key girin.",+ "de": "Bereich von OpenHands Cloud; andernfalls geben Sie einen Critic API Key von dieser Seite ein.",+ "uk": "розділі OpenHands Cloud; інакше введіть Critic API Key з цієї сторінки.",+ "ca": "secció d'OpenHands Cloud; si no, introduïu una Critic API Key des d'aquesta pàgina."},"SCHEMA$VERIFICATION$CRITIC_API_KEY$LABEL": {"en": "Critic API Key",@@ -11797,23 +11797,6 @@"uk": "Ключі API дозволяють вам програмно автентифікуватися за допомогою API OpenHands. Зберігайте свої ключі API в безпеці; будь-хто, хто має ваш ключ API, може отримати доступ до вашого облікового запису. Для отримання додаткової інформації про використання API, перегляньте нашу <a>документацію API</a>.","ca": "Les claus d'API us permeten autenticar-vos amb l'API d'OpenHands de manera programàtica. Manteniu les vostres claus d'API segures; qualsevol persona amb la vostra clau d'API pot accedir al vostre compte. Per obtenir més informació sobre com fer servir l'API, consulteu la nostra <a>documentació de l'API</a>."},- "SETTINGS$OPENHANDS_API_KEY_HELP": {- "en": "You can find your OpenHands Provider LLM Key in the <a>API Keys</a> tab of OpenHands Cloud.",- "ja": "OpenHands Provider LLM Key はOpenHands Cloudの<a>APIキー</a>タブで確認できます。",- "zh-CN": "您可以在OpenHands Cloud的<a>API密钥</a>标签页中找到您的 OpenHands Provider LLM Key。",- "zh-TW": "您可以在OpenHands Cloud的<a>API密鑰</a>標籤頁中找到您的 OpenHands Provider LLM Key。",- "ko-KR": "OpenHands Provider LLM Key는 OpenHands Cloud의 <a>API 키</a> 탭에서 찾을 수 있습니다.",- "no": "Du kan finne din OpenHands Provider LLM Key i <a>API-nøkler</a>-fanen i OpenHands Cloud.",- "it": "Puoi trovare la tua OpenHands Provider LLM Key nella scheda <a>Chiavi API</a> di OpenHands Cloud.",- "pt": "Você pode encontrar sua OpenHands Provider LLM Key na guia <a>Chaves de API</a> do OpenHands Cloud.",- "es": "Puede encontrar su OpenHands Provider LLM Key en la pestaña <a>Claves API</a> de OpenHands Cloud.",- "ar": "يمكنك العثور على OpenHands Provider LLM Key في علامة التبويب <a>مفاتيح API</a> في OpenHands Cloud.",- "fr": "Vous pouvez trouver votre OpenHands Provider LLM Key dans l'onglet <a>Clés API</a> d'OpenHands Cloud.",- "tr": "OpenHands Provider LLM Key'inizi OpenHands Cloud'un <a>API Anahtarları</a> sekmesinde bulabilirsiniz.",- "de": "Sie finden Ihren OpenHands Provider LLM Key im Tab <a>API-Schlüssel</a> von OpenHands Cloud.",- "uk": "Ви можете знайти свій OpenHands Provider LLM Key у вкладці <a>Ключі API</a> OpenHands Cloud.",- "ca": "Podeu trobar la vostra OpenHands Provider LLM Key a la pestanya <a>Claus d'API</a> d'OpenHands Cloud."- },"SETTINGS$OPENHANDS_API_KEY_HELP_TEXT": {"en": "You can find your OpenHands Provider LLM Key in the","ja": "OpenHands Provider LLM Key は",@@ -11831,22 +11814,56 @@"uk": "Ви можете знайти свій OpenHands Provider LLM Key у","ca": "Podeu trobar la vostra OpenHands Provider LLM Key a la"},+ "SETTINGS$OPENHANDS_API_KEY_HELP_LINK": {+ "en": "OpenHands LLM Key",+ "ja": "OpenHands LLM Key",+ "zh-CN": "OpenHands LLM Key",+ "zh-TW": "OpenHands LLM Key",+ "ko-KR": "OpenHands LLM Key",+ "no": "OpenHands LLM Key",+ "it": "OpenHands LLM Key",+ "pt": "OpenHands LLM Key",+ "es": "OpenHands LLM Key",+ "ar": "OpenHands LLM Key",+ "fr": "OpenHands LLM Key",+ "tr": "OpenHands LLM Key",+ "de": "OpenHands LLM Key",+ "uk": "OpenHands LLM Key",+ "ca": "OpenHands LLM Key"+ },"SETTINGS$OPENHANDS_API_KEY_HELP_SUFFIX": {- "en": "tab of OpenHands Cloud.",- "ja": "タブで確認できます。",- "zh-CN": "标签页中找到您的 OpenHands Provider LLM Key。",- "zh-TW": "標籤頁中找到您的 OpenHands Provider LLM Key。",- "ko-KR": "탭에서 찾을 수 있습니다.",- "no": "-fanen i OpenHands Cloud.",- "it": "scheda di OpenHands Cloud.",- "pt": "guia do OpenHands Cloud.",- "es": "pestaña de OpenHands Cloud.",- "ar": "علامة التبويب في OpenHands Cloud.",- "fr": "l'onglet d'OpenHands Cloud.",- "tr": "OpenHands Cloud'un sekmesinde bulabilirsiniz.",- "de": "Tab von OpenHands Cloud.",- "uk": "вкладці OpenHands Cloud.",- "ca": "pestanya d'OpenHands Cloud."+ "en": " section of OpenHands Cloud -",+ "ja": "セクションで確認できます -",+ "zh-CN": "部分中找到您的 OpenHands Provider LLM Key -",+ "zh-TW": "區塊中找到您的 OpenHands Provider LLM Key -",+ "ko-KR": "섹션에서 찾을 수 있습니다 -",+ "no": "-seksjonen i OpenHands Cloud -",+ "it": "sezione di OpenHands Cloud -",+ "pt": "seção do OpenHands Cloud -",+ "es": "sección de OpenHands Cloud -",+ "ar": "القسم في OpenHands Cloud -",+ "fr": "la section d'OpenHands Cloud -",+ "tr": "OpenHands Cloud'un bölümünde bulabilirsiniz -",+ "de": "Bereich von OpenHands Cloud -",+ "uk": "розділі OpenHands Cloud -",+ "ca": "secció d'OpenHands Cloud -"+ },+ "SETTINGS$SEE_HERE_FOR_MORE_DETAILS": {+ "en": "see here for more details",+ "ja": "詳しくはこちらを参照してください",+ "zh-CN": "点击此处查看更多详情",+ "zh-TW": "點擊此處查看更多詳情",+ "ko-KR": "자세한 내용은 여기를 참조하세요",+ "no": "se her for mer informasjon",+ "it": "vedi qui per maggiori dettagli",+ "pt": "veja aqui para mais detalhes",+ "es": "ver aquí para más detalles",+ "ar": "انظر هنا لمزيد من التفاصيل",+ "fr": "voir ici pour plus de détails",+ "tr": "daha fazla bilgi için bkz.",+ "de": "siehe hier für weitere Details",+ "uk": "дивіться тут для отримання більш детальної інформації",+ "ca": "veu aquí per a més detalls"},"SETTINGS$CREATE_API_KEY": {"en": "Create API Key",diff --git a/src/routes/llm-settings.tsx b/src/routes/llm-settings.tsxindex 182400dfae..945d6fd9d1 100644--- a/src/routes/llm-settings.tsx+++ b/src/routes/llm-settings.tsx@@ -34,9 +34,11 @@ import {} from "#/constants/llm-subscription";import { useOpenAISubscriptionModels } from "#/hooks/query/use-llm-subscription-models";import { useProviderConnections } from "#/hooks/query/use-provider-connections";+import { useActiveBackend } from "#/contexts/active-backend-context";import {FREE_OPENHANDS_MODEL_NOTE,isFreeOpenHandsModel,+ isOpenHandsProviderModel,} from "#/utils/format-model-name";/** Form-values key for the shared provider connection a profile links to. */@@ -109,9 +111,12 @@ function OpenHandsApiKeyHelp({ testId }: OpenHandsApiKeyHelpProps) {<HelpLinktestId={testId}text={t(I18nKey.SETTINGS$OPENHANDS_API_KEY_HELP_TEXT)}- linkText={t(I18nKey.SETTINGS$NAV_API_KEYS)}+ linkText={t(I18nKey.SETTINGS$OPENHANDS_API_KEY_HELP_LINK)}href="https://app.all-hands.dev/settings/api-keys"suffix={` ${t(I18nKey.SETTINGS$OPENHANDS_API_KEY_HELP_SUFFIX)}`}+ suffixLinkText={t(I18nKey.SETTINGS$SEE_HERE_FOR_MORE_DETAILS)}+ suffixLinkHref="https://docs.openhands.dev/usage/local-setup#getting-an-api-key"+ trailing="."/>);}@@ -160,6 +165,9 @@ export function LlmSettingsScreen({}) {const { t } = useTranslation("openhands");+ const { backend } = useActiveBackend();+ const isCloud = backend.kind === "cloud";+const { data: providerConnections } = useProviderConnections();const connectionOptions = React.useMemo(() => (showProviderConnection ? (providerConnections ?? []) : []),@@ -231,9 +239,15 @@ export function LlmSettingsScreen({typeof values["llm.base_url"] === "string"? values["llm.base_url"]: "";- const showOpenHandsApiKeyHelp = modelValue.startsWith("openhands/");+ const showOpenHandsApiKeyHelp = isOpenHandsProviderModel(modelValue);const authType = resolveLlmAuthType(values[LLM_AUTH_TYPE_KEY]);const isSubscriptionAuth = authType === LLM_AUTH_TYPE_SUBSCRIPTION;+ // On cloud the OpenHands provider is backed by a server-minted LLM key,+ // so the inline API key / base URL inputs are not user-supplied. Local+ // mode still collects an api_key (the OpenHands provider can run against+ // a self-hosted endpoint there).+ const hideInlineCredentials =+ isCloud && showOpenHandsApiKeyHelp && !isSubscriptionAuth;const shouldDisableSubscriptionControls =isDisabled || (isSubscriptionAuth && isWaitingForSubscriptionModels);const subscriptionModelValue = subscriptionModels?.includes(modelValue)@@ -304,7 +318,11 @@ export function LlmSettingsScreen({/>);- const renderApiKeyInput = (testId: string, helpTestId: string) => (+ const renderApiKeyInput = (+ testId: string,+ helpTestId: string,+ openHandsHelpTestId: string,+ ) => (<><SettingsInputtestId={testId}@@ -321,12 +339,19 @@ export function LlmSettingsScreen({}/>- <HelpLink- testId={helpTestId}- text={t(I18nKey.SETTINGS$DONT_KNOW_API_KEY)}- linkText={t(I18nKey.SETTINGS$CLICK_FOR_INSTRUCTIONS)}- href="https://docs.openhands.dev/usage/local-setup#getting-an-api-key"- />+ {/* The OpenHands provider's key lives in the OpenHands Cloud "API+ Keys" tab, so point users there instead of the generic docs page+ that covers both LLM and regular API keys. */}+ {showOpenHandsApiKeyHelp ? (+ <OpenHandsApiKeyHelp testId={openHandsHelpTestId} />+ ) : (+ <HelpLink+ testId={helpTestId}+ text={t(I18nKey.SETTINGS$DONT_KNOW_API_KEY)}+ linkText={t(I18nKey.SETTINGS$CLICK_FOR_INSTRUCTIONS)}+ href="https://docs.openhands.dev/usage/local-setup#getting-an-api-key"+ />+ )}</>);@@ -446,17 +471,15 @@ export function LlmSettingsScreen({{showConnectionSelector ? renderConnectionSelector() : null}- {showOpenHandsApiKeyHelp && !isLinkedToConnection ? (- <OpenHandsApiKeyHelp testId="openhands-api-key-help" />- ) : null}-- {isLinkedToConnection+ {isLinkedToConnection || hideInlineCredentials? null: renderApiKeyInput(// eslint-disable-next-line i18next/no-literal-string -- DOM id, not user-facing"llm-api-key-input",// eslint-disable-next-line i18next/no-literal-string -- DOM id, not user-facing"llm-api-key-help-anchor",+ // eslint-disable-next-line i18next/no-literal-string -- DOM id, not user-facing+ "openhands-api-key-help",)}</>)}@@ -488,13 +511,12 @@ export function LlmSettingsScreen({{isFreeOpenHandsModel(modelValue) ? (<OpenHandsFreeModelsNote />) : null}- <OpenHandsApiKeyHelp testId="openhands-api-key-help-2" /></>) : null}{showConnectionSelector ? renderConnectionSelector() : null}- {isLinkedToConnection ? null : (+ {isLinkedToConnection || hideInlineCredentials ? null : (<SettingsInputtestId="base-url-input"label={t(I18nKey.SETTINGS$BASE_URL)}@@ -508,13 +530,15 @@ export function LlmSettingsScreen({/>)}- {isLinkedToConnection+ {isLinkedToConnection || hideInlineCredentials? null: renderApiKeyInput(// eslint-disable-next-line i18next/no-literal-string -- DOM id, not user-facing"llm-api-key-input",// eslint-disable-next-line i18next/no-literal-string -- DOM id, not user-facing"llm-api-key-help-anchor-advanced",+ // eslint-disable-next-line i18next/no-literal-string -- DOM id, not user-facing+ "openhands-api-key-help-2",)}</>)}@@ -528,6 +552,7 @@ export function LlmSettingsScreen({showProviderConnection,defaultModel,embedded,+ isCloud,isWaitingForSubscriptionModels,settings?.llm_api_key_set,subscriptionModels,@@ -580,12 +605,22 @@ export function LlmSettingsScreen({if (context.view === "basic" && llm.model !== undefined) {llm.base_url = getSchemaFieldDefaultValue(schema, "llm.base_url");}+ // On cloud the OpenHands provider uses a server-minted LLM key, so+ // never send an inline api_key / base_url — let the backend attach its+ // own credential. (Local mode still collects an inline key.)+ if (+ isCloud &&+ isOpenHandsProviderModel(String(context.values["llm.model"] ?? ""))+ ) {+ delete llm.api_key;+ delete llm.base_url;+ }}agentSettings.llm = llm;return { agent_settings_diff: agentSettings };},- [schema, subscriptionModels],+ [schema, subscriptionModels, isCloud],);return (diff --git a/src/ui/help-link.tsx b/src/ui/help-link.tsxindex 7d7017b7fd..496cbd0878 100644--- a/src/ui/help-link.tsx+++ b/src/ui/help-link.tsx@@ -24,6 +24,11 @@ interface HelpLinkProps extends VariantProps<typeof helpLinkVariants> {linkText: string;href: string;suffix?: string;+ /** Optional second link rendered after the suffix. */+ suffixLinkText?: string;+ suffixLinkHref?: string;+ /** Trailing text rendered after the second link (e.g. a period). */+ trailing?: string;className?: string;linkTextClassName?: string;suffixClassName?: string;@@ -35,6 +40,9 @@ export function HelpLink({linkText,href,suffix,+ suffixLinkText,+ suffixLinkHref,+ trailing,size,linkColor,className,@@ -60,6 +68,24 @@ export function HelpLink({{linkText}</a>{suffix && <span className={suffixClassName}>{suffix}</span>}+ {suffixLinkText && suffixLinkHref ? (+ <>+ {" "}+ <a+ href={suffixLinkHref}+ rel="noreferrer noopener"+ target="_blank"+ className={cn(+ "underline underline-offset-2",+ helpLinkVariants({ size, linkColor }),+ linkTextClassName,+ )}+ >+ {suffixLinkText}+ </a>+ {trailing}+ </>+ ) : null}</p>);}diff --git a/src/utils/format-model-name.ts b/src/utils/format-model-name.tsindex 089128b0e4..b17e4461d8 100644--- a/src/utils/format-model-name.ts+++ b/src/utils/format-model-name.ts@@ -8,6 +8,17 @@ export const FREE_OPENHANDS_MODELS = {} as const;export const FREE_OPENHANDS_MODEL_IDS = Object.keys(FREE_OPENHANDS_MODELS);++/**+ * Whether a model id routes through the OpenHands provider (the `openhands/`+ * prefix). On cloud the OpenHands provider is backed by a server-minted LLM+ * key rather than a user-supplied one, so callers use this to hide the inline+ * API key / base URL inputs and strip those fields from the save payload.+ */+export const isOpenHandsProviderModel = (+ model: string | null | undefined,+): boolean => Boolean(model?.startsWith("openhands/"));+export const FREE_OPENHANDS_MODEL_NOTE = `Free OpenHands models: ${FREE_OPENHANDS_MODEL_IDS.join(", ",)}. Other provider endpoints with similar model names may require separate billing.`;