{
  "openapi": "3.1.0",
  "info": {
    "title": "NoJunk Speech",
    "version": "1.0.0",
    "description": "Pay-per-call speech and language tools for agents: transcribe audio (URL or base64, up to 20 MB / about 10 minutes) to text with timestamps and detected language, turn text into natural MP3 speech, or translate text between 100 languages. USDC on Base via x402; you are only charged when a valid result is returned.",
    "x-guidance": "Three POST endpoints paid per call in USDC on Base via x402 (you are only charged when a valid result is returned; all 4xx/5xx are free). POST /transcribe {audio_url} or {audio_base64, content_type?}, optional language hint -> {text, language, language_probability, duration_seconds, word_count, segments:[{start,end,text}], ...} costs $0.02 per call and covers one file up to 20 MB (about 10 minutes of compressed audio); the URL must be public (no localhost or private networks) and is downloaded within 20 s. POST /speak {text (<= 400 chars), speaker?, format?: mp3|json} costs $0.01: with format=mp3 (default) the response body IS the MP3 file (Content-Type audio/mpeg; save the bytes as .mp3), with format=json you get {audio_base64, content_type, bytes, ...}. POST /translate {text (<= 5000 chars), target_lang, source_lang?: default en} -> {translated_text, ...} costs $0.002 and supports the 100 M2M100 languages by ISO 639-1 code (en, es, fr, de, it, pt, ru, zh, ja, ko, ar, hi, ...). Models: Whisper large-v3-turbo, Deepgram Aura-1, Meta M2M100 1.2B on Cloudflare Workers AI. Best for: turning voice notes, podcasts, meetings or voicemail into text; voicing replies, alerts or summaries for voice interfaces; localizing messages, product copy or support replies."
  },
  "servers": [
    {
      "url": "https://nojunk-speech.mick8511.workers.dev"
    }
  ],
  "paths": {
    "/transcribe": {
      "post": {
        "operationId": "transcribe",
        "summary": "Transcribe audio (URL or base64) to text with timestamps and detected language",
        "tags": [
          "AI",
          "Speech",
          "Transcription",
          "Audio"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.020000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "audio_url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "Public http(s) URL of the audio file (mp3, wav, m4a, ogg, flac, webm, mp4 audio). Max 20 MB, downloaded within 20 s. Localhost, private-network and internal hostnames are rejected. Provide this or audio_base64."
                  },
                  "audio_base64": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "Base64 (or data: URI) of the audio bytes, max 20 MB decoded. Provide this or audio_url."
                  },
                  "content_type": {
                    "type": "string",
                    "description": "Media type of audio_base64 (audio/*, video/mp4 or application/octet-stream). Default application/octet-stream."
                  },
                  "language": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 3,
                    "description": "Optional ISO 639-1 hint, e.g. en, es, de; omit to auto-detect"
                  }
                },
                "oneOf": [
                  {
                    "required": [
                      "audio_url"
                    ]
                  },
                  {
                    "required": [
                      "audio_base64"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "string",
                      "description": "Full transcript"
                    },
                    "language": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Detected (or given) language code"
                    },
                    "language_probability": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Confidence of the language detection, 0-1"
                    },
                    "duration_seconds": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Audio duration in seconds"
                    },
                    "word_count": {
                      "type": "integer"
                    },
                    "segments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "start": {
                            "type": [
                              "number",
                              "null"
                            ],
                            "description": "Segment start, seconds"
                          },
                          "end": {
                            "type": [
                              "number",
                              "null"
                            ],
                            "description": "Segment end, seconds"
                          },
                          "text": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "start",
                          "end",
                          "text"
                        ]
                      },
                      "description": "Timestamped segments"
                    },
                    "audio_bytes": {
                      "type": "integer",
                      "description": "Size of the audio that was transcribed"
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "url",
                        "base64"
                      ]
                    },
                    "model": {
                      "type": "string",
                      "description": "Model that produced the result"
                    },
                    "generated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "text",
                    "language",
                    "language_probability",
                    "duration_seconds",
                    "word_count",
                    "segments",
                    "audio_bytes",
                    "source",
                    "model",
                    "generated_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no charge)"
          },
          "402": {
            "description": "Payment Required"
          },
          "404": {
            "description": "audio_url was not found upstream (HTTP 404/410) (no charge)"
          },
          "413": {
            "description": "Request body larger than 29360128 bytes, or audio larger than 20 MB (no charge)"
          },
          "415": {
            "description": "The URL or base64 payload is not audio (e.g. an HTML page) (no charge)"
          },
          "502": {
            "description": "Audio download failed (upstream error, 20 s timeout, too many redirects, redirect to a blocked address) or the AI model is unavailable (no charge)"
          }
        }
      }
    },
    "/speak": {
      "post": {
        "operationId": "speak",
        "summary": "Text to speech: natural MP3 audio from up to 2,000 characters",
        "tags": [
          "AI",
          "Speech",
          "TTS",
          "Audio"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.010000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 400,
                    "description": "Text to speak (max 400 characters)"
                  },
                  "speaker": {
                    "type": "string",
                    "enum": [
                      "asteria",
                      "luna",
                      "stella",
                      "athena",
                      "hera",
                      "orion",
                      "arcas",
                      "perseus",
                      "angus",
                      "orpheus",
                      "helios",
                      "zeus",
                      "aura-asteria-en",
                      "aura-luna-en",
                      "aura-stella-en",
                      "aura-athena-en",
                      "aura-hera-en",
                      "aura-orion-en",
                      "aura-arcas-en",
                      "aura-perseus-en",
                      "aura-angus-en",
                      "aura-orpheus-en",
                      "aura-helios-en",
                      "aura-zeus-en"
                    ],
                    "default": "asteria",
                    "description": "Deepgram Aura voice (English). Bare names (asteria, luna, ...) are preferred; legacy aura-<voice>-en names are accepted and normalized."
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "mp3",
                      "json"
                    ],
                    "default": "mp3",
                    "description": "mp3: the response body is the raw audio/mpeg file; json: {audio_base64, content_type, bytes, ...}"
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "With format=mp3 (default) the body is the raw MP3 file (audio/mpeg) and the headers carry PAYMENT-RESPONSE, X-Audio-Bytes and X-Text-Chars. With format=json the body is JSON with the MP3 as base64.",
            "headers": {
              "X-Audio-Bytes": {
                "schema": {
                  "type": "integer"
                },
                "description": "Size of the MP3 in bytes"
              },
              "X-Text-Chars": {
                "schema": {
                  "type": "integer"
                },
                "description": "Characters spoken"
              },
              "PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                },
                "description": "Base64 x402 settlement receipt"
              }
            },
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "audio_base64": {
                      "type": "string",
                      "contentEncoding": "base64",
                      "description": "MP3 bytes, base64"
                    },
                    "content_type": {
                      "type": "string",
                      "const": "audio/mpeg"
                    },
                    "bytes": {
                      "type": "integer"
                    },
                    "text_chars": {
                      "type": "integer"
                    },
                    "speaker": {
                      "type": "string"
                    },
                    "model": {
                      "type": "string",
                      "description": "Model that produced the result"
                    },
                    "generated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "audio_base64",
                    "content_type",
                    "bytes",
                    "text_chars",
                    "speaker",
                    "model",
                    "generated_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no charge)"
          },
          "402": {
            "description": "Payment Required"
          },
          "413": {
            "description": "Request body larger than 65536 bytes (no charge)"
          },
          "502": {
            "description": "AI model temporarily unavailable or returned an unusable result (no charge)"
          }
        }
      }
    },
    "/translate": {
      "post": {
        "operationId": "translate",
        "summary": "Translate text between 100 languages",
        "tags": [
          "AI",
          "Translation",
          "Language"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.002000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 5000,
                    "description": "Text to translate (max 5000 characters)"
                  },
                  "target_lang": {
                    "type": "string",
                    "enum": [
                      "af",
                      "am",
                      "ar",
                      "ast",
                      "az",
                      "ba",
                      "be",
                      "bg",
                      "bn",
                      "br",
                      "bs",
                      "ca",
                      "ceb",
                      "cs",
                      "cy",
                      "da",
                      "de",
                      "el",
                      "en",
                      "es",
                      "et",
                      "fa",
                      "ff",
                      "fi",
                      "fr",
                      "fy",
                      "ga",
                      "gd",
                      "gl",
                      "gu",
                      "ha",
                      "he",
                      "hi",
                      "hr",
                      "ht",
                      "hu",
                      "hy",
                      "id",
                      "ig",
                      "ilo",
                      "is",
                      "it",
                      "ja",
                      "jv",
                      "ka",
                      "kk",
                      "km",
                      "kn",
                      "ko",
                      "lb",
                      "lg",
                      "ln",
                      "lo",
                      "lt",
                      "lv",
                      "mg",
                      "mk",
                      "ml",
                      "mn",
                      "mr",
                      "ms",
                      "my",
                      "ne",
                      "nl",
                      "no",
                      "ns",
                      "oc",
                      "or",
                      "pa",
                      "pl",
                      "ps",
                      "pt",
                      "ro",
                      "ru",
                      "sd",
                      "si",
                      "sk",
                      "sl",
                      "so",
                      "sq",
                      "sr",
                      "ss",
                      "su",
                      "sv",
                      "sw",
                      "ta",
                      "th",
                      "tl",
                      "tn",
                      "tr",
                      "uk",
                      "ur",
                      "uz",
                      "vi",
                      "wo",
                      "xh",
                      "yi",
                      "yo",
                      "zh",
                      "zu"
                    ],
                    "description": "Target language code (ISO 639-1; 100 M2M100 languages)"
                  },
                  "source_lang": {
                    "type": "string",
                    "enum": [
                      "af",
                      "am",
                      "ar",
                      "ast",
                      "az",
                      "ba",
                      "be",
                      "bg",
                      "bn",
                      "br",
                      "bs",
                      "ca",
                      "ceb",
                      "cs",
                      "cy",
                      "da",
                      "de",
                      "el",
                      "en",
                      "es",
                      "et",
                      "fa",
                      "ff",
                      "fi",
                      "fr",
                      "fy",
                      "ga",
                      "gd",
                      "gl",
                      "gu",
                      "ha",
                      "he",
                      "hi",
                      "hr",
                      "ht",
                      "hu",
                      "hy",
                      "id",
                      "ig",
                      "ilo",
                      "is",
                      "it",
                      "ja",
                      "jv",
                      "ka",
                      "kk",
                      "km",
                      "kn",
                      "ko",
                      "lb",
                      "lg",
                      "ln",
                      "lo",
                      "lt",
                      "lv",
                      "mg",
                      "mk",
                      "ml",
                      "mn",
                      "mr",
                      "ms",
                      "my",
                      "ne",
                      "nl",
                      "no",
                      "ns",
                      "oc",
                      "or",
                      "pa",
                      "pl",
                      "ps",
                      "pt",
                      "ro",
                      "ru",
                      "sd",
                      "si",
                      "sk",
                      "sl",
                      "so",
                      "sq",
                      "sr",
                      "ss",
                      "su",
                      "sv",
                      "sw",
                      "ta",
                      "th",
                      "tl",
                      "tn",
                      "tr",
                      "uk",
                      "ur",
                      "uz",
                      "vi",
                      "wo",
                      "xh",
                      "yi",
                      "yo",
                      "zh",
                      "zu"
                    ],
                    "default": "en",
                    "description": "Source language code (ISO 639-1); must differ from target_lang"
                  }
                },
                "required": [
                  "text",
                  "target_lang"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "translated_text": {
                      "type": "string"
                    },
                    "source_lang": {
                      "type": "string"
                    },
                    "target_lang": {
                      "type": "string"
                    },
                    "input_chars": {
                      "type": "integer"
                    },
                    "model": {
                      "type": "string",
                      "description": "Model that produced the result"
                    },
                    "generated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "translated_text",
                    "source_lang",
                    "target_lang",
                    "input_chars",
                    "model",
                    "generated_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no charge)"
          },
          "402": {
            "description": "Payment Required"
          },
          "413": {
            "description": "Request body larger than 65536 bytes (no charge)"
          },
          "502": {
            "description": "AI model temporarily unavailable or returned an unusable result (no charge)"
          }
        }
      }
    }
  }
}