Skip to content

BlockRunAI/rig

 
 

Repository files navigation

Rig logo

     
    stars - rig

 

📑 Docs   •   🌐 BlockRun   •   ⚡ x402 Protocol   •   ✍🏽 Blogs


BlockRun: Pay-Per-Request AI — No API Keys Needed

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.

Why BlockRun?

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

Quick Start

[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.

On-Chain Transaction Proof (Base Mainnet)

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

Available Models

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

Upstream PR

This BlockRun provider has been submitted upstream: 0xPlaygrounds/rig#1294


What is Rig?

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.

Features

  • 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)

Who is using Rig?

For the full list, see ECOSYSTEM.md

Get Started (Standard Providers)

cargo add rig-core
use 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(())
}

Supported Integrations

Vector Stores: MongoDBLanceDBNeo4jQdrantSQLiteSurrealDBMilvusScyllaDBS3VectorsHelixDB

Additional Providers: AWS BedrockFastembedEternal AIGoogle 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



Powered by BlockRun   x402 Micropayments

Build by Playgrounds

About

⚙️🦀 Build modular and scalable LLM Applications in Rust

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 99.2%
  • TypeScript 0.7%
  • Shell 0.1%
  • Nix 0.0%
  • Just 0.0%
  • Makefile 0.0%