Examples

Ready-to-use workflows

Copy-paste code examples for common automation tasks. Each example includes the complete x402 payment flow.

AI & Content
Beginner
Webpage Summarizer

AI-powered content summarization for any URL

$0.25per execution

Features:

AI-powered summarization
URL content extraction
Configurable length
Multiple languages

Code Example:

// 1. Make request to xFlow
const response = await fetch('/api/run/summarize', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ 
    url: 'https://example.com/article' 
  })
})

// 2. Handle 402 payment required
if (response.status === 402) {
  const paymentData = await response.json()
  console.log('Payment required:', paymentData.price, paymentData.currency)
  
  // 3. Simulate payment (in real app, redirect to payment_url)
  await fetch(paymentData.payment_url)
  
  // 4. Retry with payment token
  const retryResponse = await fetch('/api/run/summarize', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ 
      url: 'https://example.com/article',
      paymentToken: 'mock-token-123'
    })
  })
  
  const result = await retryResponse.json()
  console.log('Summary:', result.output.summary)
}
Finance
Beginner
Token Price Fetcher

Real-time cryptocurrency price data from multiple exchanges

$0.10per execution

Features:

Real-time prices
Multiple exchanges
Historical data
Price alerts

Code Example:

// Fetch token prices
const response = await fetch('/api/run/price-fetcher', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ 
    tokens: ['BTC', 'ETH', 'USDC'],
    currency: 'USD'
  })
})

if (response.status === 402) {
  const paymentData = await response.json()
  // Handle payment...
}

const prices = await response.json()
console.log('Current prices:', prices.output)
AI & Vision
Intermediate
Image Captioner

Generate captions for images using AI vision models

$0.15per execution

Features:

AI vision analysis
Multiple styles
Object detection
Accessibility support

Code Example:

// Analyze image and generate caption
const response = await fetch('/api/run/image-captioner', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ 
    imageUrl: 'https://example.com/image.jpg',
    style: 'descriptive' // or 'creative', 'technical'
  })
})

if (response.status === 402) {
  const paymentData = await response.json()
  // Handle payment...
}

const result = await response.json()
console.log('Image caption:', result.output.caption)
Getting Started

Ready to build?

Start with our examples or create your own custom workflows. All examples include complete payment handling.

1. Copy Code

Copy the example code and customize it for your needs

2. Test Live

Use our live demo to test the complete payment flow

3. Deploy

Deploy to production and start earning from your workflows