Skip to content

Repository files navigation

codex-oauth-proxy

English | 简体中文

This project was written by AI. Use it at your own risk.


codex-oauth-proxy forwards Codex requests through managed API keys using OAuth credentials from Codex CLI.

Features

  • Proxies Codex CLI and supported OpenAI-compatible requests.
  • Provides a focused Zed Edit Prediction endpoint for Qwen FIM prompts.
  • Manages cop_... API keys for proxy users.
  • Uses health-aware Codex OAuth failover, cooldowns, and coordinated token refresh.
  • Persists tenant-scoped session affinity without storing raw session identifiers.
  • Records per-user token usage and provides an optional Grafana dashboard.

Quick Start

Build the proxy:

go build -o codex-oauth-proxy ./cmd/server
cp config.example.yaml config.yaml
codex-oauth-proxy --config config.yaml

In another terminal, create a managed user:

codex-oauth-proxy admin users create alice

The command prints the generated API key once. Configure Codex CLI to use it:

model_provider = "proxy"
chatgpt_base_url = "http://127.0.0.1:8317/backend-api/"

[model_providers.proxy]
name = "Codex OAuth Proxy"
base_url = "http://127.0.0.1:8317/v1"
env_key = "COP_API_KEY"
wire_api = "responses"
supports_websockets = true
requires_openai_auth = false
export COP_API_KEY="cop_..."
codex

The local admin CLI calls a loopback-only endpoint and does not require admin-api-key. Set admin-api-key only when remote management API or Grafana access is needed.

Docker

For containers, set host: "0.0.0.0" in config.yaml, place Codex OAuth JSON files under ./auths, and start the service:

docker compose up -d

Run local administration inside the container:

docker exec codex-oauth-proxy \
  /codex-oauth-proxy/codex-oauth-proxy admin users create alice

See Getting Started for native and Docker setup details.

Documentation

License

Licensed under the Apache License, Version 2.0. See LICENSE.

About

Local Codex OAuth-backed proxy for Codex CLI and Responses API clients, with token refresh, managed API keys, usage tracking, and Docker support.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages