⚡ Agent Grid Protocol
Stop wasting your idle AI Agent API quotas. Earn passive income or bypass rate-limits with <1ms Rust in-memory order book.
A high-performance AI API quota exchange built in Rust with Axum. Agents sell unused API quotas, other agents buy them — matched in microseconds via a BTreeMap-backed order book protected by Arc<RwLock<_>>.
Why Agent Grid?
| Problem | Agent Grid Solution |
|---|---|
| You hit OpenAI / Anthropic rate limits | Buy quota from agents with spare capacity |
| Your API quota sits idle at night | Sell it, earn passive income |
| You pay full price for every token | The market sets the price — always cheapest first |
| Complex integration | Drop-in OpenAI & Anthropic SDK compatible proxy |
| Financial settlements | Built-in Wallet & Ledger with Stripe fiat & Solana USDC crypto support |
| Monitoring & Admin | Beautiful embedded Cyberpunk/Fintech Web Dashboard |
Embedded Web Dashboard
Agent Grid includes a high-performance Cyberpunk/Fintech-styled embedded dashboard available at: 👉 http://127.0.0.1:3000/dashboard
Features:
- Live Order Book: Real-time polling showing cheapest OpenAI/Claude sells.
- My Wallet: Monitor multi-asset USD (Stripe) and Crypto (USDC) balances for any developer API key.
- Instant Deposits: Mock deposits for Stripe (via Lemon Squeezy integration) and Solana USDC on-chain verification.
Architecture
┌─────────────────────────────────────────────────────┐
│ Agent Grid — Rust Core │
│ │
│ BTreeMap<OrderedFloat<f64>, Vec<Order>> │
│ ← sorted asks, <1ms match latency │
│ │
│ GET /dashboard ← Web Dashboard │
│ POST /order ← sell quota │
│ GET /book ← browse market │
│ POST /v1/chat/completions ← OpenAI proxy │
│ POST /v1/messages ← Anthropic proxy │
│ GET /api/wallet ← fetch balance │
│ POST /api/pay/stripe-... ← fiat Stripe webhook │
│ POST /api/pay/crypto-ver. ← crypto USDC verify │
└─────────────────────────────────────────────────────┘
Quick Start
1. Start the exchange
cargo run
╔══════════════════════════════════════════════════════╗
║ TOKEN BORSASI — Agent Grid v0.2.0 ║
╚══════════════════════════════════════════════════════╝
POST /order
GET /book
POST /v1/chat/completions (OpenAI)
POST /v1/messages (Anthropic Claude)
2. Use the Python SDK
pip install requests
OpenAI — drop-in replacement:
from agent_grid_client import AgentGrid
grid = AgentGrid()
response = grid.chat_completion(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello from Agent Grid!"}]
)
print(response["choices"][0]["message"]["content"])
Anthropic Claude — fully compatible:
from agent_grid_client import AgentGrid
grid = AgentGrid()
response = grid.claude_completion(
model="claude-3-5-sonnet",
messages=[{"role": "user", "content": "Hello from Agent Grid!"}]
)
print(response["content"][0]["text"])
API Reference
POST /order — List quota for sale
{
"provider": "OpenAI",
"model": "gpt-4o",
"token_amount": 50000,
"price_per_1k": 0.0015
}
GET /book — Browse the order book
{
"total_orders": 42,
"asks": [
{ "id": 7, "provider": "OpenAI", "model": "gpt-4o", "token_amount": 49000, "price_per_1k": 0.0014 }
]
}
POST /v1/chat/completions — OpenAI-compatible proxy
Standard OpenAI SDK request. The exchange matches the cheapest gpt-4o quota automatically.
POST /v1/messages — Anthropic-compatible proxy
Standard Anthropic SDK request. The exchange matches the cheapest Claude quota automatically.
Python SDK Methods
| Method | Description |
|---|---|
chat_completion(model, messages) |
OpenAI-format completion via the exchange |
claude_completion(model, messages) |
Anthropic-format completion via the exchange |
cheapest_message(model, content) |
One-liner OpenAI response as string |
ask_claude(content) |
One-liner Claude response as string |
list_orders() |
Fetch the live order book |
add_order(provider, model, tokens, price) |
List your quota for sale |
Environment Variables
| Variable | Description |
|---|---|
OPENAI_API_KEY |
If set, requests are tunnelled to real OpenAI API |
ANTHROPIC_API_KEY |
If set, requests are tunnelled to real Anthropic API |
If neither is set, the exchange returns realistic mock responses — perfect for development and load testing.
Market Maker Simulation
The exchange ships with a built-in autonomous market maker that generates realistic order flow every 2–4 seconds:
[BOT HACMİ] Yeni Kota Eklendi | # 12 | OpenAI gpt-4o | 23000 token | $0.001649/1k
[BOT HACMİ] Yeni Kota Eklendi | # 13 | Anthropic claude-3-5-sonnet | 41000 token | $0.003306/1k
Tech Stack
- Rust + Axum 0.7 — async HTTP server
- BTreeMap + ordered-float — sub-millisecond price-sorted order matching
- Arc<RwLock<_>> — lock-free concurrent state
- reqwest — upstream API tunnelling
- tower-http — CORS middleware
License
MIT © Agent Grid Protocol
Metadata
Release files for agent-grid-protocol 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent_grid_protocol-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for agent_grid_protocol-0.2.0-py3-none-any.whl |
Release files / agent_grid_protocol-0.2.0-py3-none-any.whl
| Download URL | agent_grid_protocol-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07c266befba3579cc6fbc6c2d95c5f6f052047aa1323a12077ca5ee654ec1051
|
|
BLAKE2b-256 checksum How to use checksums |
d1799dd071cc92fc1bf0818658d5e4ed60751240d900108757dd081f8862818f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Security for agent-grid-protocol 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.