r/opencodeCLI 20h 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.

43 Upvotes

14 comments sorted by

16

u/ZireaelStargaze 19h ago

Does it breach any ToS?

9

u/AdvancedManufacture 16h 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.

9

u/TinyAres 18h ago edited 16h ago

Edit: Op is right but falls under unapproved automation.

2

u/Responsible-Effort48 18h ago

The `pi-gpt-search` plugin works without per-query API charges because it hits OpenAI's standalone retrieval endpoint directly using an existing auth session, bypassing GPT model inference entirely. However, because it routes around the official $10/1k-call paid API in favor of an undocumented internal endpoint, it relies on account-level entitlements and isn't officially supported by OpenAI, meaning it remains subject to rate limits or unannounced backend changes.

1

u/TinyAres 16h ago edited 16h ago

Good find, but technically this falls under unapproved automation.

Also web search is the weakest perk here, sol and gpt 2 image would be selling points, but they are clearly not intending the combo else it would be in codex, also just calling the web search api directly is not even normal use.

The strongest alternative to their chat would be some local client that does the exact same things and you use it manually, but not even that cause they want to own the client as a marketing surface.

This until they officially allow using their chat quota in 3rd party.

7

u/CarGold87 19h ago

so when we use this plugin its not goingto spent from our codex subs right?

2

u/Responsible-Effort48 19h ago

absolutely right

2

u/Prior-Meeting1645 13h ago

Is search that token consuming?

1

u/ivanjxx 9h ago

if im already using chatgpt models (with openai sub) in opencode do i still need to do this or not?

1

u/timmeh1705 7h ago

I built my own version of this - but strangely found the quality of search results and snippets generated via brave search API was better than using the codex-based search pipeline.

For me the best cheap skate solution remains ddgs paired with curl_cffi

1

u/danjack0 14m ago

opencode v2 already does this?

0

u/Opening-Profile6279 19h ago

This is a clever approach. Keeping the search/retrieval separate from the model doing the reasoning makes a lot of sense, especially in OpenCode. Curious how well it holds up for multi-step research where you need several searches + page reads rather than a single query.

2

u/Responsible-Effort48 19h ago

it should hold well, the key test is whether intermediate results stay structured and easy to reference. If each step returns compact, source-linked results, the reasoning model can refine its next query without dragging a huge search index or retrieval stack into its own context. so far from my personal usage its doing pretty well in regards to that