feat(provider): add data residency header support for OpenAI Enterprise#15844
feat(provider): add data residency header support for OpenAI Enterprise#15844DusKing1 wants to merge 1 commit into
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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 |
6f74781 to
e48d982
Compare
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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