BlockRun
Integrations / LangChain

Use BlockRun as a LangChain chat model through a local sidecar

Run the blockrun-litellm sidecar and point LangChain's ChatOpenAI at it: every model in the catalog with tools, streaming and async — no provider keys, pay per call.

How it works

BlockRun's chat endpoint is already OpenAI-compatible; the only difference from api.openai.com is authentication — a per-request wallet signature instead of a bearer key. The blockrun-litellm sidecar bridges exactly that: a local OpenAI-compatible proxy that signs x402 payments with your wallet, so ChatOpenAI works unchanged, including tool calling, streaming and async.

Prefer no sidecar? An in-process path registers BlockRun as a LiteLLM provider and uses ChatLiteLLM, and a minimal custom LLM class over the Python SDK covers text-in, text-out chains and RAG. The sidecar is the recommended path because it keeps the full chat-model feature set.

Behind it is the BlockRun catalog: 78 chat models plus image, video, music and speech generation, search, market data and multi-chain RPC, priced per call. 6 open-weight models are free and need no wallet.

Setup

1. Install

pip install 'blockrun-litellm[proxy]' langchain langchain-openai

2. Start the sidecar

export BLOCKRUN_WALLET_KEY=0x<base wallet key>
blockrun-litellm-proxy --port 4001

3. Point ChatOpenAI at it

from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="openai/gpt-5.4", base_url="http://127.0.0.1:4001/v1", api_key="dummy")
print(llm.invoke("Explain x402 in one sentence").content)

Questions

Can I pay on Solana instead of Base?
Yes — start the sidecar with the Solana API URL and a SOLANA_WALLET_KEY.
Is the sidecar exposed to the network?
It binds to loopback by default; set BLOCKRUN_PROXY_TOKEN before binding anywhere else.

Two ways to run this

Get an API key

Sign in, get a key, and call the same endpoints with usage billed to your account. For teams that want one invoice instead of one wallet.

Get an API key 

Or let your agent pay per call, in USDC

No account, no API key. Three steps, and the last one is the request this page is about.

  1. 01
    Point your agent at BlockRun

    Install ClawRouter, or add the BlockRun MCP server to Claude Code, Cursor, Codex or OpenClaw. Any OpenAI-compatible client works too — change the base URL, nothing else.

    curl -fsSL https://blockrun.ai/ClawRouter-update | bash
  2. 02
    Fund a wallet with USDC

    Send USDC to a wallet on Base or Solana. There is no account to create and no API key to issue: the wallet is the account, and it pays per call.

  3. 03
    Use BlockRun from LangChain

    The first call returns HTTP 402 with the exact price, your agent signs it, and the answer comes back. Payment settles on-chain; nothing is charged if the call fails.

    pip install 'blockrun-litellm[proxy]' langchain langchain-openai