Skip to content

Custom API Endpoints doesn't work #20997

Closed

Description

@MH0386

I tried to use the new Custom API Endpoints via Environment Variables, but it seems to have a bug.

I added this:

engine:
  id: codex
  model: "openrouter/free"
  env:
    OPENAI_BASE_URL: "https://openrouter.ai/api/v1"
    OPENAI_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}

But I found this in the agent job log. It seems to use gpt-5.3-codex model.

2026-03-14T22:21:22.758990Z DEBUG session_init: codex_core::codex: Configuring session: model=gpt-5.3-codex; provider=ModelProviderInfo { name: "OpenAI", base_url: Some("http://172.30.0.30:10000/v1"), env_key: None, env_key_instructions: None, experimental_bearer_token: None, wire_api: Responses, query_params: None, http_headers: Some({"version": "0.114.0"}), env_http_headers: Some({"OpenAI-Organization": "OPENAI_ORGANIZATION", "OpenAI-Project": "OPENAI_PROJECT"}), request_max_retries: None, stream_max_retries: None, stream_idle_timeout_ms: None, requires_openai_auth: true, supports_websockets: true }

Knowing that I tried to configure Codex locally with the same base URL (https://openrouter.ai/api/v1) and model (openrouter/free), and it works properly.

~/.codex/config.toml:

model_provider = "openrouter"
model="openrouter/free"

[model_providers.openrouter]
name = "openrouter"
base_url="https://openrouter.ai/api/v1"
env_key="OPENROUTER_API_KEY"

The agent summary:

Agentic Conversation
Conversation:

Agent: stream disconnected before completion: stream closed before response.completed

Agent: Reconnect attempts: 5/5

Statistics:
MCP Gateway
  • ✓ startup MCPG Gateway version: v0.1.15
  • ✓ startup Starting MCPG with config: stdin, listen: 0.0.0.0:80, log-dir: /tmp/gh-aw/mcp-logs/
  • ✓ startup Loaded 2 MCP server(s): [github safeoutputs]
  • ✓ startup Guards sink server ID logging enrichment disabled
  • ✓ backend
    Successfully connected to MCP backend server, command=docker
    
  • 🔍 rpc github→tools/list
  • 🔍 rpc safeoutputs→tools/list
  • 🔍 rpc safeoutputs←resp {"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"create_pull_request","description":"Create a new GitHub pull request to propose code changes. Use this after making file edits to submit them for review and merging. The PR will be created from the current branch with your committed changes. For code review comments on an existing PR, use create_pull_request_review_comment instead. CONSTRAINTS: Maximum 1 pull request(s) can be created. Title will be prefixed with \"[code-simplifier] \". Labels [\"refactori...
  • 🔍 rpc github←resp {"jsonrpc":"2.0","id":1,"result":{"tools":[{"annotations":{"readOnlyHint":true,"title":"Get commit details"},"description":"Get details for a commit from a GitHub repository","inputSchema":{"properties":{"include_diff":{"default":true,"description":"Whether to include file diffs and stats in the response. Default is true.","type":"boolean"},"owner":{"description":"Repository owner","type":"string"},"page":{"description":"Page number for pagination (min 1)","minimum":1,"type":"number"},"perPage":{"descriptio...
  • ✓ startup Starting in ROUTED mode on 0.0.0.0:80
  • ✓ startup Routes: /mcp/ for servers: [github safeoutputs]
Firewall Activity

▼ 6 requests | 6 allowed | 0 blocked | 1 unique domain

Domain Allowed Denied
openrouter.ai 6 0

Activity

  1. locked and limited conversation to collaborators on Mar 14, 2026
  2. unlocked this conversation on Mar 14, 2026
  3. pelikhan commented on Mar 15, 2026

    @pelikhan
    Collaborator

    @copilot update the agentic engine to declare the command api base url environment variable like "OPENAI_BASE_URL" (determine the ones from copilot/claude/gemini) and configure the api-target URL passed to awf accordingly. The compiler should detect this environment variable in the yaml and special treat it. Make sure the example above is operational.

  4. agross commented on Mar 17, 2026

    @agross

    Same for me, but with MiniMax:

    Firewall Activity

    ▼ 3 requests | 3 allowed | 0 blocked | 2 unique domains

    Domain Allowed Denied
    api.minimax.io 2 0
    raw.githubusercontent.com 1 0
  5. locked and limited conversation to collaborators on Mar 17, 2026
  6. unlocked this conversation on Mar 17, 2026
  7. samuelkahessay commented on Mar 22, 2026

    @samuelkahessay

    Still reproducible for me on gh-aw v0.62.5 with OpenRouter.

    Using engine.id: codex plus OPENAI_BASE_URL: https://openrouter.ai/api/v1, the compiled run kept Codex on the AWF proxy path (--enable-api-proxy + --openai-api-target openrouter.ai). At runtime Codex initialized against the local AWF proxy with the built-in OpenAI provider and supports_websockets: true, then failed with:

    failed to connect to websocket: HTTP error: 200 OK, url: ws://172.30.0.30:10000/v1/responses
    falling back to HTTP
    

    The only repo-side workaround I found is patching the generated lockfile after gh aw compile to remove the AWF proxy path and inject a custom Codex provider with supports_websockets = false. That makes OpenRouter work over HTTP-only transport, but it changes the trust boundary because Codex then reads OPENAI_API_KEY directly instead of staying behind the AWF proxy.

    So the remaining gap appears to be: there is still no supported way to keep AWF proxy-based credential isolation and force HTTP-only transport for a custom OpenAI-compatible provider.

  8. locked and limited conversation to collaborators on Mar 22, 2026
  9. unlocked this conversation on Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions