blockrun

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

BlockRun

BlockRun

BlockRun works with Claude Code and Google Antigravity.
You can't generate images. You have no real-time X/Twitter access. BlockRun gives you these capabilities.
BlockRun 可与 Claude Code 和 Google Antigravity 配合使用。
你无法生成图像,也无法获取实时X/Twitter数据,BlockRun可为你提供这些功能。

Philosophy

设计理念

You have a wallet. When you need a capability you lack, you pay for it autonomously.
You NeedYou CallPricing
Image generationDALL-E$0.04/image
Real-time X dataGrok + Live Search$0.025/source
Second opinionGPT-5.2$1.75/M input, $14/M output
Cheaper processingDeepSeek$0.14/M input, $0.28/M output
How it works: BlockRun uses x402 micropayments to route your requests to OpenAI, xAI, Google, and other providers. No API keys needed - your wallet pays per token.
你拥有一个钱包,当你需要自身不具备的功能时,可以自主付费使用。
你需要的功能调用的工具定价
图像生成DALL-E$0.04/张
实时X数据Grok + 实时搜索$0.025/数据源
二次意见GPT-5.2输入$1.75/百万token,输出$14/百万token
低成本处理DeepSeek输入$0.14/百万token,输出$0.28/百万token
工作原理: BlockRun 使用x402微支付将你的请求路由到OpenAI、xAI、Google等服务商。无需API密钥,你的钱包按token计费。

Budget Control (Optional)

预算控制(可选)

If the user specifies a budget (e.g., "use at most $1"), track spending and stop when budget is reached:
python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()
budget = 1.0  # User's budget
如果用户指定了预算(例如“最多使用1美元”),请跟踪支出,达到预算后停止调用:
python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()
budget = 1.0  # 用户设定的预算

Before each call, check if within budget

每次调用前检查是否在预算内

spending = client.get_spending() if spending['total_usd'] >= budget: print(f"Budget reached: ${spending['total_usd']:.4f} spent") # Stop making calls else: response = client.chat("openai/gpt-5.2", "Hello!")
spending = client.get_spending() if spending['total_usd'] >= budget: print(f"已达预算:已花费${spending['total_usd']:.4f}") # 停止调用 else: response = client.chat("openai/gpt-5.2", "Hello!")

At the end, report spending

最后报告支出情况

spending = client.get_spending() print(f"💰 Total spent: ${spending['total_usd']:.4f} across {spending['calls']} calls")
undefined
spending = client.get_spending() print(f"💰 总支出:${spending['total_usd']:.4f},共调用{spending['calls']}次")
undefined

When to Use

使用场景

TriggerYour Action
User explicitly requests ("blockrun second opinion with GPT on...", "use grok to check...", "generate image with dall-e")Execute via BlockRun
User needs something you can't do (images, live X data)Suggest BlockRun, wait for confirmation
You can handle the task fineDo it yourself, don't mention BlockRun
触发条件你的操作
用户明确请求(如“blockrun用GPT给出二次意见...”、“用grok查询...”、“用dall-e生成图像”)通过BlockRun执行
用户需要你无法完成的任务(图像生成、实时X数据)建议使用BlockRun,等待用户确认
你可以独立完成任务自行处理,无需提及BlockRun

Example User Prompts

用户提示示例

Users will say things like:
User SaysWhat You Do
"blockrun generate an image of a sunset"Call DALL-E via ImageClient
"use grok to check what's trending on X"Call Grok with
search=True
"blockrun GPT review this code"Call GPT-5.2 via LLMClient
"what's the latest news about AI agents?"Suggest Grok (you lack real-time data)
"generate a logo for my startup"Suggest DALL-E (you can't generate images)
"blockrun check my balance"Show wallet balance via
get_balance()
"blockrun deepseek summarize this file"Call DeepSeek for cost savings
用户可能会这样说:
用户提问你的操作
"blockrun生成一张日落的图片"通过ImageClient调用DALL-E
"用grok查看X上的热门内容"调用Grok并设置
search=True
"blockrun用GPT审核这段代码"通过LLMClient调用GPT-5.2
"关于AI Agent的最新消息是什么?"建议使用Grok(你没有实时数据)
"为我的创业公司生成一个logo"建议使用DALL-E(你无法生成图像)
"blockrun查看我的余额"通过
get_balance()
显示钱包余额
"blockrun用deepseek总结这个文件"调用DeepSeek以节省成本

Wallet & Balance

钱包与余额

Use
setup_agent_wallet()
to auto-create a wallet and get a client. This shows the QR code and welcome message on first use.
Initialize client (always start with this):
python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()  # Auto-creates wallet, shows QR if new
Check balance (when user asks "show balance", "check wallet", etc.):
python
balance = client.get_balance()  # On-chain USDC balance
print(f"Balance: ${balance:.2f} USDC")
print(f"Wallet: {client.get_wallet_address()}")
Show QR code for funding:
python
from blockrun_llm import generate_wallet_qr_ascii, get_wallet_address
使用
setup_agent_wallet()
自动创建钱包并获取客户端。首次使用时会显示二维码和欢迎信息。
初始化客户端(务必从这一步开始):
python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()  # 自动创建钱包,若为新钱包则显示二维码
查询余额(当用户询问“显示余额”、“检查钱包”等):
python
balance = client.get_balance()  # 链上USDC余额
print(f"余额:${balance:.2f} USDC")
print(f"钱包地址:{client.get_wallet_address()}")
显示充值二维码:
python
from blockrun_llm import generate_wallet_qr_ascii, get_wallet_address

ASCII QR for terminal display

终端显示ASCII格式的二维码

print(generate_wallet_qr_ascii(get_wallet_address()))
undefined
print(generate_wallet_qr_ascii(get_wallet_address()))
undefined

SDK Usage

SDK使用方法

Prerequisite: Install the SDK with
pip install blockrun-llm
前置条件: 使用
pip install blockrun-llm
安装SDK

Basic Chat

基础对话

python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()  # Auto-creates wallet if needed
response = client.chat("openai/gpt-5.2", "What is 2+2?")
print(response)
python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()  # 若需要则自动创建钱包
response = client.chat("openai/gpt-5.2", "2+2等于多少?")
print(response)

Check spending

查询支出

spending = client.get_spending() print(f"Spent ${spending['total_usd']:.4f}")
undefined
spending = client.get_spending() print(f"已花费${spending['total_usd']:.4f}")
undefined

Real-time X/Twitter Search (xAI Live Search)

实时X/Twitter搜索(xAI实时数据API)

IMPORTANT: For real-time X/Twitter data, you MUST enable Live Search with
search=True
or
search_parameters
.
python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()
重要提示: 要获取实时X/Twitter数据,必须通过
search=True
search_parameters
启用实时搜索。
python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()

Simple: Enable live search with search=True

简单用法:设置search=True启用实时搜索

response = client.chat( "xai/grok-3", "What are the latest posts from @blockrunai on X?", search=True # Enables real-time X/Twitter search ) print(response)
undefined
response = client.chat( "xai/grok-3", "X上@blockrunai的最新帖子是什么?", search=True # 启用实时X/Twitter搜索 ) print(response)
undefined

Advanced X Search with Filters

带筛选条件的高级X搜索

python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()

response = client.chat(
    "xai/grok-3",
    "Analyze @blockrunai's recent content and engagement",
    search_parameters={
        "mode": "on",
        "sources": [
            {
                "type": "x",
                "included_x_handles": ["blockrunai"],
                "post_favorite_count": 5
            }
        ],
        "max_search_results": 20,
        "return_citations": True
    }
)
print(response)
python
from blockrun_llm import setup_agent_wallet

client = setup_agent_wallet()

response = client.chat(
    "xai/grok-3",
    "分析@blockrunai近期的内容和互动情况",
    search_parameters={
        "mode": "on",
        "sources": [
            {
                "type": "x",
                "included_x_handles": ["blockrunai"],
                "post_favorite_count": 5
            }
        ],
        "max_search_results": 20,
        "return_citations": True
    }
)
print(response)

Image Generation

图像生成

python
from blockrun_llm import ImageClient

client = ImageClient()
result = client.generate("A cute cat wearing a space helmet")
print(result.data[0].url)
python
from blockrun_llm import ImageClient

client = ImageClient()
result = client.generate("一只戴着太空头盔的可爱猫咪")
print(result.data[0].url)

xAI Live Search Reference

xAI实时搜索参考

Live Search is xAI's real-time data API. Cost: $0.025 per source (default 10 sources = ~$0.26).
To reduce costs, set
max_search_results
to a lower value:
python
undefined
实时搜索是xAI的实时数据API,定价为每个数据源$0.025(默认10个数据源≈$0.26)。
如需降低成本,可将
max_search_results
设置为更小的值:
python
undefined

Only use 5 sources (~$0.13)

仅使用5个数据源(≈$0.13)

response = client.chat("xai/grok-3", "What's trending?", search_parameters={"mode": "on", "max_search_results": 5})
undefined
response = client.chat("xai/grok-3", "当前热门内容是什么?", search_parameters={"mode": "on", "max_search_results": 5})
undefined

Search Parameters

搜索参数

ParameterTypeDefaultDescription
mode
string"auto""off", "auto", or "on"
sources
arrayweb,news,xData sources to query
return_citations
booltrueInclude source URLs
from_date
string-Start date (YYYY-MM-DD)
to_date
string-End date (YYYY-MM-DD)
max_search_results
int10Max sources to return (customize to control cost)
参数类型默认值说明
mode
字符串"auto"可选值:"off"、"auto"、"on"
sources
数组web,news,x要查询的数据源
return_citations
布尔值true是否包含源URL
from_date
字符串-开始日期(格式:YYYY-MM-DD)
to_date
字符串-结束日期(格式:YYYY-MM-DD)
max_search_results
整数10返回的最大数据源数量(可自定义以控制成本)

Source Types

数据源类型

X/Twitter Source:
python
{
    "type": "x",
    "included_x_handles": ["handle1", "handle2"],  # Max 10
    "excluded_x_handles": ["spam_account"],        # Max 10
    "post_favorite_count": 100,  # Min likes threshold
    "post_view_count": 1000      # Min views threshold
}
Web Source:
python
{
    "type": "web",
    "country": "US",  # ISO alpha-2 code
    "allowed_websites": ["example.com"],  # Max 5
    "safe_search": True
}
News Source:
python
{
    "type": "news",
    "country": "US",
    "excluded_websites": ["tabloid.com"]  # Max 5
}
X/Twitter数据源:
python
{
    "type": "x",
    "included_x_handles": ["handle1", "handle2"],  # 最多10个
    "excluded_x_handles": ["spam_account"],        # 最多10个
    "post_favorite_count": 100,  # 最低点赞数阈值
    "post_view_count": 1000      # 最低浏览量阈值
}
网页数据源:
python
{
    "type": "web",
    "country": "US",  # ISO alpha-2国家代码
    "allowed_websites": ["example.com"],  # 最多5个
    "safe_search": True
}
新闻数据源:
python
{
    "type": "news",
    "country": "US",
    "excluded_websites": ["tabloid.com"]  # 最多5个
}

Available Models

可用模型

ModelBest ForPricing
openai/gpt-5.2
Second opinions, code review, general$1.75/M in, $14/M out
openai/gpt-5-mini
Cost-optimized reasoning$0.30/M in, $1.20/M out
openai/o4-mini
Latest efficient reasoning$1.10/M in, $4.40/M out
openai/o3
Advanced reasoning, complex problems$10/M in, $40/M out
xai/grok-3
Real-time X/Twitter data$3/M + $0.025/source
deepseek/deepseek-chat
Simple tasks, bulk processing$0.14/M in, $0.28/M out
google/gemini-2.5-flash
Very long documents, fast$0.15/M in, $0.60/M out
openai/dall-e-3
Photorealistic images$0.04/image
google/nano-banana
Fast, artistic images$0.01/image
M = million tokens. Actual cost depends on your prompt and response length.
模型适用场景定价
openai/gpt-5.2
二次意见、代码审核、通用场景输入$1.75/百万token,输出$14/百万token
openai/gpt-5-mini
成本优化型推理输入$0.30/百万token,输出$1.20/百万token
openai/o4-mini
最新高效推理模型输入$1.10/百万token,输出$4.40/百万token
openai/o3
高级推理、复杂问题输入$10/百万token,输出$40/百万token
xai/grok-3
实时X/Twitter数据$3/百万token + $0.025/数据源
deepseek/deepseek-chat
简单任务、批量处理输入$0.14/百万token,输出$0.28/百万token
google/gemini-2.5-flash
超长文档处理、快速响应输入$0.15/百万token,输出$0.60/百万token
openai/dall-e-3
写实风格图像生成$0.04/张
google/nano-banana
快速生成艺术风格图像$0.01/张
M = 百万token。实际成本取决于你的提示词和响应长度。

Cost Reference

成本参考

All LLM costs are per million tokens (M = 1,000,000 tokens).
ModelInputOutput
GPT-5.2$1.75/M$14.00/M
GPT-5-mini$0.30/M$1.20/M
Grok-3 (no search)$3.00/M$15.00/M
DeepSeek$0.14/M$0.28/M
Fixed Cost Actions
Grok Live Search$0.025/source (default 10 = $0.25)
DALL-E image$0.04/image
Nano Banana image$0.01/image
Typical costs: A 500-word prompt (~750 tokens) to GPT-5.2 costs ~$0.001 input. A 1000-word response (~1500 tokens) costs ~$0.02 output.
所有大模型成本以百万token为单位(M = 1,000,000 token)。
模型输入成本输出成本
GPT-5.2$1.75/M$14.00/M
GPT-5-mini$0.30/M$1.20/M
Grok-3(无搜索)$3.00/M$15.00/M
DeepSeek$0.14/M$0.28/M
固定成本操作定价
Grok实时搜索$0.025/数据源(默认10个=$0.25)
DALL-E图像生成$0.04/张
Nano Banana图像生成$0.01/张
典型成本: 给GPT-5.2发送500词提示词(约750token),输入成本约$0.001;1000词响应(约1500token),输出成本约$0.02。

Setup & Funding

设置与充值

Wallet location:
$HOME/.blockrun/.session
(e.g.,
/Users/username/.blockrun/.session
)
First-time setup:
  1. Wallet auto-creates when
    setup_agent_wallet()
    is called
  2. Check wallet and balance:
python
from blockrun_llm import setup_agent_wallet
client = setup_agent_wallet()
print(f"Wallet: {client.get_wallet_address()}")
print(f"Balance: ${client.get_balance():.2f} USDC")
  1. Fund wallet with $1-5 USDC on Base network
Show QR code for funding (ASCII for terminal):
python
from blockrun_llm import generate_wallet_qr_ascii, get_wallet_address
print(generate_wallet_qr_ascii(get_wallet_address()))
钱包位置:
$HOME/.blockrun/.session
(例如
/Users/username/.blockrun/.session
首次设置:
  1. 调用
    setup_agent_wallet()
    时自动创建钱包
  2. 查看钱包和余额:
python
from blockrun_llm import setup_agent_wallet
client = setup_agent_wallet()
print(f"钱包地址:{client.get_wallet_address()}")
print(f"余额:${client.get_balance():.2f} USDC")
  1. 在Base网络给钱包充值1-5 USDC
显示充值二维码(终端显示ASCII格式):
python
from blockrun_llm import generate_wallet_qr_ascii, get_wallet_address
print(generate_wallet_qr_ascii(get_wallet_address()))

Troubleshooting

故障排除

"Grok says it has no real-time access" → You forgot to enable Live Search. Add
search=True
:
python
response = client.chat("xai/grok-3", "What's trending?", search=True)
Module not found → Install the SDK:
pip install blockrun-llm
“Grok提示无实时访问权限” → 你忘记启用实时搜索,添加
search=True
python
response = client.chat("xai/grok-3", "当前热门内容是什么?", search=True)
“模块未找到” → 安装SDK:
pip install blockrun-llm

Updates

更新SDK

bash
pip install --upgrade blockrun-llm
bash
pip install --upgrade blockrun-llm