{"slug": "context7-vs-web-search-vs-no-docs-12-claude-code-runs-on-openai-3-x", "title": "Context7 vs Web Search vs No Docs: 12 Claude Code Runs on openai 3.x", "summary": "A developer ran a controlled comparison of four documentation strategies for Claude Code across 12 runs generating a script against the OpenAI Python SDK 3.x, finding that runs without docs failed 3 out of 3 times with ModuleNotFoundError for httpx, while Context7 MCP and web search each passed 3 out of 3. Context7 runs averaged about 38-43 seconds and $0.34-0.37 per run versus 70 seconds and $0.48 for web search, and the agent invoked Context7 on its own in all three runs where the prompt never mentioned it.", "body_md": "`ModuleNotFoundError: No module named 'httpx'`\n\nThat'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.\n\nSo 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.\n\nEverything below is reproducible, and the last section shows you how.\n\n| Setup | Worked on openai 3.60 | Avg time | Avg cost | \n|---|---|---|---|\n| No docs | **0 / 3** | 28 s | $0.24 | \n| Context7 MCP | **3 / 3** | 38 s | $0.37 | \n| Context7 + \"use context7\" | **3 / 3** | 43 s | $0.34 | \n| Web search + fetch | **3 / 3** | 70 s | $0.48 | \n\n`openai` 3.0 (August 12, 2026) moved the SDK from `httpx` to **HTTPX2**, and `httpx` [is no longer a dependency](https://github.com/openai/openai-python/blob/main/httpx2.md). Anything that builds a custom HTTP client is affected: proxies, granular timeouts, transports, mocks.\n\n```\nWrite triage.py. Read tickets.csv (id, text), ask OpenAI to classify each ticket\n(billing, bug, feature_request, other) with a one-sentence reason, write triaged.csv.\n- openai SDK pinned to >=3.60,<4. Make sure the code is correct for this version.\n- Model: gpt-5.4-mini\n- All traffic through the corporate proxy in CORP_PROXY\n- 5 s connect timeout, 30 s read timeout\n- Structured output, no regex parsing\nOnly write the files. Don't install packages or call the API.\n```\n\nAll three no-docs runs reached for the client they remembered:\n\n``` python\nimport httpx\n\nhttp_client = httpx.Client(\n    proxy=proxy,\n    timeout=httpx.Timeout(30.0, connect=5.0),\n)\nreturn OpenAI(http_client=http_client, max_retries=0)\nTraceback (most recent call last):\n  File \"triage.py\", line 6, in <module>\n    import httpx\nModuleNotFoundError: No module named 'httpx'\n```\n\nThe version was in the prompt. The model didn't know what that version changed.\n\n[Context7](https://context7.com/?utm_source=kevin-meneses) exposes two MCP tools. Each Context7 run followed the same pattern:\n\n``` php\nresolve-library-id  \"openai python\"                    -> /openai/openai-python\nquery-docs          \"structured outputs with responses.parse\"\nquery-docs          \"custom http client with proxy and timeout\"\nquery-docs          \"httpx2 migration: does plain httpx.Client still work\"\n```\n\nAnd produced:\n\n``` python\nimport httpx2\nfrom openai import OpenAI, DefaultHttpx2Client\n\nTIMEOUT = httpx2.Timeout(connect=5.0, read=30.0, write=30.0, pool=30.0)\n\nclient = OpenAI(\n    http_client=DefaultHttpx2Client(proxy=proxy, timeout=TIMEOUT),\n    timeout=TIMEOUT,\n)\n```\n\n6 of 6 runs passed, including the 3 where the prompt never mentioned Context7. The agent called it on its own.\n\nWeb 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.\n\nExecution against the real OpenAI API, through a logging proxy:\n\nCost per run, as reported by Claude Code:\n\n`pip install httpx` rescues the no-docs code.`APITimeoutError` at 30.2 s.\nYou need Node 22.13+, Python 3.12, Claude Code, and an OpenAI API key for the final check.\n\n**1. One MCP config per setup.** Context7's hosted server works without a key (rate-limited):\n\n```\necho '{\"mcpServers\":{}}' > mcp-none.json\necho '{\"mcpServers\":{\"context7\":{\"type\":\"http\",\"url\":\"https://mcp.context7.com/mcp\"}}}' > mcp-context7.json\n```\n\n**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.\n\n**3. The runner.** The tool flags are the experiment:\n\n``` bash\n#!/bin/bash\n# usage: ./run.sh <name> <mcp-json> <disallowed-tools> [prompt-suffix]\nNAME=$1; MCP=$2; DIS=$3; SUFFIX=$4\nmkdir -p runs/$NAME && cp base/* runs/$NAME/ && cd runs/$NAME\nclaude -p \"$(cat ../../PROMPT.md)$SUFFIX\" \\\n  --model claude-sonnet-5-5 \\\n  --strict-mcp-config --mcp-config ../../$MCP \\\n  --disable-slash-commands \\\n  --permission-mode acceptEdits \\\n  --allowedTools \"mcp__context7__resolve-library-id,mcp__context7__query-docs,WebSearch,WebFetch\" \\\n  --disallowedTools $DIS \\\n  --output-format stream-json --verbose < /dev/null > ../$NAME.jsonl\nfor r in 1 2 3; do\n  ./run.sh nodocs_$r   mcp-none.json     \"WebSearch,WebFetch,Bash\" &\n  ./run.sh context7_$r mcp-context7.json \"WebSearch,WebFetch,Bash\" &\n  ./run.sh phrase_$r   mcp-context7.json \"WebSearch,WebFetch,Bash\" $'\\n\\nuse context7' &\n  ./run.sh web_$r      mcp-none.json     \"Bash\" &\ndone; wait\n```\n\nTwo flags matter more than they look:\n\n`--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 **4. Read cost and tool calls** from the last `result` event of each `.jsonl`:\n\n``` python\nimport json, glob\nfor f in sorted(glob.glob(\"runs/*.jsonl\")):\n    r = [json.loads(l) for l in open(f) if '\"type\":\"result\"' in l][-1]\n    print(f, r[\"num_turns\"], f'{r[\"duration_ms\"]/1000:.0f}s', f'${r[\"total_cost_usd\"]:.3f}')\n```\n\n**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.\n\nTry [Context7](https://context7.com/?utm_source=kevin-meneses) on your own stack. Run the script above against the library that last broke your agent.\n\n*Looking for technical content for your company? I can help — [LinkedIn](https://www.linkedin.com/in/kevin-meneses-gonzalez/) · [kevinmenesesgonzalez@gmail.com](mailto:kevinmenesesgonzalez@gmail.com)*", "url": "https://wpnews.pro/news/context7-vs-web-search-vs-no-docs-12-claude-code-runs-on-openai-3-x", "canonical_source": "https://dev.to/kevin_menesesgonzlez/context7-vs-web-search-vs-no-docs-12-claude-code-runs-on-openai-3x-3n5", "published_at": "2026-12-01 08:10:00+00:00", "updated_at": "2026-12-01 08:14:47.678820+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "large-language-models", "ai-search"], "entities": ["Claude Code", "Context7", "OpenAI", "httpx", "Anthropic"], "also_reported_by": [], "takeaway": "Giving a coding agent version-specific docs via Context7 MCP fixed all 3 runs that otherwise failed on openai 3.x's httpx2 migration, at roughly 40s and $0.36 per run versus 70s and $0.48 for web search.", "recommendation": {"advice": "Wire a docs MCP server like Context7 into your coding agent's config when generating code against fast-moving SDKs; it resolved the httpx2 migration in 3/3 runs at lower cost than web search.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/context7-vs-web-search-vs-no-docs-12-claude-code-runs-on-openai-3-x", "markdown": "https://wpnews.pro/news/context7-vs-web-search-vs-no-docs-12-claude-code-runs-on-openai-3-x.md", "text": "https://wpnews.pro/news/context7-vs-web-search-vs-no-docs-12-claude-code-runs-on-openai-3-x.txt", "jsonld": "https://wpnews.pro/news/context7-vs-web-search-vs-no-docs-12-claude-code-runs-on-openai-3-x.jsonld"}}