Codex + Tencent LKEAP 401: It Was Not the Key
Description and use
A 401 error was caused by a protocol mismatch between Codex (Responses API) and Tencent LKEAP (Chat Completions). A local Node.js proxy was created to translate requests, and the configuration was updated accordingly.
Problem
Codex misinterpreted a Tencent LKEAP endpoint as a Responses API, appending "/responses" to a Chat Completions URL and causing a 401 error.
Outcome
The 401 error was caused by a protocol mismatch; a local proxy successfully bridged the gap, allowing Codex to communicate with Tencent LKEAP.
Workflow
- Inspect the final request URL for unexpected path patterns.
- Confirm the client’s wire protocol (Responses vs Chat Completions).
- Verify the upstream endpoint’s expected URL shape.
- If mismatch, either adjust the client config or implement a local protocol adapter.
- Set up a local Node.js proxy that forwards Responses requests to the correct Chat Completions URL.
- Configure Codex to point to the proxy and provide a dummy OPENAI_API_KEY.
- Test the setup with a real Tencent LKEAP API key and validate responses.
- Document any remaining gaps (streaming, tool‑call traffic, error mapping).
Evidence
unexpected status 401 Unauthorized
invalid configuration: wire_api = "chat" is no longer supported.
- Record date: 2026-09-05T13:58:38.697Z