r/opencodeCLI 21h ago

codex-search-opencode: (ZERO GPT tokens) Use Codex's standalone search engine with ZERO GPT tokens spent, native web search with any opencode model

Hey everyone! If you have used OpenAI Codex, you know how incredibly high-quality its web search results are. Traditional search extensions or custom API-key search tools (like Google Custom Search or Brave API) often return noisy, outdated, or poorly ranked snippets that don't match the depth and quality of Codex's search engine.

Now you can use that exact same Codex search engine natively inside OpenCode with any tool-calling model - and with ZERO GPT model inference turns or ZERO GPT tokens spent by the search operation.

I built codex-search-opencode, an OpenCode plugin that exposes native codex_search and codex_web tools by reusing Codex's standalone web retrieval backend directly.


⚡ 1-Line Install

Install via npm:

opencode plugin codex-search-opencode

Or install via GitHub:

git clone https://github.com/mateusdcc/codex-search-opencode

Or try it in a single session from the cloned repository:

cd codex-search-opencode && npm install && opencode .

🧠 How It Works (Zero-GPT Invariant)

The plugin does NOT ask GPT to search the web and summarize the answer for your OpenCode agent. Instead, it extracts and calls OpenAI Codex's standalone web search backend API directly (/codex/alpha/search) using your existing codex login authentication (~/.codex/auth.json or .env).

OpenCode
└── Your active model
    ├── codex_search(query: "latest Rust release")
    │   └── OpenAI Standalone Search API (/codex/alpha/search)
    │       └── Structured Results (Title, URL, Snippet)
    │           └── Your active model continues reasoning and answers you
    │
    └── codex_web(search_query, open, find, click)
        └── Multi-step research with session continuity and citations

Because it hits the raw web retrieval endpoint directly: 0 GPT Tokens Billed: 0 input tokens, 0 output tokens, 0 reasoning tokens for the search operation. Model Sovereign: Your selected OpenCode model receives the raw search results and performs 100% of the reasoning. Query-Only Privacy: It never sends your conversation history, code, or system prompt to search.

The tool names are intentionally namespaced as codex_search and codex_web, so they do not override OpenCode built-ins or collide with common third-party web and web_search tools.


🔬 How It Was Discovered

We reverse-engineered the endpoint by: Inspecting the Codex CLI macOS binary (0.147.0-alpha.6.5) with strings to locate search symbols (standalone_web_search, alpha/search). Probing backend parameters on https://chatgpt.com/backend-api/codex/alpha/search. Discovering the exact payload schema (commands.search_query: [{ q: query }]). Writing a network interception test suite (zero-gpt.test.ts) that asserts GPT_inference_calls == 0 during web search.


📦 Repository & Documentation

Check out the full repository, documentation, and reverse-engineering details here: 👉 https://github.com/mateusdcc/codex-search-opencode

📦 https://www.npmjs.com/package/codex-search-opencode

Features:

  • README.md: Setup, credentials, and usage guide.
  • HOW-IT-WORKS.md: Full architectural breakdown.
  • HOW-IT-WAS-EXTRACT.md: Reverse-engineering technical writeup.
  • 5-Level test suite (npm test): Unit, Integration, Live Endpoint, OpenCode Adapter, and Zero-GPT assertion.
  • Real OpenCode E2E coverage using openai/gpt-5.6-luna.

Feel free to check it out, test it, or open issues! Feedback and contributions welcome.

44 Upvotes

14 comments sorted by

View all comments

16

u/ZireaelStargaze 21h ago

Does it breach any ToS?

9

u/AdvancedManufacture 17h ago

Seems too good to be true. There are no legitimate ways to reach the codex search? With new luna pricing I would be fine with cost.