This fork adds BlockRun support to Rig, enabling pay-per-request access to 30+ AI models via x402 micropayments. Fund a wallet with USDC on Base and start building—no API keys, no subscriptions, no rate limits.
| Traditional API Keys | BlockRun x402 |
|---|---|
| Apply for API access | Fund a wallet with USDC |
| Wait for approval | Start immediately |
| Monthly minimums | Pay only for what you use |
| Rate limits | No artificial limits |
| Manage multiple keys | One wallet, all providers |
| Key rotation & security | Cryptographic signatures |
[dependencies]
rig-core = { git = "https://github.com/BlockRunAI/rig", features = ["blockrun"] }use rig::prelude::*;
use rig::providers::blockrun::{self, CLAUDE_SONNET_4, GPT_4O, DEEPSEEK_CHAT};
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// Create client from wallet private key (no API keys!)
let client = blockrun::Client::from_env();
// Use Claude, GPT-4, DeepSeek — same interface, one wallet
let agent = client.agent(CLAUDE_SONNET_4)
.preamble("You are a helpful assistant.")
.build();
let answer = agent.prompt("What is x402?").await?;
println!("{answer}");
Ok(())
}Setup: Set BLOCKRUN_PRIVATE_KEY=0x... with a wallet funded with USDC on Base.
Every API request is settled on-chain with cryptographic proof:
| Model | Cost | Latency | Transaction |
|---|---|---|---|
| Claude Sonnet 4 | 0.016239 USDC | ~500ms | 0x6b2e42f5... |
| GPT-4o | 0.010821 USDC | ~400ms | 0x2ebec29e... |
| DeepSeek | 0.001 USDC | ~300ms | 0xb960c54e... |
| Claude + Tools | 0.01621 USDC | ~400ms | 0xf1a5c831... |
Test Wallet: 0x4069560641ec74acfc74ddec64181f588c64e3a7
Anthropic: Claude Opus 4, Claude Sonnet 4, Claude Sonnet 3.5, Claude Haiku 3.5 OpenAI: GPT-4o, GPT-4o Mini, GPT-o1, GPT-o1 Mini, GPT-o3 Mini DeepSeek: DeepSeek Chat, DeepSeek Reasoner Meta: Llama 3.3 70B, Llama 3.1 405B/70B/8B Google: Gemini 2.5 Pro, Gemini 2.0 Flash, Gemini 1.5 Pro Mistral: Mistral Large, Codestral, Ministral 8B Image: Flux 1.1 Pro, Flux 1.1 Pro Ultra
This BlockRun provider has been submitted upstream: 0xPlaygrounds/rig#1294
Rig is a Rust library for building scalable, modular, and ergonomic LLM-powered applications.
More information about this crate can be found in the official & crate (API Reference) documentations.
- Agentic workflows that can handle multi-turn streaming and prompting
- Full GenAI Semantic Convention compatibility
- 20+ model providers, all under one singular unified interface
- 10+ vector store integrations, all under one singular unified interface
- Full support for LLM completion and embedding workflows
- Support for transcription, audio generation and image generation model capabilities
- Integrate LLMs in your app with minimal boilerplate
- Full WASM compatibility (core library only)
- St Jude - Using Rig for a chatbot utility as part of
proteinpaint - Coral Protocol - Using Rig extensively, part of the Coral Rust SDK
- VT Code - Rust-based terminal coding agent
- Dria - Decentralised AI network
- Nethermind - Part of their Neural Interconnected Nodes Engine
- Neon - Using Rig for app.build V2
- Listen - AI portfolio management agents
- Cairnify - Intelligent search bar with agentic AI
- Ryzome - Visual AI workspace
For the full list, see ECOSYSTEM.md
cargo add rig-coreuse rig::providers::openai;
use rig::completion::Prompt;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let client = openai::Client::from_env();
let agent = client.agent(openai::GPT_4O)
.preamble("You are a comedian.")
.build();
let response = agent.prompt("Entertain me!").await?;
println!("{response}");
Ok(())
}Vector Stores: MongoDB • LanceDB • Neo4j • Qdrant • SQLite • SurrealDB • Milvus • ScyllaDB • S3Vectors • HelixDB
Additional Providers: AWS Bedrock • Fastembed • Eternal AI • Google Vertex
Built-in Providers: BlockRun • Anthropic • Azure • Cohere • DeepSeek • Galadriel • Gemini • Groq • Huggingface • Hyperbolic • Mira • Mistral • Moonshot • Ollama • OpenAI • OpenRouter • Perplexity • Together • Voyage AI • xAI