Switching from ElevenLabs
The speech-to-text endpoint takes ElevenLabs' request and returns its response, so your code keeps working with a few changes.
What to change
Four things: point the client at https://api.platform.klang.ai, use a Klang API key, set model_id to pianissimo or pianissimo_pro, and set language_code. The path is the same, /v1/speech-to-text, and the key is read from xi-api-key just like ElevenLabs.
The Python SDK works with its retries turned off, as below: a retry resends the file without model_id and language_code. Retry 429 and 503 yourself after Retry-After seconds, with the file opened again. The Node.js SDK (@elevenlabs/elevenlabs-js) rejects the response, because it requires a logprob on every word, which Klang doesn't return yet; call the endpoint with fetch instead (Node.js 20 or later).
import os
from elevenlabs.client import ElevenLabs
client = ElevenLabs(
api_key=os.environ["KLANG_API_KEY"],
base_url="https://api.platform.klang.ai",
)
with open("meeting.mp3", "rb") as f:
transcript = client.speech_to_text.convert(
file=f,
model_id="pianissimo",
language_code="sv",
# The SDK's retries resend the file without the form fields.
request_options={"max_retries": 0},
)
print(transcript.text)import { openAsBlob } from "node:fs";
const form = new FormData();
form.append("model_id", "pianissimo");
form.append("language_code", "sv");
form.append("file", await openAsBlob("meeting.mp3"), "meeting.mp3");
const response = await fetch("https://api.platform.klang.ai/v1/speech-to-text", {
method: "POST",
headers: { "xi-api-key": process.env.KLANG_API_KEY },
body: form,
});
if (!response.ok) throw new Error((await response.json()).error.message);
console.log((await response.json()).text);Klang does not detect the language, which is why language_code is required. Swedish and Danish run on Pianissimo, our fine-tunes; the other 23 languages run on NVIDIA's Parakeet (parakeet-tdt-0.6b-v3) as released, under the same model ids.
Parameters
Klang refuses an option it can't honour with 400 unsupported_parameter instead of ignoring it, so you never think you got a feature you didn't. Sending one at its off value (diarize=false, an empty webhook field) is fine.
| parameter | on Klang |
|---|---|
file, model_id | Supported. model_id takes Klang's models. |
language_code | Required: one of 25 languages, as a two-letter ISO 639-1 code (sv, not swe). See the reference for the list. |
keyterms | Supported with pianissimo_pro: up to 1000 terms, each at most 50 characters and 5 words, without < > { } [ ] \ or control characters, and at most 64 KB together. See the reference. |
file_format | Supported: other or pcm_s16le_16. |
enable_logging | Accepted as a form field or query parameter, no effect: audio and transcripts are never stored, and request metadata is always kept for billing. |
diarize, num_speakers, diarization_threshold | Not yet. |
tag_audio_events | Not yet. |
timestamps_granularity=character or none | Not yet. Word timestamps are always included. |
webhook, webhook_id, webhook_metadata | Not yet. Every request is answered synchronously. |
cloud_storage_url, source_url | Not yet. Upload the file. |
use_multi_channel, additional_formats | Not yet. |
temperature, seed, entity detection and redaction, no_verbatim | Not yet. |
Response differences
The response has ElevenLabs' fields, filled where Klang has the data:
wordshaswordandspacingitems with start and end times. There is nospeaker_id,logproboraudio_eventyet.language_probabilityis always1, since you name the language.- Two extra fields:
model_id, andaudio_seconds, the length you are billed for.