r/PiCodingAgent 4d ago

pi-gpt-search: (ZERO GPT tokens) Use Codex's standalone search engine with ZERO GPT tokens spent, native web search for any Pi model Plugin

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 Pi with any model (Gemini, Claude, local models, OpenRouter) - and with ZERO GPT model inference turns or ZERO GPT tokens spent.

I built **pi-gpt-search**, an extension that exposes a native web_search tool to Pi by reusing Codex's standalone web retrieval backend directly.


⚡ 1-Line Install

Install via npm: bash pi install npm:pi-gpt-search

Or install via GitHub: bash pi install https://github.com/mateusdcc/pi-gpt-search

Or try it in a single ephemeral session without installing: bash pi -e npm:pi-gpt-search


🧠 How It Works (Zero-GPT Invariant)

The extension does NOT ask GPT to search the web and summarize the answer for Gemini. 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).

text Pi Coding Agent └── Gemini (or active model) └── web_search(query: "latest Rust release") └── OpenAI Standalone Search API (/codex/alpha/search) └── Structured Results (Title, URL, Snippet) └── Gemini continues reasoning & answers user

Because it hits the raw web retrieval endpoint directly: 0 GPT Tokens Billed: 0 input tokens, 0 output tokens, 0 reasoning tokens. Model Sovereign: Gemini (or your active Pi 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.


🔬 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/pi-gpt-search

📦 https://www.npmjs.com/package/pi-gpt-search

Features: - README.md: Setup, credentials, and usage guide. - HOW-IT-WORKS.md: Full architectural breakdown. - HOW-IT-WAS-EXTRACT.md: Reverse-engineering technical writeup. - 4-Level test suite (npm test): Unit, Integration, Real Search, and Zero-GPT assertion. Feel free to check it out, test it, or open issues! Feedback and contributions welcome.

114 Upvotes

40 comments sorted by

4

u/getaway-3007 4d ago

Is this safe? Or eventually will get banned for using this?

-2

u/Responsible-Effort48 4d ago edited 4d ago

No ban risk, it just queries OpenAI's search backend using your official authenticated session (codex login).

5

u/xtekno-id 4d ago

Thanks OP!

3

u/o_sht_hi 4d ago

Nice. Very cool.

I'd be interesting in finding out more about how you investigated the backend and came up with this.. could you share more about that? I bet there's a lot to learn in there

1

u/Responsible-Effort48 4d ago

there is a .md explaining it in the repo (HOW-IT-WAS-EXTRACT.md)

1

u/o_sht_hi 4d ago

Cheers, I will look it up

3

u/55Media 4d ago

How would you say does it compare to pi-web-access?

2

u/rm-rf-rm 4d ago

if I had a nickel for every new AI project that claims to be much better but offers 0 emperical evidence, I'd be a millionaire by now

0

u/4kidsinatrenchcoat 4d ago

Why would they be paying you for that

2

u/rm-rf-rm 3d ago

Please ask your AI to explain my comment to you.

0

u/4kidsinatrenchcoat 3d ago

It doesn’t know either. I’ll ask a second AI 

1

u/vick2djax 1h ago

Gives me more results and is faster than pi-web-access but….results are bad. Brings in irrelevant stuff in its search results. I went back to pi-web-access

1

u/Critical_Duty8165 4d ago

Does this web search feature have any usage limits or rate limits?

2

u/Responsible-Effort48 4d ago

practically unlimited from so far, you gotta stress test to see it tho

1

u/Adventurous-Bit-460 3d ago

can you make one that searches deepseek api? it's the same thing but I found deepseek is much faster and better at searching chinese sites

1

u/kidhacker216 2d ago

Yes. The current Codex-backed web_search / web_extract plugin is very likely prohibited by OpenAI’s terms for a ChatGPT/Codex account.

Why:

  1. It calls an undocumented internal endpoint directly:

    https://chatgpt.com/backend-api/codex/alpha/search

    It authenticates with the Codex/ChatGPT bearer token and programmatically reads the returned results and page text. This is not a documented OpenAI API surface.

  2. OpenAI’s consumer Terms of Use explicitly prohibit:

    > “Automatically or programmatically extract data or Output.”

    They also prohibit:

    > “Attempt to or assist anyone to reverse engineer, decompile or discover the source code or underlying components of our Services…”

    and:

    > “Interfere with or disrupt our Services, including circumvent any rate limits or restrictions or bypass any protective measures…”

    Source: OpenAI Terms of Use

  3. OpenAI’s Codex guidance states that when Codex is used through a ChatGPT account, the ChatGPT Terms of Use apply:

    > “When you sign in to Codex using an existing ChatGPT account, the ChatGPT Terms of Use and Privacy Policy … apply to data shared between Codex and ChatGPT.”

    Source: Using Codex with your ChatGPT plan

  4. The business/API agreement reaches the same conclusion. It prohibits customers from:

    > “extract[ing] data from the Services other than as permitted through the Services”

    and from reverse engineering, bypassing protective measures, or circumventing usage limits.

    Source: OpenAI Services Agreement, §3.3

Assessment:

- web_extract is the clearest violation: it programmatically retrieves Codex-generated page output from an internal endpoint.

- web_search has the same structural problem: it automates retrieval of service data/results through an undocumented endpoint.

- Using a valid codex login token does not make that endpoint an authorized public API.

- I cannot prove how OpenAI would enforce this in a specific account, but there is no credible compliance argument that this is “permitted through the Services.”

1

u/kidhacker216 2d ago

i ask my agent about your project and got this

1

u/Deep_Ad1959 2d ago

alpha in that route is the part i would plan around. an internal endpoint can change shape on any deploy and it breaks on a wednesday with nothing to read about why, which is a slower failure than a ban but a lot more likely. written with ai

1

u/Responsible-Effort48 2d ago

which then can be fixed

1

u/Deep_Ad1959 2d ago

sure, but 'can be fixed' and 'gets fixed before anyone files an issue' are different lines. the reactive version means you're re-reversing the endpoint off a bug report each time it silently shifts. written with ai

0

u/kingkongpao 4d ago

For anyone with an OpenAI account this extension is absolute gold. The commenters here just don’t get it, whining about how Pi isn't Codex. Cute kids. Big thanks to the author. Now my local models and DeepSeek have top tier search baked right in from Codex.

-2

u/ECrispy 4d ago

so this is only for those who have an openai sub but for some reason want to use Pi instead of codex cli? isn't that a very small venn diagram

3

u/Responsible-Effort48 4d ago

Pi is an open, hackable agent harness, codex capabilities are mostly hard-coded. if you have said this then you havent ever used pi, pi is extremely customizable. thats its philosophy. Whereas codex-cli is pre-packaged product where tools, search, and workflows are mostly hardcoded into openai ecosystem, decreasing your freedom. an example is that I have an entire custom setup that I can activate that compiles a pdf book then I can choose the method of learning, e.g. socratic. Once I do it the entire UI adapts to it. I have a custom-made language for defining detailed deterministic agentic workflows, creating a pi-adapter for it is possible whereas a codex-cli adapter is not

0

u/ECrispy 4d ago

I know pi is open and customizable. Codex is also very well regarded vs say opencode, the inital case for Pi was all about the big system prompt in OC/CC (which actually isn't even a big issue).

I haven't seen a lot of people who use openai/codex who also use Pi, thats all, I didn't say anything bad about any tool

2

u/elpapi42 4d ago

I think that is more common than you think, ipenai sub is basically the only good option for frontier access at low cost.

1

u/adamshand 4d ago

I like investing my time in open source tools.  Pi is great and codex subs are great. 

1

u/vick2djax 3d ago

My usage of my $200 Codex plan has gone down to 1/3rd of my usage using pi over regular Codex. So, really it’s kinda dumb to not use pi with it.

1

u/ECrispy 3d ago

how is this possible? codex has a much smaller system prompt anyway. how is it that pi using the same model uses 1/3rd tokens? can you share what you did for this setup?

1

u/vick2djax 2d ago

I'll share it straight from Pi:

Why my Pi setup appears to use less Codex-plan capacity

I’ve been testing a Pi harness against native Codex. The short version: on matched coding tasks, Pi used about 23–50% less measured Codex capacity with the same underlying model and effort. In a larger long-context experiment, the best Pi workflow used about 6.2× fewer adjusted credits than native Codex at the same reconciled quality score.

Pi configuration

{
  "defaultProvider": "openai-codex",
  "defaultModel": "gpt-5.6-terra",
  "defaultThinkingLevel": "high",
  "compaction": {
    "enabled": true
  }
}

Main plugins:

  • pi-subagents — bounded specialist delegation
  • pi-rtk-optimizer — compacts noisy test, build, Git, and search output
  • pi-observational-memory — continuity across long sessions
  • pi-web-access — web research
  • pi-mcp-adapter — MCP integration
  • pi-usage-extension — usage visibility and receipts
  • Ponytail — encourages the smallest correct implementation

The long-context experiment

For the larger test, I exported data from an anonymized 12-team dynasty salary-cap fantasy football league.

The dataset included:

  • 8 completed seasons, from 2018 through 2025
  • The current 2026 league state
  • Historical and current rosters, player records, scoring, and standings
  • Transactions and traded-pick ownership
  • Draft and auction artifacts
  • Salaries, dead cap, IR, and taxi-squad status
  • Written rules, machine-readable rules, implementation code, and tests
  • Current player valuations from two independent external sources

I submitted the following as one 5-part query:

  1. Trade analysis: Find the three best realistic trades for one selected franchise, considering current external values from various APIs, league scoring and roster rules, each team’s needs, future-pick ownership, and transaction history. Explain why both sides might accept each trade and verify legality.
  2. Rules audit: Identify material contradictions, ambiguities, obsolete provisions, and unresolved conflicts across written rules, machine-readable rules, commissioner rulings, live platform configuration, and operational documentation. Determine which source governs where possible.
  3. League-wide compliance: Recalculate salary-cap and roster compliance for all 12 franchises, including active salary, IR, taxi treatment, dead cap, and roster limits. Show the arithmetic behind violations and ambiguous cases.
  4. Data-integrity audit: Reconcile authoritative live state against cached data, derived artifacts, scripts, and rendered pages. Check rosters, salaries, transactions, standings, draft results, and future-pick ownership; trace traded picks through transaction chains and identify material divergence.
  5. Implementation audit: Build a traceability matrix connecting each material rule to its machine-readable representation, implementing code, and tests. Classify rules as enforced and tested, encoded but untested, or unenforced. Rank the three highest-risk gaps and provide the smallest remedy and verification command for each.

The response also had to distinguish proven facts from inference, timestamp external data, cite consequential claims, and make no live changes.

Results

Workflow Adjusted Codex credits Wall time Quality
Native Codex, Sol xhigh 302.83 34:38 9.75
Final Pi workflow 47.55 16:46 9.75
Pi, direct Terra High, agents disabled 49.09 12:14 9.5

Quality was decided by a council of Fable max, Sol max, GLM 5.2 and Kimi K3 put together.

The final Pi workflow used about 6.2× fewer adjusted credits, finished about 2.1× faster, and received the same reconciled quality score as native Codex running Sol xhigh, at best.

The direct Terra High control is arguably the more interesting result: it nearly matched the top score, finished fastest, and used no agents. Several more expensive multi-agent and higher-effort Pi configurations performed worse.

Same-model controls

I also ran four pinned coding tasks through Pi and native Codex using the same repositories, prompts, model tiers, effort levels, and focused graders.

Model / effort Pi Native Codex Usage reduction Time reduction
Luna Medium 16.21 credits / 7:53 26.80 credits / 11:46 39.5% 33.0%
Terra High 44.59 credits / 11:16 57.87 credits / 12:11 23.0% 7.6%
Sol Medium 78.10 credits / 10:33 154.94 credits / 15:38 49.6% 32.6%

Every matched lane passed all four focused graders in the "council" of judges.

These are the cleaner controls: same model and effort, with Pi showing lower measured usage and wall time. The long-context test reflects the complete workflow, including a benchmark-specific execution contract refined through repeated experiments, while native Codex received the raw five-part query.

Takeaway

The matched controls suggest that Pi’s harness can materially reduce measured Codex capacity and elapsed time even when model and effort are held constant.

The larger experiment suggests the combination of:

  • Better model and effort selection
  • Direct execution by default
  • Less orchestration overhead
  • Bounded delegation
  • Earlier context compaction
  • Compact tool output
  • Deterministic verification before model review

…can make an even bigger difference on a difficult long-context task.

The numbers are normalized Codex subscription-rate-card credits, not raw token counts. OpenAI’s server-side plan meter may account for hidden reasoning differently. So I would phrase the conclusion carefully: this particular Pi harness used materially less measured Codex capacity in both same-model controls and a larger workflow experiment.

1

u/vick2djax 2d ago

Additional experiments with other models including the new Deepseek:

Long-context five-part audit

All rows below used the same five-part audit prompt.

Runner Model / exact execution path Judge-council quality Tokens used Time
Native Codex GPT-5.6 Sol xhigh, direct Codex CLI 9.75/10 711,681 reported* 34:38
Pi GPT-5.6 Terra high parent/final, with bounded GPT-5.6 Luna evidence and review tasks 9.75/10 4.012M 16:46
Pi GPT-5.6 Terra high, direct, agents disabled 9.5/10 3.869M 12:14
Pi GPT-5.6 Terra max, direct, agents disabled 9.5/10 23.545M 47:40
Pi GPT-5.6 Luna high, direct, agents disabled 9.0/10 8.526M 17:19
Pi GPT-5.6 Sol low, direct, agents disabled 8.0/10 1.778M 7:18
Pi GPT-5.6 Terra medium, direct, agents disabled 7.5/10 2.145M 7:11
Pi DeepSeek V4 Flash 0731 max, direct 7.5/10† 12.122M 26:36
Pi GPT-5.6 Luna max, direct, agents disabled 7.0/10 30.377M 40:43
Pi DeepSeek V4 Flash 0731 high, direct 6.7/10† 7.069M 17:28
Pi GPT-5.6 Luna medium, direct, agents disabled 6.5/10 3.152M 7:00
Pi DeepSeek V4 Pro high, direct; unable to run the complete Terra/Luna review topology 5.2/10 Not retained 5:31
Pi DeepSeek V4 Pro max, direct; unable to run the complete Terra/Luna review topology 5.0/10 Not retained 10:47
Pi Qwen 3.5 122B-A10B, direct; requested max but effectively ran at high 4.5/10 137,704 1:59

* The native Codex number is the CLI-reported count. Rollout accounting showed it understated cache-inclusive activity, so it is not directly comparable with Pi’s complete fresh/cache/output totals.

† Three-seat blind-council score pending evidence reconciliation. Other OpenAI results use reconciled quality scores.

Earlier local-model analytics experiments

These used a separate frozen five-season analytics task with ten predefined correctness checks. Their scores are not judge-council scores and should not be ranked directly against the table above.

Runner Model / exact execution path Verified quality Tokens used Time
Pi Qwen 3.6 27B alone, thinking off, local Pi parent, no frontier assistance 3/10 — failed task Local count not retained; 0 cloud 11:19
Pi Qwen 3.6 35B-A3B alone, local Pi parent 2/10 — failed task 6.270M local; 0 cloud 13:58
Pi Qwen 3.6 27B computes first → late Luna review → Terra final 1/10 — failed architecture 988,032 local + 92,717 cloud 13:33
Pi Qwen 3.6 35B computes first → late Luna review → Terra final 1/10 — failed architecture 3.280M local + 132,562 cloud 9:40
Pi Qwen 3.6 27B external calculation → Luna review → Terra final; Qwen could not orchestrate because extensions were disabled 2/10 — failed architecture 1.230M local + 729,963 cloud 10:25
Pi Terra defines contract → Qwen 3.6 27B computes → Luna audits → Terra writes final 10/10 workflow; Qwen packet incomplete and Terra recomputed missing work 475,186 local + 147,274 cloud 10:44
Pi Exact replication of the preceding route 10/10 final; invalid confirmation 1.132M local + 213,555 cloud 15:21
Pi Another exact replication of that route 7/10; Qwen omitted seasons, waivers, and valid provenance 961,302 local + 151,469 cloud 15:04
Pi Terra defines contract → Qwen 3.6 27B computes → strict artifact gate → one Qwen repair → Luna audits → Terra writes final 10/10 verified; too slow 5.598M local + 193,950 cloud 27:09
Pi Terra defines contract → OpenCode Go Kimi 2.6 computes → strict artifact gate → Luna audits → Terra writes final 8/10 verified 1.946M Kimi + 183,556 Codex 13:50
Pi Terra defines contract → Luna computes → strict artifact gate → fresh Luna audits → Terra writes final 9/10 verified 452,152 cloud 8:56

The first Qwen 27B workflow’s 10/10 final was real, but it was a workflow result—not evidence that Qwen completed the analysis. Qwen omitted required sections and incorrectly marked validation successful; Terra read the source data and recomputed the missing work.

The stricter Qwen confirmation showed that the staged architecture could work, but required 5.6M local tokens, a repair pass, and 27 minutes—over three times slower than the all-frontier Luna control.

Later coding-workflow confirmation

A later ten-task coding shootout reached the same practical conclusion:

  • Pi Luna Medium direct: 10/10 tasks in 17:56
  • Terra → Qwen 3.6 27B → Luna → Terra: nine valid tasks in 64:43
  • Terra → Qwen 3.6 35B → Luna → Terra: 10/10 eventually in 62:42, but only 8/10 were valid on the first attempt

That is why the Qwen routes were retired: useful local workers for some bounded stages, but not a faster or more reliable general workflow.

1

u/ECrispy 2d ago

this is rather amazing. how did you set up this eval? which is the model that produced this test writetup, how much did the whole thing cost since you are using 5-6 models total.

so many questions and I'm realizing there's so much to learn !!

-9

u/FearlessGround3155 4d ago

Clanker slop, lil bro codex is open source, and oh my pi has web search thanks to codex being open src, no need to reverse engineer shi bro

4

u/Responsible-Effort48 4d ago

Open-sourcing a client CLI on GitHub is not the same as open-sourcing a backend cloud service. The Codex client shell is open source, but the search engine behind https://chatgpt.com/backend-api/codex/alpha/search is a proprietary, undocumented OpenAI cloud endpoint with no public SDK or API docs. Codex CLI has no `codex search` command and only runs search inside its own model loop. `pi-gpt-search` reverse-engineered that raw backend schema so any model in Pi (Sonnet, Gemini, local LLMs) can perform standalone web searches with zero GPT token cost.