Documentation

API Reference

Integrate TOON-HUB into your application to reduce LLM costs. Our simple REST API makes it easy to optimize your data before sending it to any LLM provider.

Process Request
POST/api/v1/process

Headers

Content-Type: application/json
X-X402-Consumer: 0x... (optional in free mode)

Request Body

Request
{
  "model": "gpt-4",       // Required: LLM model to use
  "data": { ... },        // Required: JSON data to optimize
  "prompt": "Analyze..."  // Required: Your prompt
}

Response

Response
{
  "success": true,
  "data": {
    "result": "Based on the data provided...",
    "pricing": {
      "jsonTokens": 1245,
      "toonTokens": 747,
      "tokensSaved": 498,
      "savingPercentage": 40.0,
      "chargedUSD": 0,
      "potentialChargeUSD": 0.0224
    },
    "paymentMode": "free",
    "isFreeMode": true
  }
}
Code Examples
cURL
curl -X POST https://toonapi.0xbuildingonchain.space/api/v1/process \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "data": {"users": [{"name": "Alice"}, {"name": "Bob"}]},
    "prompt": "Analyze this data"
  }'
Other Endpoints
GET/api/v1/mode

Get current payment mode and rate limits.

GET/api/v1/models

Get list of available LLM models.

POST/api/v1/estimate

Estimate token savings before processing.

Rate Limits
Anonymous10 req/hour
With Wallet100 req/hour

Connect a wallet via the X-X402-Consumer header for higher limits.

Supported Models
  • OAIgpt-4
  • OAIgpt-4-turbo
  • OAIgpt-3.5-turbo
  • ANTclaude-3-opus
  • ANTclaude-3.5-sonnet
Base URL
https://toonapi.0xbuildingonchain.space