CheapTokens is beta/experimental software. Use at your own risk.

OpenClaw Protocol

OpenClaw is a concept for programmatic purchasing and consumption of expiring AI API credits. It builds on the x402 payment protocol that CheapTokens.ai already uses.

Overview

CheapTokens.ai sells discounted API credits that expire daily. The purchase flow is already automated via the x402 protocol: a client sends USDC on Base, and receives a Venice.ai API key in response. OpenClaw extends this idea toward a fully programmatic workflow where agents or scripts can autonomously acquire and rotate API keys based on pricing signals.

Status: OpenClaw is a forward-looking concept. The building blocks exist today (x402 payment, programmatic API key delivery, public pricing endpoint), but a formal OpenClaw SDK or standard has not been released.

How purchasing works today

CheapTokens uses the x402 HTTP payment protocol. When you make a purchase:

  1. The client sends a POST /api/buy request with the desired USD amount, along with an x402 payment header containing a USDC authorization.
  2. The server verifies the on-chain USDC payment on Base, calculates the live discount, and determines how many Venice credits to issue.
  3. A Venice.ai INFERENCE API key is created with the appropriate credit limit and returned in the response.
  4. The key expires at midnight UTC. Unused credits do not carry over.
Conceptual flow
Client CheapTokens.ai Venice.ai | | | |-- POST /api/buy ---------->| | | (x402 USDC payment) | | | |-- Create API key -------->| | |<-- Key + credit limit ----| |<-- { veniceApiKey, ... } --| | | | | |-- Call Venice API directly --------------------------->| | (using veniceApiKey) | |

The OpenClaw concept

An OpenClaw-style agent would:

  • Monitor pricing — poll the public pricing endpoint to track the current discount curve and inventory levels.
  • Buy at optimal times — trigger a purchase when the discount reaches a target threshold, balancing discount vs. remaining time until expiry.
  • Rotate keys automatically — when credits run low or a new day starts, acquire a fresh key and swap it into the running application.
  • Budget management — set daily USDC spending limits and automatically stop purchasing when the budget is exhausted.
Pseudo-code
# Conceptual OpenClaw agent loop while True: pricing = fetch("https://cheaptokens.ai/api/pricing").json() discount = pricing["discountPercent"] if discount >= TARGET_DISCOUNT and daily_budget_remaining > 0: # Purchase credits via x402 key_data = x402_purchase( url="https://cheaptokens.ai/api/buy", usd_amount=PURCHASE_AMOUNT, usdc_wallet=wallet ) # Swap the active API key active_key = key_data["veniceApiKey"] daily_budget_remaining -= key_data["usdPaid"] sleep(CHECK_INTERVAL)

Available endpoints

These CheapTokens.ai endpoints are relevant for programmatic integration:

EndpointDescription
GET /api/pricingCurrent discount, credits per dollar, inventory level
POST /api/buyPurchase credits (requires x402 USDC payment)
GET /api/statusCheck key status and remaining credits
← OpenAI CompatibilityBack to Docs →