feat(provider): add data residency header support for OpenAI Enterprise#15844
Open
DusKing1 wants to merge 1 commit intoanomalyco:devfrom
Open
feat(provider): add data residency header support for OpenAI Enterprise#15844DusKing1 wants to merge 1 commit intoanomalyco:devfrom
DusKing1 wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Author
|
I verified this change locally and it works as expected. After configuring |
|
it looks good and looking forward to see this in the official version |
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.
Issue for this PR
No existing issue — this addresses a gap in OpenAI Enterprise support for non-US regions using Codex OAuth.
Type of change
What does this PR do?
Adds the
x-openai-internal-codex-residencyHTTP header to OpenAI Codex provider requests inpackages/opencode/src/plugin/codex.ts.Problem: OpenAI Enterprise workspaces with US data residency reject Codex API requests from non-US regions with
401 "Workspace is not authorized in this region". OpenCode's Codex auth plugin shares the identical OAuth flow, client ID, and endpoint as OpenAI's own Codex CLI — but is missing this one header.Fix: Read
enforce_residencyfrom provider options and setx-openai-internal-codex-residencyin thechat.headershook. This mirrors exactly how Codex CLI handles it incodex-rs/core/src/default_client.rs. Users configure it viaopencode.json:{ "provider": { "openai": { "options": { "enforce_residency": "us" } } } }The provider options schema already uses
.catchall(z.any()), so no schema changes are needed.How did you verify your code works?
enforce_residencyis set in provider configScreenshots / recordings
N/A — backend-only change, no UI impact.
Checklist