xtekky/gpt4free · error · RuntimeError
CDP module is required for Cloudflare provider. Please ensur
Error message
CDP module is required for Cloudflare provider. Please ensure g4f.requests.cdp is available.
What it means
installG4F ran `python -m pip install --no-input g4f[slim]` inside the freshly extracted runtime and it exited non-zero. Note the message formats both the exit code and the run error; err may be nil when the process simply exited non-zero. Despite the pipEnv sandbox, this step still needs network access to reach PyPI, contradicting the 'no network' comment only for the runtime — g4f itself is downloaded here.
Source
Thrown at g4f/Provider/Cloudflare.py:112
"tinyllama-1.1b-v1.0": "@cf/tinyllama/tinyllama-1.1b-chat-v1.0",
"una-cybertron-7b-v2-bf16": "@cf/fblgit/una-cybertron-7b-v2-bf16",
"zephyr-7b-beta": "@hf/thebloke/zephyr-7b-beta-awq",
}
models = list(model_aliases.keys())
@classmethod
async def create_async_generator(
cls,
model: str,
messages: Messages,
proxy: str = None,
max_tokens: int = 2048,
**kwargs,
) -> AsyncResult:
try:
from ..requests.cdp import CDPSession
except ImportError:
raise RuntimeError(
"CDP module is required for Cloudflare provider. Please ensure g4f.requests.cdp is available."
)
try:
model = cls.get_model(model)
except ModelNotFoundError:
pass
debug.log("Cloudflare: Starting CDPSession...")
session = CDPSession(headless=False)
await session.start()
try:
await session.navigate(cls.url)
# Wait for Cloudflare validation to pass and React to load
await asyncio.sleep(5)
View on GitHub (pinned to 973504e177)
Solutions
- Re-run with pip's output visible (the command inherits stdout/stderr via runPython) and read the actual pip failure line — it is almost always resolver, network, or build-tooling
- Verify network/proxy: HTTPS_PROXY/HTTPS_PROXY env, and test reachability of pypi.org from the same environment
- If a dependency fails to build from source on python 3.14, pin a g4f version with compatible wheels: run `python -m pip install --no-input "g4f[slim]==<known-good>"` manually inside the runtime, then touch the .installed stamp
- Confirm pipEnv's lib/python3.14/site-packages path matches the actual extracted layout (ls python-home/lib) — a version bump of the bundled python breaks the hardcoded '3.14'
- Free disk space if pip failed writing to site-packages
Example fix
// before "-m", "pip", "install", "--no-input", "g4f[slim]", // after (pin a version known to ship 3.14 wheels) "-m", "pip", "install", "--no-input", "g4f[slim]==0.5.x",
Defensive patterns
Strategy: retry
Validate before calling
// pre-flight the two things pip needs: network and a matching site-packages dir
home := pythonHome(binDir)
lib := filepath.Join(home, "Lib", "site-packages")
if runtime.GOOS != "windows" {
lib = filepath.Join(home, "lib", "python3.14", "site-packages")
}
if _, err := os.Stat(lib); err != nil {
return fmt.Errorf("site-packages missing; runtime layout changed: %w", err)
} Try / catch
code, err := runPython(noSignalCtx(), exe, pipArgs, pipEnv(binDir)...)
if err != nil || code != 0 {
// one retry after ensurepip is often enough for first-run pip state issues
if !retried {
retried = true
continue
}
return fmt.Errorf("pip install g4f failed (exit %d): %w", code, err)
} Prevention
- Derive the site-packages path from the interpreter (e.g. run python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])') instead of hardcoding python3.14
- Pin a g4f version known to ship wheels for the bundled python version
- Ensure network/proxy env is set before first launch in CI or containers
When it happens
Trigger: No internet or blocked PyPI egress when pip tries to resolve g4f[slim]; pip resolving a g4f version incompatible with python 3.14; pipEnv's PYTHONHOME/PYTHONPATH pointing at a mismatched layout so the interpreter cannot import its own stdlib; disk full writing site-packages.
Common situations: Sandboxed/air-gapped environments where only the runtime download was expected to need network; g4f upstream dropping or changing a dependency that fails to build on 3.14 (no wheel, source build fails without compilers); corporate proxies rejecting pip's TLS; the hardcoded lib/python3.14 path in pipEnv going stale when the bundled python version bumps.
Related errors
- WebSocket error inside Cloudflare session
- WebSocket Error: {ws.exception()}
- Yupp request failed: {str(e)}
- Install "gpt4all" package | pip install -U g4f[local]
- Token refresh failed: {text}
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/2201cedc342774a8.
Report an issue: GitHub.