Documentation / Getting started

Pronunciation assessment API reference

Send a recording and its reference text to one endpoint. Get a 0–100 score for the sentence, every word and every sound, plus Mandarin initial, final and tone detail, in one JSON response.

  1. Create an account and generate a secret key in your dashboard.
  2. Send your first recordings with the 50 free credits every account starts with — no card needed. Choose a monthly plan when you need more.
  3. Send a short recording to POST /v1/assess. No recording at hand? The first command downloads a two-second sample of 你好.
Shell
curl -o hello.ogg https://api.toneperfect.app/capsule/speech-zh-nihao.ogg
cURL
curl https://api.toneperfect.app/v1/assess \
  -H "Authorization: Bearer $TONEPERFECT_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F "audio=@hello.ogg" \
  -F "text=你好" \
  -F "language=zh-CN"

New here? The 5-minute quickstart has the same call in cURL, Python and Node.js, how to make a test recording, and the real response. Prefer a client library? The Python and Node.js SDKs wrap this request with the same fields.

Store your API key on your server. Browser and mobile applications should call your own backend, which makes the authenticated assessment request (see browser & mobile apps).

Authentication

Pass your secret key in the Authorization header, written Authorization: Bearer tp_live_…. Or send the bare key in an X-Api-Key header. The scheme is not case-sensitive and a bare key (no scheme) is accepted too. Keys start with tp_live_ and are shown once when created. You can create up to 20 active keys and revoke them in your dashboard without changing your account password.

HTTP
Authorization: Bearer tp_live_YOUR_SECRET_KEY

Test keys

A tp_test_ key (dashboard → API keys → Test key) runs the whole request path — key, multipart upload, Idempotency-Key, reference rules, response schema — but returns a fixed example result instead of scoring the audio. It never spends credits and never counts as usage, and it has its own limit of 60 requests a minute per test key, so a copied demo key cannot slow down your live key. That makes it safe in browser code, a public demo or a CI job. Idempotency works as with live keys (same key and body: replay; same key, different body: 409). Responses carry "test": true and the header X-TonePerfect-Test: true. Rehearse error handling with TonePerfect-Test-Outcome: unassessable, invalid_assessment, engine_unavailable, subscription_required, subscription_past_due, insufficient_credits, account_busy or rate_limit.

cURL
curl https://api.toneperfect.app/v1/assess \
  -H "Authorization: Bearer tp_test_YOUR_TEST_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "TonePerfect-Test-Outcome: insufficient_credits" \
  -F audio=@hello.ogg -F text=你好 -F language=zh-CN

Never include a secret in a URL, public source code, or client application. Revoke an exposed key and generate a replacement. GET /v1/capabilities needs no key.

Assess a recording

POST https://api.toneperfect.app/v1/assess accepts multipart/form-data. Let your HTTP client set the multipart content type and boundary. Authorization is required. Idempotency-Key is optional and recommended: without it the API makes one and returns it in the Idempotency-Key response header, but a retry after a lost response then runs as a new assessment.

FieldTypeMeaning
audioFile · requiredThe recording: WAV, MP3, M4A, Ogg or WebM. 0.15 to 120 seconds, at most 10 MB. Decoded to 16 kHz mono on the server. M4A from phone recorders, which write the file index after the audio, is decoded too.
textStringThe expected words, up to 2,000 characters. Required. Mandarin: up to 600 characters; other languages: up to 320 words in the language’s own script (Latin, Cyrillic for Russian, Hangul for Korean, kana and/or kanji for Japanese). Recordings over 30 seconds, or references over 40 words (100 Mandarin characters), are scored in pieces. See input rules by language.
languageStringA locale: zh-CN (default), en-US, fr-FR, es-419, de-DE, it-IT, pt-BR, ru-RU, ko-KR, or ja-JP. Always send it: without it Mandarin text is scored as zh-CN and any other text gets 422 missing_language, naming the locale the text’s script suggests. Short codes (en, de, ja) resolve to their locale; another region (en-GB) gets a “did you mean”. Check live capabilities.
taskString · optionalgeneral (default), connected_speech, or isolated_word. Validated and echoed in the response; the current engine scores every task the same way, so it does not change scores or decisions today.
pinyinString · optionalMandarin only, up to 1,000 characters. With characters in text, one pinyin syllable per character picks the reading of characters with several (warning pinyin_reading_used; a count mismatch ignores it, warning pinyin_ignored_count_mismatch). On its own (with text empty or absent), pinyin with tones (ni3 hao3 or nǐ hǎo, up to 100 syllables and 30 s) is scored. Pinyin without tones is refused with 422.
JavaScript · server-side (Node 18+)
// Node 18+ (global fetch, FormData and Blob). Save as assess.mjs, run: node assess.mjs
import { readFile } from 'node:fs/promises';
import { randomUUID } from 'node:crypto';

const form = new FormData();
form.append('audio', new Blob([await readFile('hello.ogg')], { type: 'audio/ogg' }), 'hello.ogg');
form.append('text', '你好');
form.append('language', 'zh-CN');

const response = await fetch('https://api.toneperfect.app/v1/assess', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.TONEPERFECT_API_KEY}`,
    // One key per recording attempt; reuse it only to retry the same attempt.
    'Idempotency-Key': `quickstart-${randomUUID()}`,
  },
  body: form,
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status} ${result.error.code}: ${result.error.message}`);
console.log(result.scores.overall);
for (const word of result.words) {
  console.log(word.word, word.pinyin, word.score, word.phones.map(p => [p.dimension, p.expected, p.heard, p.decision]));
}
Python
import os
import uuid

import requests  # pip install requests

with open("hello.ogg", "rb") as audio:
    response = requests.post(
        "https://api.toneperfect.app/v1/assess",
        headers={
            "Authorization": f"Bearer {os.environ['TONEPERFECT_API_KEY']}",
            # One key per recording attempt; reuse it only to retry the same attempt.
            "Idempotency-Key": f"quickstart-{uuid.uuid4()}",
        },
        files={"audio": ("hello.ogg", audio, "audio/ogg")},
        data={"text": "你好", "language": "zh-CN"},
        timeout=90,
    )
result = response.json()
if not response.ok:
    raise SystemExit(f"{response.status_code} {result['error']['code']}: {result['error']['message']}")
print(result["scores"]["overall"])
for word in result["words"]:
    print(word["word"], word["pinyin"], word["score"], [(p["dimension"], p["expected"], p["heard"], p["decision"]) for p in word["phones"]])

The response includes assessable, scores, words, billing, and the loaded model_version. Scores use a 0–100 display scale. Unsupported dimensions are null; a missing measurement is not a zero score.

A pronunciation grade is a display score, not a percentage of native likeness or a guaranteed probability of correctness. Use the explicit decision field for feedback; do not turn every low display grade into a correction. Sound-level detail and language capabilities depend on the loaded model. Each response says which engine scored it in engine_route (see Engine and fallback).

Check reference text first

POST https://api.toneperfect.app/v1/lint runs the engine's reference rules on a lesson's text without audio: script, digits, length, and for Mandarin whether there are characters to score. It is free and needs no key, so run it when you author content, not when a learner is waiting. A text that passes can still be refused by a newer engine; the assessment's own invalid_assessment error stays authoritative.

cURL
curl https://api.toneperfect.app/v1/lint \
  -H "Content-Type: application/json" \
  -d '{"text": "我有3个苹果", "language": "zh-CN"}'
Response
{
  "ok": true,
  "language": "zh-CN",
  "issues": [
    {
      "code": "digits",
      "message": "Digits are read as Mandarin numbers (3 becomes 三); the response shows the rewritten text in reference_normalization.",
      "field": "text",
      "severity": "warning"
    }
  ],
  "units": 5
}

Issues with severity: "warning" never block. The SDKs and the CLI (toneperfect lint "你好" --language zh-CN) call the same endpoint.

Response structure

One assessment connects the overall result to individual words and sounds: recording → word or character → sound. A successful request returns HTTP 200 with the fields below; a recording that cannot be assessed also returns 200, with assessable: false.

FieldMeaning
idThe request id (req_…), also in the X-Request-Id header.
assessable, status, reasontrue with completed when every word was scored, or partial when some were not (sounds outside the pack’s inventory, or a piece of a long passage that could not be scored; those words have score: null). Otherwise false / unassessable with a reason (table under Errors). Unassessable results, and results in which no word got a score, are not charged.
scores0–100 grades: overall, pronunciation, and the pack’s dimensions: initial, final, tone (Mandarin); integrity (completeness: the share of the reference that was heard; other packs). fluency and rhythm are reserved and null in every language with the current engine. Unsupported dimensions are null. When words of the reference were not said, overall falls with completeness (pronunciation × the share of words said, warning incomplete_reading).
words[]One entry per word (per character in Mandarin): word, score, start_ms, end_ms; pinyin (Mandarin) or expected_ipa, decision and omission_suspected (other languages). A word that was not said has score: 0, omitted: true and decision: "review". A word with sounds not heard carries sounds_heard (share heard) and is at most 79. A word scored on its supported sounds only has score_scope: "supported_sounds". A word below 50 is never no_correction. Japanese words have no timings yet. A long passage’s piece that could not be scored returns its words with score: null, assessed: false and decision: "unassessable". Digits in the reference appear in their spelled-out form.
words[].phones[]Sound-level rows: expected, heard, score. Mandarin rows have a dimension (initial, final, tone), a decision and flagged; other languages have per-phoneme timing, an alignment operation and diagnosis_status: "experimental", and no decision (their correction decision is on the word). When the sound decoder missed a sound in a word the speech recognizer heard, the row is heard = expected with its measured score and heard_by: "transcript" (or "forced_alignment" when the forced alignment measured it as said). When the decoder's label was only a variant of the same sound, heard = expected and heard_raw keeps the decoder's label.
syllables[]Mandarin only. expected (pinyin, initial, final, tone), span_ms and components.initial|final|tone, each with expected, heard, agrees_with_prompt, score, confidence, alternatives (ranked labels with probabilities), decision and advice.
heardWhat the engine estimates was said: syllables[] (Mandarin initial, final and tone per syllable) or phonetic_transcription (other languages).
model_version, modelThe model that actually scored the request, with calibration notes and limitations. A score from the fallback engine has +fallback appended.
engine_routeWhich engine answered: engine is primary or fallback, fallback the same as a boolean, and reason why the fallback was used. Also in the X-TonePerfect-Engine header and in the compact schema. See Engine and fallback.
text, reference_normalizationThe reference as scored. When digits were spelled out, reference_normalization holds your original input_text and the scored form.
phonetic_coverageWhen some words were not scored because of sounds outside the inventory: unassessed_words with their index.
duration_seconds, timing_ms, timingDecoded audio length, engine time, and (Mandarin) pause and speaking-rate measurements.
warnings[]Non-fatal notes about the recording; the codes are listed below.
billingcredits charged for this request, source (free or plan), the remaining plan balance_credits and the remaining free_credits. When less than the full duration was charged: credits_not_charged and not_charged_reason (no_word_scored or unscored_pieces); credits_waived when the last free credits covered a longer clip.
rawEngine diagnostics. Not a stable contract; do not build on it.
WarningMeaning
contentThe words heard match the reference poorly while the audio was clear: possibly another text. The score is kept.
unclear_audioThe words heard match the reference poorly and the audio was unclear (noise, clipping, distance). Treat the score with caution.
weak_speech_evidenceVery little speech was detected; the score rests on little evidence.
single_word_content_gateA one-word prompt (every prompt in ja-JP and ko-KR) looked like another word or text was said. In ja-JP and ko-KR the score is capped at 55 unless the speech recognizer reads the reference; in en, fr, es, de and ru the word gets decision review with content_mismatch_suspected: true.
incomplete_readingSome words of the reference were not said: they come back with score 0, omitted: true and decision review, integrity is the share of words said, and overall = pronunciation × that share.
extra_speechThe learner said more than the reference (a repeat, an extra word). Reported only; the score is not lowered for it.
missing_soundsOne-word prompt: some of its sounds were not heard, so the word (and the headline) is capped at 79 and words[].sounds_heard gives the share heard.
content_not_confirmedThe overall is far below both pronunciation and completeness because the words heard do not confirm the reference (possibly other speech mixed in).
short_clip_paddedA very short clip of a one- or two-word prompt was padded with silence so it could be scored; timings refer to your original audio.
content_mismatch_suspectedThe words heard look like another word or text, but the prompt is too short to tell that from a learner's mispronunciation (under 10 syllables; Mandarin: one or two characters). The take is scored, not refused, and the score is usually low.
unsupported_phonetic_symbolsSome words use sounds outside the pack’s inventory and are not scored (status partial; phonetic_coverage lists them).
all_words_partialNo word could be scored. Such a result is not charged.
long_reference_chunked / long_passage_chunkedA long passage was scored in pieces (other languages / Mandarin).
piece_N_<reason>Piece N of a long passage could not be scored (reason as in the table above). Its words come back unassessed and its audio is not charged.
foreign_words_unassessedMandarin: Latin-letter words in the reference were left out of the score.
pinyin_reading_usedMandarin: your pinyin chose the reading of a character that has several (it is one of that character’s dictionary readings).
pinyin_sandhi_or_unknown_reading_keptMandarin: a pinyin syllable was a tone-sandhi spelling (ni2 hao3) or not a dictionary reading of its character, so the dictionary reading was kept; sandhi is already accepted when scoring.
pinyin_ignored_count_mismatchMandarin: the pinyin did not have one syllable per character, so it was ignored.

A decision is one of review (the evidence for an error is strong), uncertain, no_correction, or content_mismatch_suspected (a one-word prompt where another word seems to have been said; the score is capped at 55); unassessable, partial and legacy_correction also occur. Treat any other value as “no decision”. Decisions are per initial, final and tone in Mandarin and per word in the other languages, where sounds carry no decision. A word with a low score can still say no_correction today, so do not read the decision alone. Heard sounds are acoustic estimates. A different heard category can be acceptable in context, such as Mandarin tone sandhi, so use the decision rather than treating every mismatch as an error.

A real response for 你好, trimmed to the documented fields (the full body also carries engine diagnostics and probabilities):

JSON · 200 OK
{
  "id": "req_example",
  "language": "zh",
  "locale": "zh-CN",
  "model_version": "mandarin-human-v2-85741cdf3967-fbf73d85ee88",
  "task": "general",
  "status": "completed",
  "assessable": true,
  "reason": null,
  "scores": {
    "overall": 99.6,
    "pronunciation": 97.8,
    "initial": 98.2,
    "final": 97.3,
    "tone": 98,
    "fluency": null,
    "rhythm": null,
    "integrity": null
  },
  "words": [
    {
      "word": "你",
      "pinyin": "ni3",
      "score": 99.3,
      "start_ms": 0,
      "end_ms": 155,
      "phones": [
        {
          "dimension": "initial",
          "expected": "n",
          "heard": "n",
          "score": 96.6,
          "decision": "no_correction",
          "flagged": false
        },
        {
          "dimension": "final",
          "expected": "i",
          "heard": "i",
          "score": 96.1,
          "decision": "no_correction",
          "flagged": false
        },
        {
          "dimension": "tone",
          "expected": 3,
          "heard": 2,
          "score": 99.7,
          "decision": "no_correction",
          "flagged": false
        }
      ]
    },
    {
      "word": "好",
      "pinyin": "hao3",
      "score": 99.5,
      "start_ms": 155,
      "end_ms": 424,
      "phones": [
        {
          "dimension": "initial",
          "expected": "h",
          "heard": "h",
          "score": 99.8,
          "decision": "no_correction",
          "flagged": false
        },
        {
          "dimension": "final",
          "expected": "ao",
          "heard": "ao",
          "score": 98.5,
          "decision": "no_correction",
          "flagged": false
        },
        {
          "dimension": "tone",
          "expected": 3,
          "heard": 3,
          "score": 96.3,
          "decision": "no_correction",
          "flagged": false
        }
      ]
    }
  ],
  "syllables": [
    {
      "index": 0,
      "expected": {
        "pinyin": "ni3",
        "initial": "n",
        "final": "i",
        "tone": 3
      },
      "span_ms": [
        0,
        155
      ],
      "score": 99.3,
      "components": {
        "initial": {
          "expected": "n",
          "heard": "n",
          "agrees_with_prompt": true,
          "score": 96.6,
          "confidence": "high",
          "decision": "no_correction",
          "advice": null
        },
        "final": {
          "expected": "i",
          "heard": "i",
          "agrees_with_prompt": true,
          "score": 96.1,
          "confidence": "high",
          "decision": "no_correction",
          "advice": null
        },
        "tone": {
          "expected": 3,
          "heard": 2,
          "agrees_with_prompt": false,
          "score": 99.7,
          "confidence": "high",
          "decision": "no_correction",
          "advice": null
        }
      }
    },
    {
      "index": 1,
      "expected": {
        "pinyin": "hao3",
        "initial": "h",
        "final": "ao",
        "tone": 3
      },
      "span_ms": [
        155,
        424
      ],
      "score": 99.5,
      "components": {
        "initial": {
          "expected": "h",
          "heard": "h",
          "agrees_with_prompt": true,
          "score": 99.8,
          "confidence": "high",
          "decision": "no_correction",
          "advice": null
        },
        "final": {
          "expected": "ao",
          "heard": "ao",
          "agrees_with_prompt": true,
          "score": 98.5,
          "confidence": "high",
          "decision": "no_correction",
          "advice": null
        },
        "tone": {
          "expected": 3,
          "heard": 3,
          "agrees_with_prompt": true,
          "score": 96.3,
          "confidence": "high",
          "decision": "no_correction",
          "advice": null
        }
      }
    }
  ],
  "heard": {
    "syllables": [
      {
        "initial": "n",
        "final": "i",
        "tone": 2
      },
      {
        "initial": "h",
        "final": "ao",
        "tone": 3
      }
    ]
  },
  "duration_seconds": 0.54,
  "billing": {
    "credits": 1,
    "balance_credits": 2499
  }
}

Note the first syllable: 你 is a 3rd tone that was heard as a 2nd, which is what a 3rd tone becomes before another 3rd tone, so its decision is no_correction.

Compact schema (stable)

Import the generated Postman collection · Subscribe to source changelog RSS

The default response carries everything the engine reports, including engine diagnostics (syllables, probabilities, model) that can change between engine versions. Send TonePerfect-Response: compact to get the documented, versioned schema toneperfect.compact.v1 instead: the scores, and per word the units with what was expected, what was heard, a grade and a decision. Dimensions a pack does not measure are null, never missing. Additive changes keep v1; anything else ships as v2 with v1 served for at least 90 days.

HTTP
TonePerfect-Response: compact
Compact response
{
  "schema": "toneperfect.compact.v1",
  "id": "req_example",
  "assessable": true,
  "reason": null,
  "locale": "zh-CN",
  "task": "general",
  "model_version": "mandarin-human-v2-85741cdf3967-fbf73d85ee88",
  "scores": {
    "overall": 99.6,
    "pronunciation": 97.8,
    "initial": 98.2,
    "final": 97.3,
    "tone": 98,
    "fluency": null,
    "rhythm": null,
    "completeness": null
  },
  "words": [
    {
      "text": "你",
      "pinyin": "ni3",
      "score": 99.3,
      "start_ms": 0,
      "end_ms": 155,
      "decision": null,
      "units": [
        {
          "dimension": "initial",
          "expected": "n",
          "heard": "n",
          "score": 96.6,
          "decision": "no_correction"
        },
        {
          "dimension": "final",
          "expected": "i",
          "heard": "i",
          "score": 96.1,
          "decision": "no_correction"
        },
        {
          "dimension": "tone",
          "expected": "3",
          "heard": "2",
          "score": 99.7,
          "decision": "no_correction"
        }
      ]
    },
    {
      "text": "好",
      "pinyin": "hao3",
      "score": 99.5,
      "start_ms": 155,
      "end_ms": 424,
      "decision": null,
      "units": [
        {
          "dimension": "initial",
          "expected": "h",
          "heard": "h",
          "score": 99.8,
          "decision": "no_correction"
        },
        {
          "dimension": "final",
          "expected": "ao",
          "heard": "ao",
          "score": 98.5,
          "decision": "no_correction"
        },
        {
          "dimension": "tone",
          "expected": "3",
          "heard": "3",
          "score": 96.3,
          "decision": "no_correction"
        }
      ]
    }
  ],
  "warnings": [],
  "billing": {
    "credits": 1,
    "balance_credits": 2499
  }
}

How the compact fields come from the full response:

CompactFull response
scores.completenessscores.completeness, else scores.integrity
words[].textwords[].word, else words[].text
words[].units[]words[].phones[] (else phonemes[]): dimension (phoneme outside Mandarin), expected, heard, score, decision
words[].decision, units[].decisionThe same value when it is one of the documented decisions, else null. Mandarin words and non-Mandarin units have no decision, so they are null.
engine_routeengine_route (engine, fallback, reason)
not in compactsyllables[] (Mandarin per-syllable detail, including the engine’s per-syllable warn), heard, model, raw, reference_normalization, phonetic_coverage, probabilities

Engine internals. The default response's raw field is the engine's internal output. It is included up to 64 KB; larger output is replaced by {"omitted": true, "bytes": N}. Send TonePerfect-Debug: raw to receive it in full when debugging. Do not build on it: it changes with engine versions. raw is never stored, so a replay with the same Idempotency-Key does not contain it; results larger than 256 KB are kept for replay in the compact schema. The format header is not part of the idempotent identity, so a retry may ask for either format.

Your own pass marks belong in your code: see the rubric adapter example, which maps the compact schema to your thresholds without treating a grade as a certification.

Mandarin tones, initials and finals

Every Mandarin syllable is scored as three components (initial, final and tone), each with an expected value, a heard estimate, a 0–100 grade and a decision. Third-tone sandhi (3-3 → 2-3) and the 不 change before a 4th tone are taken into account; the 一 change is not applied. Send the characters in text (recommended); add pinyin, one syllable per character, to pick the reading of a polyphone, or send pinyin with tones on its own. Fluency and rhythm are not scored. See the tone scoring guide for a syllable with a wrong tone, the pinyin guide for pinyin input, and the Mandarin pack page for known limits.

Languages & capabilities

GET https://api.toneperfect.app/v1/capabilities needs no key. It returns model_version, a languages[] array (locale, name, available, status, dimensions, tasks, limits and notes per pack) and the request limits (max_audio_seconds, max_upload_bytes, concurrent_requests_per_account). Inspect it before choosing a language; each assessment identifies the model actually used.

cURL
curl https://api.toneperfect.app/v1/capabilities
LanguageLocaleScored dimensions
Mandarin Chinesezh-CNpronunciation · initials · finals · tones
Englishen-USpronunciation · completeness · fluency · rhythm
Frenchfr-FRpronunciation · completeness · fluency · rhythm
Spanishes-419pronunciation · completeness
Germande-DEpronunciation · completeness
Italianit-ITpronunciation · completeness
Portuguesept-BRpronunciation · completeness
Russianru-RUpronunciation · completeness
Koreanko-KRpronunciation · completeness
Japaneseja-JPpronunciation · completeness

Every pack is currently labelled experimental. Live status, limits and per-pack notes come from GET /v1/capabilities.

Input rules by language

LocaleReference text
zh-CNChinese characters (simplified or traditional), up to 600. Digits are read as Mandarin numbers (3 → 三). Latin-letter words are left out of the score (warning foreign_words_unassessed). Pinyin with tones is scored on its own (numbered ni3 hao3 or tone-marked nǐ hǎo, in text or pinyin, up to 100 syllables and 30 s; each syllable is scored on a common character with that reading, and words[].word shows the pinyin). Next to characters, pinyin (one syllable per character) chooses the reading of characters with several readings. Pinyin without tones is refused.
en-US, fr-FR, es-419, de-DE, it-IT, pt-BRUp to 320 words in the Latin script. Digits are spelled out before scoring (2026 → “two thousand and twenty-six”), and words[] then follows the spelled-out form (see reference_normalization): write numbers as the learner will say them.
ru-RUCyrillic, up to 320 words. Digits are spelled out as in the Latin-script languages. Stress and vowel reduction come from the transcription; no stress marks needed.
ko-KRHangul with normal spacing; each space-separated word is scored; digits are refused (write numbers in Hangul). Aspiration is scored on k, p and t; aspirated s and tɕ (ㅊ) and the tense consonants are mapped to their plain counterparts.
ja-JPKana and/or kanji, no spaces needed; digits are refused (write numbers in kana or kanji). Words carry no start_ms/end_ms yet. Text is split into bunsetsu-like units (日本語を / 勉強しています) and kanji are read with a dictionary, which can miss context-dependent readings such as 今日は (write those in kana). Pitch accent is not scored.

Correction decisions are made per word in every language except Mandarin, where they are made per initial, final and tone. Wrong text. A recording of a different sentence of 10 syllables or more (Mandarin: 10 characters) is refused (different_content, not charged). A shorter prompt is never refused for content, because on a word or a short phrase a learner who confuses the sounds (“ship” for “sheep”) and someone saying another word leave the same evidence. It is scored instead, usually low, with warning content_mismatch_suspected or content. On 6,184 real app takes also graded by SpeechSuper, 12 were refused, against 328 with the previous rule (102 of those read the prompt; now 1). Wrong-prompt recordings that are scored came out at a median of 6 and below 60 outside Mandarin. Treat a content, content_mismatch_suspected or content_not_confirmed warning as a sign of a different text. Words the learner skipped come back omitted with score 0, and the overall falls with the share of words said (warning incomplete_reading). More detail, known limits and sample responses are on each language page; vendor comparisons are on /compare/.

Credits & billing

Choose a $10, $50, or $150 monthly subscription in your dashboard through Stripe. Plans include 2,500, 15,000, or 50,000 credits each month, credited after successful payment. Unused credits roll over. Higher plans include 10% or 20% off extra credit packs. Every new account also gets 50 free credits once; they work without a subscription and are spent before plan credits. When fewer free credits are left than a recording needs, it uses the ones that are left instead of being refused (billing.credits_waived says how many were waived). A successful, assessable request uses one credit for each started 15 seconds of audio:

Decoded audio durationCharge
Up to 15 seconds1 credit
More than 15, up to 30 seconds2 credits
Each further started 15 seconds, up to 120 seconds+1 credit (8 at most)
Failed or unassessable request0 credits
Result in which no word got a score0 credits (not_charged_reason: no_word_scored)
Long passage with pieces that could not be scoredOnly the scored share of the audio, at least 1 credit (credits_not_charged, unscored_pieces)
Result finished after the website proxy’s 26 s limit, or after you disconnected0 until you fetch it with the same Idempotency-Key; charged once then

Once the free credits are used, an active paid subscription is required to assess and buy extra packs. Plan changes take effect at the next renewal. Canceling stops renewal and keeps access through the paid period; your remaining credits stay in the account and can be used when you resubscribe. The supported terms, including what happens to credits after a plan ends, are published from the billing code at /terms/ and as JSON at GET /v1/terms. The final charge and remaining balance are returned in billing. Payment confirmation can arrive after the Stripe success redirect; your ledger is updated when payment is verified. See pricing.

Limits & rate limits

LimitValueWhen exceeded
Assessment requests per account60 per minute429 rate_limit
Assessments in progress per account2 at a time on every plan today; the per-plan values are in GET /v1/terms → limits.concurrent_requests_by_plan429 account_busy with Retry-After
Engine time per assessment90 seconds for audio of 30 s or less, 180 seconds above, every plan503 engine_unavailable, not charged
Request through api.toneperfect.app26 seconds (website proxy)504 from the proxy. Retry with the same key: you get the result and pay once. A result nobody received is never charged.
Reference checks (/v1/lint)120 per minute per IP address429 rate_limit
GET /v1/capabilities120 per minute per IP address429 rate_limit
Audio duration0.15 to 120 seconds422 invalid_audio
Upload size10 MB413 upload_too_large
Upload time30 seconds408 upload_timeout
Reference text2,000 characters (Mandarin: 600 characters; other languages: 320 words)422 invalid_reference or invalid_assessment
Pinyin1,000 characters, 100 syllables422 invalid_reference or invalid_assessment
Active API keys20 per accountRevoke one to create another

When the service itself is at capacity it answers 503 gateway_busy (with a Retry-After header) or decoder_busy; nothing is charged and the same key should be retried. Most short clips return in a second or two (median 1.2 s, 90th percentile 2.2 s on customer calls since September); the first request after a quiet period can take several seconds.

Capacity, honestly

Today one GPU server scores every language, with a queue shared by all customers. A long passage holds it for 10–20 seconds, and short clips sent meanwhile wait a few seconds. When the queue is full, a short clip may be scored by the fallback engine (see Engine and fallback); otherwise the request gets 503 engine_unavailable (not charged; retry after a short delay). That is plenty for an app whose learners record at different moments, and not enough for a class of 30 pressing "record" in the same second: queue on your side or spread those submissions over a few seconds. Talk to us before a launch or a classroom roll-out and we will size it with you.

Requests through api.toneperfect.app pass a proxy with a 26-second timeout. Passages over about 60 seconds can take longer than that to score, so use a client timeout above 26 seconds and, on a 504, retry with the same Idempotency-Key: the stored result comes back and is charged once, never twice. Each response carries X-TonePerfect-Credits-Charged, X-TonePerfect-Plan-Credits, X-TonePerfect-Free-Credits and X-RateLimit-Limit headers (replays too). Refused requests (402, 429 and the rest) are listed in your dashboard so you can see what your integration ran into.

Safe retries

Send a unique Idempotency-Key (any printable ASCII up to 255 characters, for example a UUID) for each recording attempt. It is optional: without it the API makes one and echoes it in the response header, but then only a retry that resends that echoed key is safe (the samples generate one per call: $(uuidgen) in a shell, crypto.randomUUID() in JavaScript, uuid.uuid4() in Python; never hard-code one). Reuse a key only to retry the same recording; a new recording needs a new key. If a network error or a proxy timeout prevents you from receiving a result, retry with the same key and identical audio, reference text, language, pinyin and practice type. A completed result is returned without charging again (with an Idempotent-Replayed: true header).

  • Proxy 504 or disconnect. A result that finished after you stopped waiting is stored uncharged; the first retry with the same key returns it and charges it, once.
  • 5xx failures are not kept. After engine_unavailable or request_interrupted, the same key runs the request again (not charged unless it succeeds).
  • Other completed outcomes are kept. A 200 (scored or unassessable) or a 422 invalid_assessment is returned again for 24 hours; use a new key for a new attempt.

Reusing a key with a different request returns a conflict. Keep the same key when the result is unknown or still pending, including an HTML, empty or unrecognized 502/504 proxy response. Stored results expire after 24 hours; an expired key returns a conflict and never causes another charge. MCP calls without an idempotency_key get one derived from the call itself, so an agent’s retry of the same call on the same UTC day is not charged twice.

Engine and fallback

Every language is scored by the current engine (engine_route.engine: "primary"). When that engine is down, unreachable, still starting or its queue is full, a recording of 30 seconds or less is scored by the previous engine instead, and the response says so: engine_route.engine: "fallback" with a reason, X-TonePerfect-Engine: fallback, and +fallback on model_version. The previous engine is calibrated differently and has none of the newer checks, so its scores are not directly comparable: store engine_route with each score.

The fallback is never used when the current engine failed on that recording (you get 503 engine_unavailable, not charged), for longer recordings, or for requests the previous engine treats differently: Mandarin with pinyin, digits, Latin letters in Mandarin text, more than 500 characters, 40 words or 100 Mandarin characters. To get a 503 instead of a fallback score, send TonePerfect-Fallback: off. While the current engine is down, GET /v1/capabilities shows the affected locales with engine: "fallback" and the previous engine’s 30-second limit.

Errors

Errors are JSON: {"error": {"code": "…", "message": "…"}, "request_id": "req_…"}; request_id is present where available and every response carries an X-Request-Id header. A finalized failure (marked below) is stored under its key and carries id and billing instead of request_id; a 503 engine_unavailable also carries id and billing.credits: 0 but is not kept, so the same key may be retried. Branch on error.code, not on the message.

A 402 says what to do and where: billing_url opens the billing tab of the dashboard, pricing_url the plans, and plan is the least expensive monthly plan on sale. A plan whose renewal payment failed or is still pending gets subscription_past_due (plan credits are kept), not subscription_required. The balances are in the X-TonePerfect-Plan-Credits and X-TonePerfect-Free-Credits headers.

JSON · 402
{
  "error": {
    "code": "subscription_required",
    "message": "Your free credits are used up. Choose a monthly plan at https://api.toneperfect.app/dashboard?tab=billing (Starter: $10 a month for 2,500 credits); assessments resume as soon as the payment is confirmed. No credits were charged.",
    "billing_url": "https://api.toneperfect.app/dashboard?tab=billing",
    "pricing_url": "https://api.toneperfect.app/pricing/",
    "plan": {
      "id": "starter",
      "name": "Starter",
      "monthly_credits": 2500,
      "price_usd": 10,
      "interval": "month"
    }
  },
  "request_id": "req_example"
}
StatusCodeMeaningWhat to do
400invalid_multipartThe body is not readable multipart/form-data.Send multipart fields audio, text and language; let your HTTP client set the boundary.
401invalid_api_keyThe key is missing, unknown or revoked (the message says which).Send Authorization: Bearer YOUR_KEY (the scheme in any case, or the bare key) or X-Api-Key. Create a key in the dashboard.
402subscription_requiredFree credits are used up (or a cancelled plan’s credits are on hold) and there is no active paid monthly plan. The error carries billing_url, pricing_url and the cheapest plan on sale with its price.Start a plan at billing_url. Existing credits are kept.
402subscription_past_dueThe monthly plan’s renewal payment failed or is not confirmed yet. Plan credits are kept.Check the payment method at billing_url; calls resume when the payment is confirmed.
402insufficient_creditsThe plan balance does not cover this recording (1 credit per started 15 s). Free credits never cause this: a clip longer than the free credits left uses what is left.Buy an extra credit pack or wait for the monthly renewal.
402payment_balance_dueA refunded or disputed purchase left a balance to settle.The next purchase settles it first.
405method_not_allowedWrong method or path, for example a trailing slash (POST /v1/assess/).POST to /v1/assess without a trailing slash.
408upload_timeoutThe upload took longer than 30 seconds, sent nothing for 10 seconds, or averaged under 4 KiB/s after its first 5 seconds. Nothing was charged.Retry with the same key.
409idempotency_conflictThis Idempotency-Key was used with different audio or fields.Use a new key for a new attempt.
409request_pendingThe assessment for this key is still running.Retry the same key shortly.
409idempotency_expiredThe stored result for this key is older than 24 hours.Use a new key. An expired key never charges again.
413upload_too_largeThe upload is over 10 MB.Send a shorter or compressed recording.
415invalid_content_typeThe body is JSON or raw audio, not a form.Send multipart/form-data with a file part named audio and the fields text and language.
422invalid_idempotency_keyThe Idempotency-Key header is longer than 255 characters or contains a character that is not printable ASCII (the message says which).Send up to 255 printable ASCII characters, for example a UUID, or leave the header out: it is optional.
422missing_audioNo file in the audio field.Attach the recording as a file part named audio.
422invalid_referenceNo text or pinyin, or a field is too long.Send text (up to 2,000 characters). For zh-CN send Chinese characters or pinyin with tones (ni3 hao3 or nǐ hǎo, up to 100 syllables).
422invalid_tasktask is not one of the accepted values.Use general, connected_speech or isolated_word.
422invalid_test_outcomeTonePerfect-Test-Outcome names an outcome a test key cannot rehearse.Use success, unassessable, invalid_assessment, engine_unavailable, subscription_required, subscription_past_due, insufficient_credits, account_busy or rate_limit, or drop the header.
422invalid_inputtext, pinyin or language is not a string.Send them as plain form fields.
422missing_languageNo language field, and the text is not Mandarin (Mandarin text without the field is still scored as zh-CN).Send language; the message names the locale the text’s script suggests.
422invalid_languagelanguage is longer than 16 characters.Send a locale code such as en-US.
422unsupported_languageThe locale is not available. Short codes (en, de, ja) and en-EN resolve on their own; another region of a supported language (en-GB, pt-PT) gets a “did you mean”.Choose an available locale from GET /v1/capabilities.
422invalid_audioThe file could not be decoded, or is shorter than 0.15 s or longer than 120 s.Send WAV, MP3, M4A, Ogg or WebM between 0.15 and 120 seconds.
422invalid_assessment · finalizedThe engine rejected this reference and recording, for example a Mandarin reference with neither characters nor pinyin with tones, pinyin without tones, or text in the wrong script for the locale.Check the reference text against the language (POST /v1/lint is free). Not charged; a new attempt needs a new key.
429rate_limitMore than 60 assessment requests in a minute for this account.Slow down and retry the same key after a short delay.
429account_busyThe account already has its concurrent-assessment limit running (2 by default; see limits in GET /v1/capabilities).Wait for one to finish, then retry the same key.
429free_capacityFree credits have reached today’s shared daily limit. Nothing was charged.Retry tomorrow with a new Idempotency-Key, or start a plan to use plan credits now.
429uploads_in_progressThis account (or this network address) already has 4 uploads in progress (1 for an account with no credits and no plan).Wait for one to finish, then retry the same key.
503gateway_busyThe upload gateway is at capacity. Nothing was charged.Retry the same key after the Retry-After delay.
503decoder_busyThe audio decoder is at capacity.Retry the same key shortly.
503audio_decoder_unavailableAudio decoding is temporarily unavailable.Retry the same key shortly.
503engine_unavailableThe engine could not finish the assessment, or its queue was full (or, from GET /v1/capabilities, is unreachable). Not charged. When the previous engine could not take over, error.fallback_unavailable_reason says why.Retry after a short delay, with the same key or a new one: a 5xx result is not kept, so the same key runs the request again.
503request_interruptedThe request was interrupted before the engine finished. Not charged.Retry with the same key.
504result_heldThe result finished after the website proxy’s 26-second limit (you normally see the proxy’s own 504 instead). It is stored and not charged.Retry with the same key and identical fields: you receive the result and it is charged then, once.

If the audio cannot be meaningfully assessed, the result is instead a successful response with assessable: false and a reason. Do not show it to your learner as a pronunciation score of zero.

Unassessable reasonMeaning
no_speech / no_audioSilence or no usable speech.
too_shortLess speech than the engine needs. A very short one- or two-word clip is padded and scored first (warning short_clip_padded).
different_contentThe recording is a different text: what the speech recognizer heard covers little of the reference and the sounds do not match it. Only prompts of 10 syllables or more (Mandarin: 10 characters) are refused this way; a shorter one is scored with warning content_mismatch_suspected or content. A different text is not always caught: see “Wrong text” under Languages & capabilities.
incomplete_readingMandarin long passage: far less audio than the reference text (only part of the passage was read).
unsupported_phonetic_symbolsEvery word uses sounds outside the pack’s inventory and the rest could not be measured reliably (for example Portuguese “Eu”).
language_model_not_installedThe language pack is not installed on this server.
no_calibrated_unitsNo unit could be graded against the native references.

Common first-call mistakes

What hand-written or AI-written first integrations most often send, and what comes back. The MCP endpoint answers 503 mcp_unavailable while it is paused; the REST API is unaffected.

SentAnswerFix
A JSON body or a raw audio body415 invalid_content_type, naming what to sendSend multipart/form-data with the recording as a file part named audio and the fields text and language.
An audio URL in a form field instead of a file422 missing_audioUpload the file itself; there is no URL input.
No language fieldMandarin text: scored as zh-CN. Any other text: 422 missing_language, naming the likely localeAlways send language, for example en-US or zh-CN.
Another region of a supported language (en-GB, pt-PT, es-ES)422 unsupported_language with a “did you mean”Send one of the locales from GET /v1/capabilities: zh-CN, en-US, fr-FR, es-419, de-DE, it-IT, pt-BR, ru-RU, ko-KR, ja-JP. Bare codes (en, de, ja) resolve on their own.
An Idempotency-Key over 255 characters or with non-ASCII characters422 invalid_idempotency_key, naming the ruleSend a UUID per recording attempt, or leave the header out.
A field named reference_text, transcript or prompt instead of text422 invalid_referenceThe field is text (or pinyin for Mandarin).
POST /v1/assess/ (trailing slash)405 method_not_allowed: “Did you mean /v1/assess (no trailing slash)?”POST /v1/assess, no trailing slash.
A path that does not exist (/v1/languages, /v1/score)404 not_foundThe routes are POST /v1/assess, GET /v1/capabilities, POST /v1/lint, GET /v1/status, GET /v1/terms and POST /v1/mcp.
POST /v1/lint with a form body415 invalid_content_type/v1/lint takes JSON with Content-Type: application/json.

Browser & mobile apps

Every /v1 route answers CORS preflight requests (Access-Control-Allow-Origin: *, no cookies), so a browser can call the API directly, for example from a prototype or an internal tool. Anyone who opens that page can read a key you put in it and spend your credits, so for anything public keep the key on a server and forward the recording: a small proxy with an origin allowlist, a per-IP limit and a fixed list of texts is on the embed page. Mobile apps should do the same; key names like prodapp in a shipped binary are extractable. A test key is the exception: it cannot spend anything, so publish it freely in demos while you build. There are no live “publishable” keys: an origin restriction is a header any script can forge, so it would not protect your credits. Three small proxies (Next.js route, Cloudflare Worker for Expo, Firebase Function for Flutter) are in the starter projects.

MCP for AI agents

https://api.toneperfect.app/v1/mcp is a Model Context Protocol server (Streamable HTTP, JSON responses). Tools: list_languages, check_reference_text (free), explain_tone_error (free) and assess_pronunciation, which takes base64 audio and returns the compact schema, billed exactly like /v1/assess. Put your key in the client's Authorization: Bearer header. For desktop agents that work with files, npx toneperfect-mcp runs a local bridge that also accepts audio_path.

MCP client configuration
{
  "mcpServers": {
    "toneperfect": {
      "type": "http",
      "url": "https://api.toneperfect.app/v1/mcp",
      "headers": {
        "Authorization": "Bearer tp_live_YOUR_SECRET_KEY"
      }
    }
  }
}

Requests through api.toneperfect.app pass a proxy with a 26-second limit; long recordings from agents are safer through the SDKs. A call that hits the limit is not charged; repeating it (same arguments, same idempotency_key or none) returns the result and charges it once.

OpenAPI & llms.txt

An OpenAPI 3.1 description of the public endpoints is at /openapi.json; import it into Postman, Insomnia or a client generator. A plain-text summary for AI assistants is at /llms.txt, and the full documentation as one text file at /llms-full.txt.

Guides & comparisons