xtekky/gpt4free · error · ImportError

wasmtime and numpy are required for PoW solving

Error message

wasmtime and numpy are required for PoW solving

What it means

ImportError raised by DeepSeekHash.init in g4f/Provider/needs_auth/DeepSeek.py: DeepSeek's authenticated endpoint requires solving a proof-of-work challenge executed as WebAssembly, and the optional dependencies that run it — wasmtime (WASM runtime) and numpy — are not installed. The module-level has_wasmtime_and_numpy flag is false, so init refuses to proceed.

Source

Thrown at g4f/Provider/needs_auth/DeepSeek.py:58

    has_curl_cffi = True
except ImportError:
    has_curl_cffi = False

WASM_PATH = os.path.join(os.path.dirname(__file__), "deepseek", "pow_solver.wasm")


class DeepSeekHash:
    """Custom SHA3 hash solver using WebAssembly"""

    def __init__(self):
        self.instance = None
        self.memory = None
        self.store = None

    def init(self, wasm_path: str):
        if not has_wasmtime_and_numpy:
            raise ImportError("wasmtime and numpy are required for PoW solving")

        if not Path(wasm_path).exists():
            raise FileNotFoundError(f"WASM file not found: {wasm_path}")

        engine = wasmtime.Engine()

        with open(wasm_path, "rb") as f:
            wasm_bytes = f.read()

        module = wasmtime.Module(engine, wasm_bytes)

        self.store = wasmtime.Store(engine)
        linker = wasmtime.Linker(engine)
        linker.define_wasi()

        self.instance = linker.instantiate(self.store, module)
        self.memory = self.instance.exports(self.store)["memory"]

View on GitHub (pinned to 973504e177)

Solutions

  1. Install the missing dependencies: pip install wasmtime numpy.
  2. Or reinstall g4f with the extras that pull them in for the DeepSeek provider.
  3. If you intentionally cannot install them, use a different provider or the API-key based DeepSeek path that does not need PoW.

Example fix

# before
# ImportError: wasmtime and numpy are required for PoW solving

# after
# pip install wasmtime numpy
from g4f.Provider import DeepSeek
# provider now initializes DeepSeekHash successfully
Defensive patterns

Strategy: validation

Validate before calling

def deepseek_pow_ready():
    try:
        import wasmtime  # noqa
        import numpy  # noqa
        return True
    except ImportError:
        return False

if not deepseek_pow_ready():
    raise SystemExit("pip install wasmtime numpy to use the DeepSeek provider")

Try / catch

try:
    resp = await client.chat.completions.create(model=m, provider=DeepSeek, messages=msgs)
except ImportError as e:
    subprocess.check_call([sys.executable, "-m", "pip", "install", "wasmtime", "numpy"])
    # retry once after install

Prevention

When it happens

Trigger: Using the DeepSeek (authenticated, cookie/HAR-based) provider in an environment where 'pip install wasmtime numpy' (or g4f's extras including them) was never run. The check fires the moment the PoW solver initializes, before any hash work starts.

Common situations: Minimal installs of g4f without the deepseek/websocket extras; slim Docker images; upgrading g4f in a venv created before the PoW requirement was added.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/d61fa072aec5fa00. Report an issue: GitHub.