Support secret-backed custom OpenAI-compatible endpoint for Codex workflows
Summary
gh-aw currently appears to support Codex workflows with its generated AWF OpenAI API proxy target, but custom OpenAI-compatible endpoints are effectively compile-time/static. This makes it hard to use a private OpenAI-compatible proxy/load balancer when the endpoint host itself must be treated as a secret.
Request: add first-class support for configuring the Codex/OpenAI API proxy target from a GitHub Actions secret at runtime, without writing the endpoint host into the committed .lock.yml.
Use Case
We run engine: codex workflows through an internal OpenAI-compatible load balancer/proxy. The proxy host is sensitive and must not appear in:
- committed workflow source
- generated
.lock.yml - generated AWF config in the repository
- workflow logs
- uploaded gh-aw/AWF artifacts
- detection artifacts
- sandboxed agent environment
The API key can already be a secret, but the base URL/host needs the same treatment.
Today, the only practical workaround is to compile normally and then patch the generated lockfile so the runner reads a secret, mutates the AWF config, excludes the secret from the sandboxed agent environment, and redacts artifacts. That works, but it is brittle and has to track generated lockfile internals.
Desired Configuration Shape
Exact syntax is flexible, but something like this would solve it:
engine: codex
openai:
base-url-secret: CODEX_LB_BASE_URL
or:
api-proxy:
targets:
openai:
base-url-secret: CODEX_LB_BASE_URL
The generated workflow would then read ${{ secrets.CODEX_LB_BASE_URL }} at runtime and configure AWF's OpenAI target from that value.
Requirements
For this to work securely, gh-aw/AWF would need to guarantee:
gh aw compilemust not write the endpoint value or derived host into the committed.lock.yml.- The generated workflow should read the endpoint from a GitHub Actions secret at runtime.
- AWF should route Codex/OpenAI-compatible traffic through that endpoint.
- AWF/network policy should allow the derived host from the secret at runtime.
- The endpoint secret should be available only to runner-side setup/AWF configuration code.
- The endpoint secret should not be passed into the sandboxed agent environment.
- The full URL, host, and host:port should be masked/redacted from logs.
- The full URL, host, and host:port should be redacted from uploaded artifacts.
- The behavior should apply consistently to all gh-aw phases, including agent and detection jobs.
- Validation should reject invalid values at runtime, e.g. non-HTTP(S) URLs, embedded credentials, or malformed hosts.
Possible Implementation Direction
One option is to model this directly in the AWF config, for example:
{
"apiProxy": {
"targets": {
"openai": {
"baseUrlEnv": "CODEX_LB_BASE_URL"
}
}
}
}
Then gh-aw could emit the secret env binding and AWF could:
- parse the runtime URL
- derive
host,host:port, and optionalbasePath - add the derived host to runtime network allow-listing
- configure the OpenAI target
- mask/redact the value and derived host forms
Alternatively, gh-aw could generate an explicit setup step before AWF starts, but having AWF understand baseUrlEnv would be cleaner and less generated-YAML-sensitive.
Current Workaround
We currently wrap gh aw compile with a repository script that:
- runs
gh aw compile - patches the generated
.lock.yml - injects a runtime step that reads
CODEX_LB_BASE_URL - mutates
${RUNNER_TEMP}/gh-aw/awf-config.json - adds
--exclude-env CODEX_LB_BASE_URLto the AWF command - injects redaction before artifact upload
This works, but it is not ideal because it depends on generated lockfile structure and needs to be kept in sync with gh-aw changes.
Why This Matters
This would let teams use gh-aw normally with private OpenAI-compatible routing infrastructure while preserving the security properties expected from GitHub Actions secrets. It would also remove the need for post-generation lockfile patching and make generated workflows easier to audit.
Addidional context from research agents:
Here’s the aggregated version, tightened into one GitHub-ready comment:
Additional context from digging into current main — sharing the precise mechanics in case it helps whoever picks this up.
Static custom endpoints are partially supported today, but not this secret-backed Codex/OpenAI case.
From what I can tell, the current OpenAI/Codex API proxy target is resolved at compile time:
gh-awderivesapiProxy.targets.openai.hostfrom a literalengine.env.OPENAI_BASE_URL, not from a runtime-resolved secret.extractAPITargetHost()parsesengine.env.OPENAI_BASE_URLduringgh aw compile.- The result is baked into
apiProxy.targets.openai.hostinawf-config.json. - That JSON is embedded as a static string in the generated
.lock.yml.
engine.api-target is used in other paths, especially allow-list/domain handling and Copilot target selection, but it does not appear to configure the OpenAI/Codex API proxy target directly. That creates some docs ambiguity: docs/enterprise-configuration.md says engine.api-target works with any engine, but the Codex/OpenAI config path appears to use OPENAI_BASE_URL for the actual OpenAI proxy target.
So setting:
OPENAI_BASE_URL: ${{ secrets.CODEX_LB_BASE_URL }}
is not equivalent to supported static endpoint configuration. It breaks in several ways:
- Host parsing — the compiler cannot derive
host/basePathfrom a secret expression at compile time. In some paths, secret expressions can be misinterpreted as literal hosts or preserved into static config in the wrong shape. - Firewall allow-listing — the allowed domains are computed at compile time and frozen into the generated lockfile. A runtime-secret host cannot be included unless there is explicit runtime handling. Separately, the Codex/OpenAI custom host does not appear to be merged into the allow-list in the same way as some other engines, so even static custom hosts may currently require a manual
network.allowedentry. - Strict-mode env handling — a secret-bearing
OPENAI_BASE_URLis treated as an unsafe engine env value. - Artifact / config exposure — the endpoint, or derived forms like host / host:port / basePath, can still end up in runtime config or uploaded artifacts unless separately redacted.
- Threat detection parity — detection jobs need the same handling as the main agent job.
The feature still seems tractable because some of the needed primitives already exist:
- Runtime injection into
awf-config.jsonalready exists for another field via the${GH_AW_MAX_AI_CREDITS}preservation flow. --exclude-env/ComputeAWFExcludeEnvVarNamesalready provides a mechanism to keep secret-valued env vars out of the sandboxed agent.secret-masking.stepsis an existing hook for extra redaction.- Allowed-domain handling already has some support for preserving expressions into runtime config.
A minimal implementation could look like:
-
Allow AWF to accept a runtime env-backed OpenAI target, for example:
"apiProxy": { "targets": { "openai": { "baseUrlEnv": "CODEX_LB_BASE_URL" } } }or equivalent
hostEnv/basePathEnvfields. -
At AWF startup, read the env var and validate/split it into:
- scheme, restricted to HTTP(S)
- host
- optional port
- optional base path
It should reject embedded credentials and malformed hosts.
-
Ensure the derived host / host:port is allowed by the network policy, either in AWF or emitted by
gh-awas part of the runner-side setup. -
Have
gh-awemit the secret env binding only for runner-side setup / AWF execution, add it to--exclude-env, and avoid exposing it to the sandboxed agent. -
Add the resolved endpoint and derived forms — full URL, host, host:port, basePath if relevant — to the redaction value set so uploaded gh-aw/AWF artifacts do not contain the secret endpoint.
-
Apply the same flow to both normal agent execution and threat detection execution.
One related note on the pre-step workaround: patching awf-config.json in pre-agent-steps is fragile because those steps run before the generated “Execute Agent CLI” step, which rewrites awf-config.json. That means pre-step patches can be clobbered, which is why the current workaround has to patch the generated lockfile rather than use a supported hook.
So I think the requested support likely needs changes on both sides:
- AWF needs an env-backed runtime API proxy target form.
gh-awneeds to emit that runtime binding safely, exclude it from the agent env, wire the derived host into network policy, and redact all derived endpoint forms from artifacts.
A good smoke-test target for this feature, once the secret-backed base_url flow exists, is a plain hosted OpenAI-compatible endpoint rather than a vendor-specific SDK path. One example is AI Router:
- Site: https://ai-router.dev
- API base URL:
https://api.ai-router.dev/v1 - Auth: standard bearer key
- Discovery:
/v1/models - Chat path:
/v1/chat/completions
That makes it useful for validating the exact things the issue cares about:
- base URL injected from a GitHub secret at runtime
- URL never baked into the committed lockfile
- derived host/path redaction in logs and artifacts
- no leak of endpoint env vars into the sandboxed agent environment
- clear separation between endpoint resolution failure, auth failure, and model mismatch
I also published a small public examples repo for this endpoint shape if it helps with QA or docs references: https://github.com/airouter-dev/ai-router-openai-compatible-examples
And for generic compatibility work, this checklist page is handy too: https://github.com/airouter-dev/ai-router-openai-compatible-examples/blob/main/docs/byok-smoke-test-checklist.md
I have implemented it in my fork which works for me (can be used for reference): https://github.com/JKamsker/gh-aw/tree/jk/secret-backed-openai-endpoint
Is there anything i can do to help getting this issue implemented here? @pelikhan
Can you distillate your fork changes into a comment here?
🔗 AWF tracking issue: https://github.com/github/gh-aw-firewall/issues/github/gh-aw-firewall#6650
Generated by Firewall Issue Dispatcher · sonnet46 · 30.4 AIC · ⊞ 6.4K · ◷
🔗 AWF tracking issue: https://github.com/github/gh-aw-firewall/issues/7575
Addressed by github/gh-aw-firewall#7576, building on github/gh-aw-firewall#6656, with runtime secret-backed OpenAI-compatible target support.