Speech-to-text
POST /api/transcribeTranscribe audio to text with the gpt-transcribe model. Send POST /api/transcribe with the required field url and pay $0.03 per call over x402 or MPP (there is no free tier). It returns a JSON object with model, provider, text, language and duration.
Provide a URL to an audio file (mp3, wav, m4a, etc.) and get back the transcript. Add diarize:true for speaker labels, word timestamps and a language confidence score (the scribe-v2 model, same price). No API key needed; pay per call via x402. Max 4 minutes of audio, 25 MB file size; /api/transcribe-pro takes the same models to 10 minutes.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | yes | URL of the audio file to transcribe (mp3, wav, m4a, ogg, flac, webm) Also accepted as link, uri, href, page. |
language | string | no | Optional ISO-639-1 language code (e.g. 'en', 'es', 'fr') for better accuracy |
diarize | boolean | no | true: transcribe with the scribe-v2 model and add speaker labels and word timestamps (`words`, `speakers`) and `language_confidence` (0 to 1, the model's confidence in the detected language). Same price and cap. Default false |
Example request
curl -i -X POST https://agent402.tools/api/transcribe \
-H "Content-Type: application/json" \
-d '{"url":"https://agent402.tools/fixtures/sample-speech.wav"}'
Without payment this returns HTTP 402 Payment Required with the exact price for transcribe; any x402 v2 or MPP client pays it and retries.
Example response
{
"model": "gpt-transcribe",
"provider": "openai",
"text": "Hi, this is the Agent402 sample recording. Can you hear me clearly? Yes, loud and clear. There are two of us on this clip, so the transcript can tell us apart.",
"language": "en",
"duration": 12.6
}
| Field | Type | Always present | In the example |
|---|---|---|---|
model | string | yes | gpt-transcribe |
provider | string | yes | openai |
text | string | yes | Hi, this is the Agent402 sample recording. Can you hear me clearly? Yes, loud... |
language | string | yes | en |
duration | number | yes | 12.6 |
From an MCP client
catalog.call {
"slug": "transcribe",
"params": {
"url": "https://agent402.tools/fixtures/sample-speech.wav"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for transcribe; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y [email protected].
Errors and behavior
urlis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement runs after the tool and only on a successful response. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool runs a model, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - Model-backed: the answer is generated by a model, so the same input can produce a different result.
- A
GETorHEADto /api/transcribe returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.03" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/transcribe", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"url": "https://agent402.tools/fixtures/sample-speech.wav"
}),
});
Part of these workflows
Speech-to-text is one step in this skill pack, each sold as a single call:
- Subtitle pipeline - Audio URL → finished subtitles in one call: transcribe the audio, emit the transcript as SRT/WebVTT/JSON cues, and report the text statistics - length, reading time, word count.
Related tools
Speech-to-text (Pro)
POST /api/transcribe-proTranscribe audio to text with the gpt-transcribe model - the same model as /api/transcribe with a longer cap.
Speech-to-text (OpenAI transcription wire)
POST /v1/audio/transcriptionsOpenAI's own transcription wire: POST multipart/form-data with a `file` part and get the transcript back.
Speech-to-text, long audio (OpenAI transcription wire)
POST /v1/pro/audio/transcriptionsOpenAI's transcription wire on the ten-minute tier: POST multipart/form-data with a `file` part.
Decisions (OpenAI wire)
POST /v1/decisionsOpenAI's Decisions API on its own wire: point an OpenAI SDK's base URL here and client.decisions.create works unchanged.
Dub: translate and speak
POST /api/dubTranslate a text into a target language and speak the translation, in one paid call.
Text embeddings
POST /api/embedGenerate a text embedding vector using OpenAI text-embedding-3-small (1536 dimensions).