feat: configurable base_url threaded to all three client sites

Adds CONF_BASE_URL/DEFAULT_BASE_URL and threads base_url through every
AsyncOpenAI construction site: config_flow.validate_input,
__init__.async_setup_entry, and config_flow's web-search geolocation
helper (_get_location_data) — the easy one to miss, since it would
otherwise silently talk to api.openai.com when the user configured a
different endpoint.

Fixes upstream-ported fixtures (conftest.mock_config_entry,
test_config_flow's inline MockConfigEntry/data-schema assertions) to
supply base_url now that the config-flow schema requires it.

No translations/en.json exists in this repo (only strings.json), so
only strings.json got the new "base_url" UI strings.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01739Seac5eMAfNwFeiwV5r4
This commit is contained in:
Adam SmithandClaude Sonnet 5 committed 2026-09-17 17:50:38 -04:00
1 parent 8d2326d435
commit 564c52159f
7 files changed
+50 -4

No files matched your search

+4 -1
View File
@@ -12,6 +12,7 @@ from custom_components.openai_compatible.config_flow import (
RECOMMENDED_CONVERSATION_OPTIONS,
)
from custom_components.openai_compatible.const import (
CONF_BASE_URL,
CONF_CHAT_MODEL,
CONF_CODE_INTERPRETER,
CONF_IMAGE_MODEL,
@@ -35,6 +36,7 @@ from custom_components.openai_compatible.const import (
CONF_WEB_SEARCH_TIMEZONE,
CONF_WEB_SEARCH_USER_LOCATION,
DEFAULT_AI_TASK_NAME,
DEFAULT_BASE_URL,
DEFAULT_CONVERSATION_NAME,
DEFAULT_STT_NAME,
DEFAULT_TTS_NAME,
@@ -90,6 +92,7 @@ async def test_form(hass: HomeAssistant) -> None:
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == {
"api_key": "bla",
"base_url": DEFAULT_BASE_URL,
}
assert result2["options"] == {}
assert result2["subentries"] == [
@@ -127,7 +130,7 @@ async def test_duplicate_entry(hass: HomeAssistant) -> None:
"""Test we abort on duplicate config entry."""
MockConfigEntry(
domain=DOMAIN,
data={CONF_API_KEY: "bla"},
data={CONF_API_KEY: "bla", CONF_BASE_URL: DEFAULT_BASE_URL},
).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(