Skip to main content
POST
/
api
/
v1
/
x402
/
tasks
Create Debate Task
curl --request POST \
  --url https://thinkexchange.ai/api/v1/x402/tasks \
  --header 'Content-Type: application/json' \
  --data '{
  "room_id": "<string>",
  "user_prompt": "<string>",
  "constraints": {
    "max_rounds": 123,
    "timeout_seconds": 123
  }
}'
{
  "400": {},
  "402": {},
  "429": {},
  "500": {},
  "id": "<string>",
  "room_id": "<string>",
  "status": "<string>",
  "created_at": "<string>",
  "payment_method": "<string>",
  "websocket_url": "<string>"
}

Overview

Create a debate task by submitting a question to a specialized council room. This endpoint requires payment via x402 protocol.
Price: $0.50 USD (paid in USDC on Base blockchain)The x402 SDK handles payment automatically when the server returns HTTP 402.

Authentication

No JWT required - x402 is stateless. Your wallet address is your identity.Payment is verified via EIP-712 signature in the X-PAYMENT header.

Request

room_id
string
required
The ID of the council room to use. Get available rooms from GET /x402/rooms.
user_prompt
string
required
Your question or problem for the AI council to debate.Example: “Should we use microservices or monolithic architecture for our e-commerce platform?”
constraints
object
Optional constraints for the debate.

Example Request

import { createClient } from 'x402-fetch';

const client = createClient({
  network: 'base-sepolia',
  privateKey: process.env.WALLET_PRIVATE_KEY,
});

const response = await client.fetch('https://thinkexchange.ai/api/v1/x402/tasks', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    room_id: 'room_id_here',
    user_prompt: 'What are the best practices for API versioning?',
    constraints: {
      max_rounds: 3,
      timeout_seconds: 120
    }
  }),
});

const task = await response.json();

Response

Success (201 Created)

id
string
Unique task identifier
room_id
string
ID of the council room used
status
string
Current task status: pending, in_progress, completed, or failed
created_at
string
ISO 8601 timestamp of task creation
payment_method
string
Always x402 for this endpoint
websocket_url
string
WebSocket URL for real-time updates (optional)

Example Response

{
  "id": "task_abc123xyz",
  "room_id": "room_tech_leadership_001",
  "status": "pending",
  "created_at": "2025-10-29T17:00:00Z",
  "payment_method": "x402",
  "websocket_url": "wss://thinkexchange.ai/api/v1/ws/tasks/task_abc123xyz"
}

Payment Required (402)

When no payment is provided, the server returns 402 with payment requirements:
{
  "x402Version": 1,
  "error": "X-PAYMENT header is required",
  "accepts": [{
    "scheme": "exact",
    "network": "base-sepolia",
    "maxAmountRequired": "500000",
    "resource": "https://thinkexchange.ai/api/v1/x402/tasks",
    "description": "",
    "payTo": "0x7497662f19086323333464ccd3c46557a4d08e50",
    "maxTimeoutSeconds": 60,
    "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
    "outputSchema": {
      "type": "object",
      "properties": {
        "id": { "type": "string" },
        "room_id": { "type": "string" },
        "status": { "type": "string" }
      }
    }
  }]
}
Don’t handle 402 manually!Use the x402 SDK which automatically:
  1. Detects HTTP 402 response
  2. Signs EIP-712 payment message
  3. Retries with X-PAYMENT header
  4. Returns success response

Error Responses

400
Bad Request
Invalid request parameters (missing room_id, invalid user_prompt, etc.)
402
Payment Required
Missing or invalid payment. Use x402 SDK to handle automatically.
429
Too Many Requests
Rate limit exceeded (500 requests per minute per IP)
500
Internal Server Error
Server error. Contact support if persistent.

After Creating a Task

Once created, you can:

Check Status

Poll GET /x402/tasks/:id to check completion status

Get Messages

Retrieve full debate conversation with GET /x402/tasks/:id/messages

WebSocket

Connect to WebSocket URL for real-time updates

Wait for Completion

Typical debates complete in 30-120 seconds

Pricing

Fixed Price: $0.50 USD per debateIncludes:
  • 5 specialized AI agents
  • 3 rounds of debate (customizable)
  • WebSocket real-time updates
  • Full conversation history
  • Up to 120 seconds processing time
Network: Base (mainnet) or Base Sepolia (testnet)Currency: USDC (6 decimals) = 500,000 microUSDCGas Fees: Zero (Base network covers USDC transfer fees)

Rate Limits

Rate Limit: 100 requests per minute per IP addressApplies to all x402 endpoints. Exceeding this limit returns HTTP 429.Rate limit headers included in responses:
  • RateLimit-Limit: 100
  • RateLimit-Remaining: Requests left
  • RateLimit-Reset: Seconds until reset