Inicio Rápido
Envía una solicitud POST con tu imagen como cuerpo en bruto. La API responde con HTTP 402 y un encabezado WWW-Authenticate: Payment según la especificación MPP.
# Step 1: discovery — returns HTTP 402 with a "Payment" challenge curl -X POST https://mpp.clearcanvas.app/v1/remove-background \ -H "Content-Type: image/png" \ --data-binary @photo.png # Step 2: paid request — attach an Authorization: Payment header curl -X POST https://mpp.clearcanvas.app/v1/remove-background \ -H "Content-Type: image/png" \ -H "Authorization: Payment <mpp-credential>" \ --data-binary @photo.png \ --output result.png
Autenticación mediante MPP
MPP es un protocolo de pago HTTP abierto co-lanzado por Stripe y Tempo. En la primera solicitud, la API devuelve HTTP 402 con un desafío WWW-Authenticate: Payment. Firma una transferencia de pathUSD en Tempo usando el mppx SDK, luego reenvía con el encabezado Authorization: Payment.
Ver la documentación del mppx SDK →TypeScript
import fs from 'fs';
import { MppxClient } from 'mppx/client';
// Configure the mppx client for the Tempo crypto rail (pathUSD).
const client = new MppxClient({
wallet: process.env.TEMPO_WALLET_PRIVATE_KEY!,
network: 'tempo',
});
const res = await client.fetch('https://mpp.clearcanvas.app/v1/remove-background', {
method: 'POST',
headers: { 'Content-Type': 'image/png' },
body: fs.readFileSync('photo.png'),
});
const buffer = await res.arrayBuffer();
fs.writeFileSync('result.png', Buffer.from(buffer));Python
import os
import httpx
from mpp import wrap_httpx # pip install mpp
client = wrap_httpx(
wallet=os.environ["TEMPO_WALLET_PRIVATE_KEY"],
network="tempo",
)
resp = client.post(
"https://mpp.clearcanvas.app/v1/remove-background",
content=open("photo.png", "rb").read(),
headers={"Content-Type": "image/png"},
)
open("result.png", "wb").write(resp.content)Formato de Solicitud
- •Endpoint
- •Body: bytes de imagen en bruto (PNG, JPEG o WebP)
- •Content-Type: image/png | image/jpeg | image/webp
- •Opcional: ?format=webp para salida en WebP
Formato de Respuesta
- •HTTP 200 — imagen binaria (PNG o WebP)
- •HTTP 402 — pago requerido (desafío WWW-Authenticate: Payment)
Manejo de Errores
- •400 — Imagen inválida (formato incorrecto, bytes mágicos no coinciden, o dimensión excedida)
- •413 — Archivo demasiado grande (> 25 MB)
- •415 — Content-Type no compatible
- •429 — Límite de velocidad excedido (solicitudes sin pago: 30/min/IP)
- •500 — Error de procesamiento (retryable: true)
- •503 — Procesador temporalmente no disponible (retryable: true)
Límites y Formatos
- •Tamaño máx. de archivo: 25 MB
- •Dimensiones máx.: 10,000 × 10,000 px
- •Entrada admitida: PNG, JPEG, WebP
- •Salida: PNG (predeterminado) o WebP
Red
La API se ejecuta en Tempo mainnet. Los pagos se realizan en pathUSD ($0,05 por imagen). Asegúrate de que tu wallet de Tempo tenga pathUSD antes de hacer solicitudes. Usa la testnet de Tempo para pruebas de extremo a extremo sin costo.