PayGo Network x402 API

Pay-per-use AI services for developers and AI agents

Powered by x402 Protocol

Introduction

PayGo Network x402 API provides pay-per-use AI services using the x402 HTTP payment protocol. Pay only for what you use with Solana blockchain payments—no subscriptions, no API keys, no monthly fees.


Perfect for AI agents, automation workflows (n8n, Make, Zapier), and developers who need flexible, on-demand access to AI capabilities.

What is x402?

x402 is an HTTP payment protocol that uses the 402 Payment Required status code. When you call a paid endpoint without payment, you receive pricing details and payment instructions. After paying via blockchain, you retry with proof of payment to receive your result.

Base URL: https://paygo.network
Discovery: GET /api/x402/all
Payment Network: Solana (USDC)
Facilitator: PayAI Network

Authentication Flow

The x402 protocol uses a simple 3-step payment flow:

1

Call API

Make a request without payment. Receive 402 Payment Required with payment details.

2

Make Payment

Pay the exact amount to the provided Solana address using USDC. Get transaction signature.

3

Retry with Proof

Retry the same request with X-PAYMENT header containing the transaction signature.

Step 1: Initial Request (402 Response)

bash
curl -X POST https://paygo.network/api/x402/ocr/invoice \
  -H "Content-Type: application/json" \
  -d '{"file_url": "https://example.com/invoice.jpg"}'

Response (402 Payment Required):

{
  "request_id": "uuid",
  "payment_required": true,
  "status": 402,
  "payment_details": {
    "facilitator_url": "https://facilitator.payai.network",
    "amount": "0.080000",
    "currency": "USDC",
    "network": "solana",
    "recipient": "Do4wPLngMVyfBu4XKepo2Lpc5zGeYZdgqTtoNRM5B5D4",
    "payment_request_token": "JWT_TOKEN",
    "expires_at": 1762508014
  },
  "service": {
    "name": "Invoice OCR & Data Extraction",
    "description": "..."
  },
  "instructions": {
    "step1": "Complete payment using the facilitator URL",
    "step2": "Include the transaction signature in X-PAYMENT header",
    "step3": "Retry the request with X-PAYMENT header"
  }
}

Step 2: Make Payment

Send exactly 0.08 USDC to the recipient address on Solana. Use Phantom, Solflare, or any Solana wallet. You'll receive a transaction signature.

Important: Payment must be completed within 10 minutes. Use the exact amount specified in the response.

Step 3: Retry with Payment Proof

bash
curl -X POST https://paygo.network/api/x402/ocr/invoice \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: " \
  -d '{"file_url": "https://example.com/invoice.jpg"}'

Response (200 OK):

{
  "success": true,
  "data": {
    "vendor": {
      "name": "Acme Corp",
      "address": "123 Main St",
      ...
    },
    "invoice": {
      "number": "INV-001",
      "date": "2025-11-07",
      ...
    },
    "totals": {
      "total": 1620.00
    }
  },
  "metadata": {
    "processing_time": 1234.56,
    "model": "gpt-4o-mini-2024-07-18"
  }
}

Available Endpoints

GET /api/x402/all

Returns a list of all available x402 API services with pricing and metadata.

Response Example:

{
  "protocol": "x402",
  "version": "1.0",
  "facilitator": "https://facilitator.payai.network",
  "services": [
    {
      "id": "ocr-invoice",
      "name": "Invoice OCR & Data Extraction",
      "endpoint": "https://paygo.network/api/x402/ocr/invoice",
      "price": { "amount": 0.08, "currency": "USDC" },
      ...
    }
  ],
  "total": 2
}
POST /api/x402/ocr/invoice $0.08 per request

Extract structured data from invoice images or PDFs. Combines OCR with AI to deliver accurate, validated JSON output including vendor details, line items, totals, and payment terms.

Request Parameters:

Parameter Type Required Description
file_url string * URL to invoice image/PDF
file_base64 string * Base64-encoded image (alternative to file_url)
options object No Additional processing options

* Either file_url or file_base64 is required

Response Schema:

{
  "vendor": {
    "name": "string",
    "address": "string",
    "phone": "string | null",
    "email": "string | null",
    "tax_id": "string | null"
  },
  "customer": {
    "name": "string | null",
    "address": "string | null"
  },
  "invoice": {
    "number": "string",
    "date": "YYYY-MM-DD",
    "due_date": "YYYY-MM-DD | null"
  },
  "line_items": [
    {
      "description": "string",
      "quantity": number,
      "unit_price": number,
      "amount": number
    }
  ],
  "totals": {
    "subtotal": number,
    "tax": number,
    "total": number
  }
}
Rate Limits: 30 requests/minute, 500 requests/hour per IP
Supported Formats: JPG, PNG, PDF, WebP
Max File Size: 20 MB
POST /api/x402/ocr/receipt $0.05 per request

Extract structured data from receipt images. Get merchant info, items, prices, totals, and payment details in clean JSON format.

Request Parameters:

Parameter Type Required Description
file_url string * URL to receipt image
file_base64 string * Base64-encoded image (alternative to file_url)
options object No Additional processing options

* Either file_url or file_base64 is required

Response Schema:

{
  "merchant": {
    "name": "string",
    "address": "string | null",
    "phone": "string | null"
  },
  "transaction": {
    "date": "YYYY-MM-DD",
    "time": "HH:MM:SS | null",
    "transaction_id": "string | null"
  },
  "items": [
    {
      "name": "string",
      "quantity": number | null,
      "price": number
    }
  ],
  "totals": {
    "subtotal": number | null,
    "tax": number | null,
    "total": number
  },
  "payment": {
    "method": "string | null",
    "card_last_4": "string | null"
  }
}
Rate Limits: 30 requests/minute, 500 requests/hour per IP
Supported Formats: JPG, PNG, PDF, WebP
Max File Size: 20 MB
POST /api/x402/transcribe/audio $0.012 per minute

Transcribe audio to structured text with word-level or segment-level timestamps. Supports multiple audio formats (mp3, m4a, wav, webm). Powered by OpenAI Whisper.

Request Parameters:

Parameter Type Required Description
audio_url string * URL to audio file (mp3, m4a, wav, webm)
audio_base64 string * Base64-encoded audio (alternative to audio_url)
language string No ISO-639-1 language code (e.g., 'en', 'es')
prompt string No Optional context to improve transcription accuracy
timestamp_granularities array No Array containing 'word' and/or 'segment'

* Either audio_url or audio_base64 is required

Response Schema:

{
  "success": true,
  "data": {
    "text": "Full transcription text...",
    "segments": [
      {
        "id": 0,
        "start": 0.0,
        "end": 5.5,
        "text": "Hello, this is a test."
      }
    ],
    "words": null,
    "language": "en",
    "duration": 120.5
  },
  "metadata": {
    "processing_time": 2341.23,
    "duration_minutes": 2.01,
    "model": "whisper-1"
  }
}
Rate Limits: 5 requests/minute, 100 requests/hour per IP
Supported Formats: MP3, M4A, WAV, WebM, OGG
Max File Size: 25 MB
Max Duration: 120 minutes
POST /api/x402/transcribe/summary $0.015 per minute

Transcribe audio and generate an AI-powered summary highlighting key points, topics discussed, and action items. Perfect for meetings, interviews, and podcasts.

Request Parameters:

Parameter Type Required Description
audio_url string * URL to audio file (mp3, m4a, wav, webm)
audio_base64 string * Base64-encoded audio (alternative to audio_url)
language string No ISO-639-1 language code (e.g., 'en', 'es')
prompt string No Optional context for transcription
summary_prompt string No Custom prompt for summary generation
include_timestamps boolean No Include segment timestamps in transcription

* Either audio_url or audio_base64 is required

Response Schema:

{
  "success": true,
  "data": {
    "transcription": {
      "text": "Full meeting transcript...",
      "language": "en",
      "duration": 1800.0,
      "segments": [...]  // if include_timestamps=true
    },
    "summary": "The meeting covered three main topics..."
  },
  "metadata": {
    "processing_time": 3241.56,
    "duration_minutes": 30.0,
    "models_used": ["whisper-1", "gpt-4o-mini"],
    "cost_breakdown": {
      "transcription": 0.180,
      "summary": 0.001
    }
  }
}
Rate Limits: 5 requests/minute, 100 requests/hour per IP
Supported Formats: MP3, M4A, WAV, WebM, OGG
Max File Size: 25 MB
Max Duration: 120 minutes
AI Model: GPT-4o-mini for summarization
POST /api/x402/transcribe/meeting $0.018 per minute

Transcribe meeting recordings with automatic speaker identification. Returns timestamped segments labeled by speaker for easy meeting minutes creation.

Request Parameters:

Parameter Type Required Description
audio_url string * URL to meeting audio file
audio_base64 string * Base64-encoded audio (alternative to audio_url)
language string No ISO-639-1 language code (e.g., 'en', 'es')
prompt string No Optional context for transcription
identify_speakers boolean No Enable speaker identification (default: true)

* Either audio_url or audio_base64 is required

Response Schema:

{
  "success": true,
  "data": {
    "text": "Full meeting transcript...",
    "segments": [
      {
        "id": 0,
        "start": 0.0,
        "end": 5.5,
        "text": "Good morning everyone.",
        "speaker": "Speaker 1"
      },
      {
        "id": 1,
        "start": 6.0,
        "end": 10.2,
        "text": "Thanks for joining the call.",
        "speaker": "Speaker 2"
      }
    ],
    "language": "en",
    "duration": 1800.0,
    "speaker_count": 2
  },
  "metadata": {
    "processing_time": 3841.78,
    "duration_minutes": 30.0,
    "model": "whisper-1",
    "speaker_identification": true
  }
}
Rate Limits: 3 requests/minute, 50 requests/hour per IP
Supported Formats: MP3, M4A, WAV, WebM, OGG
Max File Size: 25 MB
Max Duration: 120 minutes
Max Speakers: 4 speakers detected

Code Examples

JavaScript / Node.js

javascript
async function callX402Api(endpoint, payload) {
  // Step 1: Call without payment
  let response = await fetch(endpoint, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(payload)
  });

  if (response.status === 402) {
    const paymentDetails = await response.json();

    // Step 2: Make payment (using Solana wallet)
    const txSignature = await makePayment(paymentDetails);

    // Step 3: Retry with payment proof
    response = await fetch(endpoint, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-PAYMENT': txSignature
      },
      body: JSON.stringify(payload)
    });
  }

  return await response.json();
}

// Usage - OCR Invoice
const result = await callX402Api(
  'https://paygo.network/api/x402/ocr/invoice',
  { file_url: 'https://example.com/invoice.jpg' }
);

// Usage - Audio Transcription
const transcription = await callX402Api(
  'https://paygo.network/api/x402/transcribe/audio',
  {
    audio_url: 'https://example.com/audio.mp3',
    language: 'en',
    timestamp_granularities: ['segment']
  }
);

// Usage - Transcription with Summary
const summary = await callX402Api(
  'https://paygo.network/api/x402/transcribe/summary',
  {
    audio_url: 'https://example.com/meeting.mp3',
    language: 'en',
    include_timestamps: true
  }
);

// Usage - Meeting Transcription with Speakers
const meeting = await callX402Api(
  'https://paygo.network/api/x402/transcribe/meeting',
  {
    audio_url: 'https://example.com/meeting.mp3',
    identify_speakers: true
  }
);

Python

python
import requests

def call_x402_api(endpoint, payload):
    # Step 1: Call without payment
    response = requests.post(endpoint, json=payload)

    if response.status_code == 402:
        payment_details = response.json()

        # Step 2: Make payment (using Solana SDK)
        tx_signature = make_payment(payment_details)

        # Step 3: Retry with payment proof
        response = requests.post(
            endpoint,
            json=payload,
            headers={'X-PAYMENT': tx_signature}
        )

    return response.json()

# Usage - OCR Invoice
result = call_x402_api(
    'https://paygo.network/api/x402/ocr/invoice',
    {'file_url': 'https://example.com/invoice.jpg'}
)

# Usage - Audio Transcription
transcription = call_x402_api(
    'https://paygo.network/api/x402/transcribe/audio',
    {
        'audio_url': 'https://example.com/audio.mp3',
        'language': 'en',
        'timestamp_granularities': ['segment']
    }
)

# Usage - Transcription with Summary
summary = call_x402_api(
    'https://paygo.network/api/x402/transcribe/summary',
    {
        'audio_url': 'https://example.com/meeting.mp3',
        'language': 'en',
        'include_timestamps': True
    }
)

# Usage - Meeting Transcription with Speakers
meeting = call_x402_api(
    'https://paygo.network/api/x402/transcribe/meeting',
    {
        'audio_url': 'https://example.com/meeting.mp3',
        'identify_speakers': True
    }
)

PHP

php
function callX402Api($endpoint, $payload) {
    // Step 1: Call without payment
    $ch = curl_init($endpoint);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

    $response = curl_exec($ch);
    $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    if ($statusCode === 402) {
        $paymentDetails = json_decode($response, true);

        // Step 2: Make payment (using Solana PHP SDK)
        $txSignature = makePayment($paymentDetails);

        // Step 3: Retry with payment proof
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            'Content-Type: application/json',
            'X-PAYMENT: ' . $txSignature
        ]);
        $response = curl_exec($ch);
    }

    curl_close($ch);
    return json_decode($response, true);
}

// Usage - OCR Invoice
$result = callX402Api(
    'https://paygo.network/api/x402/ocr/invoice',
    ['file_url' => 'https://example.com/invoice.jpg']
);

// Usage - Audio Transcription
$transcription = callX402Api(
    'https://paygo.network/api/x402/transcribe/audio',
    [
        'audio_url' => 'https://example.com/audio.mp3',
        'language' => 'en',
        'timestamp_granularities' => ['segment']
    ]
);

// Usage - Transcription with Summary
$summary = callX402Api(
    'https://paygo.network/api/x402/transcribe/summary',
    [
        'audio_url' => 'https://example.com/meeting.mp3',
        'language' => 'en',
        'include_timestamps' => true
    ]
);

// Usage - Meeting Transcription with Speakers
$meeting = callX402Api(
    'https://paygo.network/api/x402/transcribe/meeting',
    [
        'audio_url' => 'https://example.com/meeting.mp3',
        'identify_speakers' => true
    ]
);

cURL

bash
# Step 1: Get payment details
curl -X POST https://paygo.network/api/x402/ocr/invoice \
  -H "Content-Type: application/json" \
  -d '{"file_url":"https://example.com/invoice.jpg"}'

# Step 2: Make payment via Solana wallet (get tx signature)

# Step 3: Retry with payment proof
curl -X POST https://paygo.network/api/x402/ocr/invoice \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: " \
  -d '{"file_url":"https://example.com/invoice.jpg"}'

# Audio Transcription Example
curl -X POST https://paygo.network/api/x402/transcribe/audio \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: " \
  -d '{"audio_url":"https://example.com/audio.mp3","language":"en","timestamp_granularities":["segment"]}'

# Transcription with Summary Example
curl -X POST https://paygo.network/api/x402/transcribe/summary \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: " \
  -d '{"audio_url":"https://example.com/meeting.mp3","include_timestamps":true}'

# Meeting Transcription Example
curl -X POST https://paygo.network/api/x402/transcribe/meeting \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: " \
  -d '{"audio_url":"https://example.com/meeting.mp3","identify_speakers":true}'

Resources

x402 Protocol

x402.org

PayAI Facilitator

facilitator.payai.network

Additional Information

Status Page: All systems operational
Uptime: 99.9% SLA
Response Time: < 2 seconds average
Supported Wallets: Phantom, Solflare, any Solana-compatible wallet