DEV Community

Sébastien LOPEZ
Sébastien LOPEZ

Posted on

Process 1,000 articles for $1: Python content pipeline with pay-per-use AI

Most AI text APIs charge you a flat monthly fee — $50-500/month — whether you process 10 documents or 10,000. If you're building a content pipeline or a side project with unpredictable volume, that's a terrible deal.

I built TextAI API to solve this: pay-per-use text processing with USDC micropayments on Solana. You only pay when you use it. 1 USDC = 1,000 credits. No monthly commitment.

What can it do?

Three endpoints:

  • Summarize text (10 credits per call)
  • Extract keywords (5 credits per call)
  • Translate text to any language (15 credits per call)

A real content pipeline: 1,000 articles for < $1

Let's say you have 1,000 blog posts and you want to auto-generate summaries and extract keywords for SEO. Here's exactly what it costs:

Operation Count Credits Cost at 1 USDC/1000 credits
Summarize 1,000 10,000 $1.00 (1 USDC)
Keywords 1,000 5,000 $0.50 (0.5 USDC)
Total 2,000 calls 15,000 $1.50

Compare that to OpenAI or Cohere monthly plans — you'd be paying for 1,000x more capacity than you need.

The Python code

Step 1: Get your API key (100 free credits, no credit card)

curl -X POST https://textai-api.overtek.deno.net/keys/create
# {"apiKey":"sk_...","credits":100,"demo":true}
Enter fullscreen mode Exit fullscreen mode

Step 2: Process your articles

import requests
import json

API_KEY = "sk_your_key_here"
BASE_URL = "https://textai-api.overtek.deno.net"

def summarize(text):
    r = requests.post(f"{BASE_URL}/summarize",
        headers={"X-API-Key": API_KEY},
        json={"text": text}
    )
    return r.json()["summary"]

def extract_keywords(text):
    r = requests.post(f"{BASE_URL}/keywords",
        headers={"X-API-Key": API_KEY},
        json={"text": text}
    )
    return r.json()["keywords"]

# Process a batch of articles
articles = [
    "Your long blog post content here...",
    # ... more articles
]

results = []
for article in articles:
    results.append({
        "summary": summarize(article),
        "keywords": extract_keywords(article),
    })

print(json.dumps(results, indent=2))
Enter fullscreen mode Exit fullscreen mode

Step 3: When you need more credits, top up with USDC

# Check your balance first
curl https://textai-api.overtek.deno.net/keys/info \
  -H "X-API-Key: sk_your_key_here"
# {"credits": 45, "totalUsed": 55}

# Top up: 1 USDC = 1,000 credits (Solana devnet)
# Instructions at: https://textai-api.overtek.deno.net
Enter fullscreen mode Exit fullscreen mode

Async batch processing

For large batches, use async to maximize throughput:

import asyncio
import aiohttp

async def process_article(session, article, semaphore):
    async with semaphore:
        async with session.post(
            "https://textai-api.overtek.deno.net/summarize",
            headers={"X-API-Key": API_KEY},
            json={"text": article}
        ) as resp:
            data = await resp.json()
            return data["summary"]

async def process_batch(articles, concurrency=10):
    semaphore = asyncio.Semaphore(concurrency)
    async with aiohttp.ClientSession() as session:
        tasks = [process_article(session, a, semaphore) for a in articles]
        return await asyncio.gather(*tasks)

# Process 1,000 articles with 10 concurrent requests
summaries = asyncio.run(process_batch(articles, concurrency=10))
Enter fullscreen mode Exit fullscreen mode

With 10 concurrent requests, you can process 1,000 articles in minutes, not hours.

Why USDC micropayments?

Traditional API billing requires a credit card, monthly billing cycles, and minimum charges. USDC on Solana enables:

  • Instant settlement — credits appear immediately after payment
  • Tiny amounts — you can top up $0.50 at a time
  • No chargebacks — transactions are final
  • Programmable — easy to automate top-ups in your pipeline

Translation: multilingual pipelines

The translate endpoint handles any language pair:

def translate(text, target_lang="fr"):
    r = requests.post(f"{BASE_URL}/translate",
        headers={"X-API-Key": API_KEY},
        json={"text": text, "targetLang": target_lang}
    )
    return r.json()["translation"]

# Translate 100 articles to French for $0.15
for article in articles[:100]:
    french_version = translate(article, "fr")
Enter fullscreen mode Exit fullscreen mode

15 credits per translation × 100 articles = 1,500 credits = $0.15.


Try it now: https://textai-api.overtek.deno.net — 100 free credits, no credit card required.

Launching on Product Hunt tomorrow if you want to follow along!

Top comments (0)