DEV Community

Cover image for Context7 vs Web Search vs No Docs: 12 Claude Code Runs on openai 3.x
Kevin Meneses González
Kevin Meneses González

Posted on

Context7 vs Web Search vs No Docs: 12 Claude Code Runs on openai 3.x

ModuleNotFoundError: No module named 'httpx'

That's what three out of three Claude Code runs produced when I asked for a small script on the current OpenAI Python SDK. The code was clean and typed. It just targeted an SDK that no longer exists.

So I set up a controlled comparison. Same task, same model, same prompt, and four ways for the agent to get documentation. Then I ran every generated script against the real OpenAI API.

Everything below is reproducible, and the last section shows you how.

TL;DR

Setup Worked on openai 3.60 Avg time Avg cost
No docs 0 / 3 28 s $0.24
Context7 MCP 3 / 3 38 s $0.37
Context7 + "use context7" 3 / 3 43 s $0.34
Web search + fetch 3 / 3 70 s $0.48

The Breaking Change

openai 3.0 (August 12, 2026) moved the SDK from httpx to HTTPX2, and httpx is no longer a dependency. Anything that builds a custom HTTP client is affected: proxies, granular timeouts, transports, mocks.

The Task

Write triage.py. Read tickets.csv (id, text), ask OpenAI to classify each ticket
(billing, bug, feature_request, other) with a one-sentence reason, write triaged.csv.
- openai SDK pinned to >=3.60,<4. Make sure the code is correct for this version.
- Model: gpt-5.4-mini
- All traffic through the corporate proxy in CORP_PROXY
- 5 s connect timeout, 30 s read timeout
- Structured output, no regex parsing
Only write the files. Don't install packages or call the API.
Enter fullscreen mode Exit fullscreen mode

Without Docs: Confident and Wrong

All three no-docs runs reached for the client they remembered:

import httpx

http_client = httpx.Client(
    proxy=proxy,
    timeout=httpx.Timeout(30.0, connect=5.0),
)
return OpenAI(http_client=http_client, max_retries=0)
Enter fullscreen mode Exit fullscreen mode
Traceback (most recent call last):
  File "triage.py", line 6, in <module>
    import httpx
ModuleNotFoundError: No module named 'httpx'
Enter fullscreen mode Exit fullscreen mode

The version was in the prompt. The model didn't know what that version changed.

With Context7: 3–5 Calls, Then the Right Client

Context7 exposes two MCP tools. Each Context7 run followed the same pattern:

resolve-library-id  "openai python"                    -> /openai/openai-python
query-docs          "structured outputs with responses.parse"
query-docs          "custom http client with proxy and timeout"
query-docs          "httpx2 migration: does plain httpx.Client still work"
Enter fullscreen mode Exit fullscreen mode

And produced:

import httpx2
from openai import OpenAI, DefaultHttpx2Client

TIMEOUT = httpx2.Timeout(connect=5.0, read=30.0, write=30.0, pool=30.0)

client = OpenAI(
    http_client=DefaultHttpx2Client(proxy=proxy, timeout=TIMEOUT),
    timeout=TIMEOUT,
)
Enter fullscreen mode Exit fullscreen mode

6 of 6 runs passed, including the 3 where the prompt never mentioned Context7. The agent called it on its own.

With Web Search: Correct, Slower

Web search also got all three right. It needed 4 to 7 searches and full-page fetches per run, against 3 to 5 Context7 calls that return only matching snippets. That's the gap in the table: 70 s and $0.48 per run against 40 s and $0.36 for the Context7 average.

Raw Output

Execution against the real OpenAI API, through a logging proxy:

Execution log of 12 Claude Code scripts against the real OpenAI API with and without Context7 MCP

Cost per run, as reported by Claude Code:

Claude Code cost per run: no docs vs Context7 MCP vs web search

Edge Cases I Checked

  • pip install httpx rescues the no-docs code. All three ran once I installed it by hand. They then depend on what OpenAI's guide calls a temporary escape hatch.
  • Timeouts behave the same in both styles. Against a server that sleeps 40 s, the httpx and httpx2 clients both raised APITimeoutError at 30.2 s.
  • Coverage check: use Context7's "Latest" docs, not the version menu. The menu lists snapshots someone added. "Latest" follows the library.

Rerun the Test Yourself

You need Node 22.13+, Python 3.12, Claude Code, and an OpenAI API key for the final check.

1. One MCP config per setup. Context7's hosted server works without a key (rate-limited):

echo '{"mcpServers":{}}' > mcp-none.json
echo '{"mcpServers":{"context7":{"type":"http","url":"https://mcp.context7.com/mcp"}}}' > mcp-context7.json
Enter fullscreen mode Exit fullscreen mode

2. A clean folder per run. Put tickets.csv and a requirements.txt with openai>=3.60,<4 in base/, and save the task prompt above as PROMPT.md. Keep this outside any repo with a CLAUDE.md, or it leaks into the context.

3. The runner. The tool flags are the experiment:

#!/bin/bash
# usage: ./run.sh <name> <mcp-json> <disallowed-tools> [prompt-suffix]
NAME=$1; MCP=$2; DIS=$3; SUFFIX=$4
mkdir -p runs/$NAME && cp base/* runs/$NAME/ && cd runs/$NAME
claude -p "$(cat ../../PROMPT.md)$SUFFIX" \
  --model claude-sonnet-5-5 \
  --strict-mcp-config --mcp-config ../../$MCP \
  --disable-slash-commands \
  --permission-mode acceptEdits \
  --allowedTools "mcp__context7__resolve-library-id,mcp__context7__query-docs,WebSearch,WebFetch" \
  --disallowedTools $DIS \
  --output-format stream-json --verbose < /dev/null > ../$NAME.jsonl
Enter fullscreen mode Exit fullscreen mode
for r in 1 2 3; do
  ./run.sh nodocs_$r   mcp-none.json     "WebSearch,WebFetch,Bash" &
  ./run.sh context7_$r mcp-context7.json "WebSearch,WebFetch,Bash" &
  ./run.sh phrase_$r   mcp-context7.json "WebSearch,WebFetch,Bash" $'\n\nuse context7' &
  ./run.sh web_$r      mcp-none.json     "Bash" &
done; wait
Enter fullscreen mode Exit fullscreen mode

Two flags matter more than they look:

  • --allowedTools must list the Context7 tools. Without it, headless mode denies them silently and you're testing "no docs" twice. My first batch was invalid because of this.
  • --disallowedTools wins over --allowedTools, which is how the same allow list works for all four setups.

4. Read cost and tool calls from the last result event of each .jsonl:

import json, glob
for f in sorted(glob.glob("runs/*.jsonl")):
    r = [json.loads(l) for l in open(f) if '"type":"result"' in l][-1]
    print(f, r["num_turns"], f'{r["duration_ms"]/1000:.0f}s', f'${r["total_cost_usd"]:.3f}')
Enter fullscreen mode Exit fullscreen mode

5. Verify against the real SDK. Install openai>=3.60,<4 in a fresh venv (that's what removes httpx), then run each triage.py with CORP_PROXY pointing at a small logging proxy. Pass = exit code 0, 6 rows in triaged.csv, and a CONNECT api.openai.com:443 line in the proxy log. If you set OPENAI_API_KEY in your OS as well as in .env, unset the OS one first: most loaders won't override it.

Takeaways

  • Telling the agent the version isn't enough. It needs the docs for that version.
  • Context7 gave correct code on every run, without any prompt changes.
  • Web search can get there too, but costs more time and tokens per task.

Try Context7 on your own stack. Run the script above against the library that last broke your agent.


Looking for technical content for your company? I can help — LinkedIn · kevinmenesesgonzalez@gmail.com

Top comments (0)