{"id":50565252,"url":"https://github.com/0oastro/codex-openai-proxy","last_synced_at":"2026-06-04T14:00:55.389Z","repository":{"id":354074327,"uuid":"1221987241","full_name":"0oAstro/codex-openai-proxy","owner":"0oAstro","description":"OpenAI-compatible proxy for ChatGPT/Codex subscription — Rust binary with OAuth PKCE, /v1/responses passthrough, /v1/chat/completions translation, dynamic models, reasoning effort suffixes","archived":false,"fork":false,"pushed_at":"2026-05-27T04:49:53.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-27T06:24:25.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0oAstro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"docs/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-26T23:41:12.000Z","updated_at":"2026-05-27T04:49:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/0oAstro/codex-openai-proxy","commit_stats":null,"previous_names":["0oastro/codex-openai-proxy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/0oAstro/codex-openai-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fcodex-openai-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fcodex-openai-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fcodex-openai-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fcodex-openai-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0oAstro","download_url":"https://codeload.github.com/0oAstro/codex-openai-proxy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fcodex-openai-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33907694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-04T14:00:54.118Z","updated_at":"2026-06-04T14:00:55.376Z","avatar_url":"https://github.com/0oAstro.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# codex-openai-proxy\n\nProxy your ChatGPT/Codex subscription as an OpenAI-compatible API.\n\n## Features\n\n- **OpenAI-compatible endpoints**: `/v1/models`, `/v1/responses`, `/v1/chat/completions`\n- **Usage metrics**: `/usage` returns Codex rate-limit and credit snapshots\n- **OAuth PKCE login**: browser-based authentication with automatic token refresh\n- **Streaming support**: SSE streaming for both responses and chat completions\n- **Chat completions translation**: translates OpenAI chat format to/from Codex Responses API\n- **Reasoning effort**: parse model name suffixes (e.g. `gpt-5.5-xhigh`) into reasoning parameters\n- **Tool/function calling**: full support for function calling in chat completions\n- **Token auto-refresh**: refreshes tokens 5 minutes before expiry\n- **401 retry**: automatically refreshes and retries on auth failures\n\n## Quick Start\n\n```bash\n# Build\ncargo build --release\n\n# Log in (opens browser)\n./target/release/codex-openai-proxy login\n\n# Start the proxy\n./target/release/codex-openai-proxy serve\n\n# Check auth status\n./target/release/codex-openai-proxy auth status\n\n# Log out\n./target/release/codex-openai-proxy logout\n```\n\n## Usage\n\n### Start the server\n\n```bash\n# Default: 0.0.0.0:8080\ncodex-openai-proxy serve\n\n# Custom port\ncodex-openai-proxy serve --port 3000\n\n# Or via environment variable\nPORT=3000 codex-openai-proxy serve\n```\n\n### Authentication\n\n```bash\n# Browser login (OAuth PKCE)\ncodex-openai-proxy login\n\n# Check status\ncodex-openai-proxy auth status\n\n# Logout\ncodex-openai-proxy logout\n```\n\nCredentials are stored in `~/auth.json` by default. Set `CODEX_AUTH_FILE` to use a different path.\n\n## API Endpoints\n\n### `GET /health`\nReturns `{\"status\": \"ok\"}`.\n\n### `GET /v1/models`\nReturns available models in OpenAI format. Cached for 5 minutes.\n\n### `GET /usage`\nReturns Codex usage metrics parsed from the upstream rate-limit headers/events.\n\n### `POST /v1/responses`\nPassthrough to the Codex Responses API. Streams SSE response back verbatim.\n\n### `POST /v1/chat/completions`\nTranslates OpenAI chat completions format to Codex Responses API and back.\nSupports both streaming (`\"stream\": true`) and non-streaming modes.\n\n#### Reasoning effort\nAppend a reasoning suffix to the model name:\n```\ngpt-5.5-none     -\u003e reasoning: none\ngpt-5.5-minimal  -\u003e reasoning: minimal\ngpt-5.5-low      -\u003e reasoning: low\ngpt-5.5-medium   -\u003e reasoning: medium\ngpt-5.5-high     -\u003e reasoning: high\ngpt-5.5-xhigh    -\u003e reasoning: xhigh\n```\n\n## Docker Compose (preferred)\n\n```bash\ndocker network create main-network\ndocker compose up -d\n```\n\nThe container mounts `/opt/codex-openai-proxy/auth.json` from the host to `/root/auth.json` in the container.\n\n## Example: Using with OpenAI SDK\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"http://localhost:8080/v1\",\n    api_key=\"not-needed\"  # Auth is handled by the proxy\n)\n\nresponse = client.chat.completions.create(\n    model=\"gpt-5.5\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n    stream=True,\n)\n\nfor chunk in response:\n    if chunk.choices[0].delta.content:\n        print(chunk.choices[0].delta.content, end=\"\")\n```\n\n## Limitations\n\n- **No WebSocket transport**: The Codex CLI supports a WebSocket mode at `wss://chatgpt.com/backend-api/codex/responses` for persistent connections with `previous_response_id` chaining (~40% faster for 20+ tool-call chains). This proxy only supports HTTP/SSE. Adding WebSocket would require `tokio-tungstenite`, in-memory response state, and the `response.create` event protocol. Note that HTTP gateway proxies (e.g. Bifrost) cannot route WebSocket connections anyway, so this would only benefit direct-to-proxy clients.\n- **Stateless**: Each request is independent. `previous_response_id` and `item_reference` are not supported -- clients must send the full conversation history each turn.\n- **No image endpoint streaming via Bifrost**: Image generation/edit streaming uses custom SSE event types that may not be forwarded by all HTTP gateways.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0oastro%2Fcodex-openai-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0oastro%2Fcodex-openai-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0oastro%2Fcodex-openai-proxy/lists"}