Docs🎨 CreativeText-to-Speech
POST/api/tts$0.05

🎨 Text-to-Speech

Convert text to natural-sounding speech using ElevenLabs. Choose from multiple voices including different accents and styles. Returns an audio file URL in MP3 format.

Request Body

ParameterTypeRequiredDescriptionDefault
textstringrequiredText to convert to speech (max 5000 chars)
voicestringoptionalVoice ID or name (e.g. Rachel, Josh, Bella)Rachel

Response Fields

FieldTypeDescription
audio_urlstringCDN URL of the generated audio file (MP3)
voicestringVoice used for generation
duration_secondsnumberApproximate duration of the audio

Code Examples

cURL
bash
curl -X POST https://sparkforge.sh/api/tts \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: <x402-payment-token>" \
  -d '{
    "text": "Hello! Welcome to SparkForge, the API network for AI agents.",
    "voice": "Rachel"
  }'
Python
python
import requests

response = requests.post(
    "https://sparkforge.sh/api/tts",
    headers={"Content-Type": "application/json", "X-PAYMENT": "<token>"},
    json={"text": "Hello! Welcome to SparkForge.", "voice": "Rachel"}
)

data = response.json()
print(data["audio_url"])
TypeScript / Node.js
typescript
const res = await fetch402("https://sparkforge.sh/api/tts", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    text: "Hello! Welcome to SparkForge.",
    voice: "Rachel",
  }),
});

const { audio_url, duration_seconds } = await res.json();

Example Response

json
{
  "audio_url": "https://cdn.sparkforge.sh/audio/abc123.mp3",
  "voice": "Rachel",
  "duration_seconds": 3.2
}

💳 Payment via x402

This endpoint costs $0.05 per call, paid in USDC on Base, Polygon, or Solana. Use the @x402/fetch library to handle payments automatically, or implement the x402 handshake manually.

bash
# Free demo mode (no payment)
curl https://sparkforge.sh/api/tts?demo=true

# Or try via MCP (Claude Desktop, Cursor, Windsurf)
# Add to mcp config: { "url": "https://sparkforge.sh/api/mcp" }
Previous
AI Video Generation
Next
BTC Trading Signal