feat: support OPENAI_BASE_URL for the openai provider#328
Open
Echo (Pahkho) wants to merge 1 commit into
Open
Conversation
WH-sa
approved these changes
Jul 15, 2026
The `openai` provider had no `baseUrlEnvKey`, so a custom base URL could
only reach it implicitly via the OpenAI SDK reading the `OPENAI_BASE_URL`
env var. Make this explicit and consistent with the `openai-compatible`
and `anthropic` providers:
- Add `OPENAI_BASE_URL_ENV_KEY` and wire it as the `openai` provider's
`baseUrlEnvKey`, so `resolveProviderBaseUrl("openai")` honors it and the
resolved `baseURL` is passed through to the model client.
- Register `OPENAI_BASE_URL` in `MANAGED_ENV_KEYS` so it is loaded from
`~/.openwiki/.env`, persisted in stable order, and surfaced in the
credential diagnostics as a non-secret value (like the other base URL keys).
This lets the `openai` provider target an OpenAI-compatible Responses-API
gateway (e.g. a Codex-backed proxy) directly from `.env`, instead of forcing
users onto the `openai-compatible` provider, which routes tool calls through
chat completions and fails on such gateways.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Echo (Pahkho)
force-pushed
the
feat/openai-base-url-from-env
branch
from
July 16, 2026 01:44
55326f1 to
1f07d86
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
openaiprovider had nobaseUrlEnvKey, so a custom base URL could only reach it implicitly (relying on the OpenAI SDK to readprocess.env.OPENAI_BASE_URL). It was not loaded from~/.openwiki/.envinto the OpenWiki-managed environment, never surfaced in credential diagnostics, and never flowed throughresolveProviderBaseUrllike theopenai-compatibleandanthropicproviders do.Changes
src/constants.ts: addOPENAI_BASE_URL_ENV_KEYand set it as theopenaiprovider'sbaseUrlEnvKey.resolveProviderBaseUrl("openai")now honorsOPENAI_BASE_URL, and the resolved value is passed to the model client viaconfiguration.baseURL(no behavior change when unset — still falls back to the SDK default).src/env.ts: registerOPENAI_BASE_URLinMANAGED_ENV_KEYSso it is loaded from~/.openwiki/.env, persisted in stable order, and shown (non-secret) in credential diagnostics alongsideANTHROPIC_BASE_URL/OPENAI_COMPATIBLE_BASE_URL.README.md: documentOPENAI_BASE_URLfor theopenaiprovider under "Alternative base URLs".Why
Some OpenAI-compatible gateways only expose the Responses API (
/v1/responses) and return502for chat-completions requests that carrytools. Theopenaiprovider already routes tool calls through the Responses API (useResponsesApi: provider === "openai"), so it works against such gateways — but only if the base URL can be configured. With this change, users can target a Responses-API gateway directly from.env:Previously the only
.env-configurable path wasopenai-compatible, which routes tool calls through chat completions and fails with502on these gateways.Notes
OPENAI_BASE_URLwas already removed fromdeprecatedEnvKeysonmain, so it is already loaded from.envintoprocess.env. This PR makes theopenaiprovider consume it explicitly and consistently rather than relying on the SDK's implicit env-var read.OPENAI_BASE_URLis unset;requiresBaseUrlis not set, so the provider remains optional-default.🤖 Generated with Claude Code