Skip to content

returns 401 while Codex CLI works normally #276

@Zoean-z

Description

@Zoean-z

What version of HAPI is running?

0.16.1

What platform is your computer?

Windows11 x86

What issue are you seeing?

Running npx @twsxtd/hapi codex fails with HTTP 401 even though the Codex CLI works normally.

codex CLI works correctly

codex login status shows authenticated using an API key

hapi hub --relay starts successfully

Hub web interface loads normally

However, starting Codex through HAPI fails:

PS C:\Users\Lenovo> npx @twsxtd/hapi codex

Error: Request failed with status code 401
Failed to execute: ...\hapi.exe codex
Binary exited with status 1

This only happens when running Codex through HAPI.
Running codex directly works without any issue.

What steps can reproduce the bug?

Install Codex CLI and HAPI globally:

npm install -g @openai/codex
npm install -g @twsxtd/hapi

Login to Codex using an API key:

codex login
codex login status

Output:

Logged in using an API key - sk-proj-****

Start HAPI hub:

npx @twsxtd/hapi hub --relay

Hub starts successfully.

In another terminal run:

$env:HAPI_API_URL="http://localhost:3006"
npx @twsxtd/hapi codex

The command fails with:

Error: Request failed with status code 401

Notes:

codex CLI works normally outside of HAPI

Proxy environment variables were cleared

Hub is running and accessible at http://localhost:3006

What is the expected behavior?

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions