কণ্ঠ REST API: নিজের প্রোগ্রাম থেকে বাংলা অডিও বানান
লেখা পাঠান, WAV ফাইল পান। কী, উদাহরণ, সীমা আর এরর।
লেখক: কণ্ঠ AI টিমআপডেট:
কণ্ঠ REST API দিয়ে আপনার নিজের সার্ভার বা অ্যাপ থেকে বাংলা লেখা পাঠিয়ে অডিও (WAV অথবা MP3) বানানো যায়, তারপর ফাইলটা নিজের সিস্টেমে নামিয়ে নেওয়া যায়। এতে আপনার কণ্ঠ-ক্লোন করা ভয়েস, তৈরি ২৪টি কণ্ঠ আর আঞ্চলিক টান সবই চলে। অনুমতি দেয় একটি অ্যাপ্লিকেশন কী; উত্তর আসে JSON-এ।
৩ ধাপে শুরু
কী বানান।সাইন আপ করে যেকোনো একটি প্যাকেজ কিনুন (API ব্যবহারের জন্য একবার কেনা লাগে), তারপর ড্যাশবোর্ডের “API ও MCP” ট্যাবে কী বানান। কীটি kontho_sk_… দিয়ে শুরু; এটি শুধু একবার দেখানো হয়, তাই কপি করে নিরাপদ জায়গায় রাখুন।
অডিও বানান।POST /v1/speech-এ লেখা পাঠান। উত্তরে অডিওর আইডি, সময় আর কত ক্রেডিট কাটল তা আসে।
ফাইল নামান।GET /v1/speech/{id}/audio থেকে WAV নিন (MP3 চাইলে শেষে ?format=mp3)। অথবা প্রথম অনুরোধেই Accept: audio/wav বা audio/mpeg দিন, তাহলে সরাসরি ফাইলটাই ফেরত আসবে।
সব অনুরোধে হেডারে Authorization: Bearer <আপনার কী> দিন। API ডাকুন আপনার সার্ভার থেকে, ওয়েব পেজের ভেতর থেকে নয়: ব্রাউজারে কী রাখলে যে কেউ সেটা দেখে ফেলতে পারে, তাই এই API ব্রাউজারকে উত্তর পড়তেই দেয় না।
The Kontho REST API lets your own server or app send Bangla text, make audio (WAV or MP3) and download the file into your own system. It works with voices you cloned, the 24 ready-made voices and every regional accent. An application key is the permission; answers come as JSON.
Start in 3 steps
Make a key.Sign up, buy any package (the API needs one purchase), then make a key in the dashboard tab “API ও MCP”. It starts with kontho_sk_… and is shown only once, so copy it somewhere safe.
Make audio. Send the text to POST /v1/speech. The answer has the audio id, its length and how many credits it cost.
Download the file. Get the WAV from GET /v1/speech/{id}/audio (add ?format=mp3 for an MP3). Or send Accept: audio/wav or audio/mpeg with the first request and the file comes straight back.
Send Authorization: Bearer <your key> with every request. Call the API from your server, not from inside a web page: a key in a browser can be seen by anyone, so this API does not let browsers read its answers.
import os, requests
key = os.environ["KONTHO_API_KEY"]
auth = {"Authorization": f"Bearer {key}"}
r = requests.post("https://kontho.net/v1/speech",
headers={**auth, "Idempotency-Key": "order-1001"},
json={"text": "আমি বাংলায় কথা বলি।", "voice_id": "builtin:nila"},
timeout=600) # a long text can take minutes
r.raise_for_status()
speech = r.json()
open("hello.wav", "wb").write(requests.get(speech["audio_url"], headers=auth).content)
প্রতিটি কল একটি মেশিন-পাঠযোগ্য ফাইলে বর্ণনা করা আছে:openapi.json (OpenAPI 3.1)
সব কল
GET /v1/balance
কত ক্রেডিট বাকি। বিনামূল্যে।
GET /v1/voices
আপনার ক্লোন করা ও তৈরি কণ্ঠ, আঞ্চলিক টান, বলার ধরন, মানের দাম। বিনামূল্যে।
POST /v1/text/fix
সংখ্যা, তারিখ, চিহ্ন বাংলা শব্দে লেখা; চাইলে আঞ্চলিক টানে। সর্বোচ্চ ২,০০০ অক্ষর। বিনামূল্যে।
একটি অডিওর পুরো তথ্য ও লগইন ছাড়া ডাউনলোড লিংক। বিনামূল্যে।
GET /v1/speech/{id}/audio
WAV ফাইল, বা ?format=mp3 দিলে MP3 (Range চলে)। বিনামূল্যে।
POST /v1/speech-এর ফিল্ড: text (দরকারি), voice_id (builtin:nila বা নিজের কণ্ঠের নম্বর), style, dialect, quality (fast বা hq), format (wav বা mp3), fix_text (true দিলে আগে লেখা ঠিক করে নেয়)। সব বিকল্পের তালিকা GET /v1/voices-এ আছে।
GET /v1/balance
Credits left. Free.
GET /v1/voices
Your cloned voices, the ready-made voices, accents, speaking styles and quality prices. Free.
POST /v1/text/fix
Writes numbers, dates and symbols as Bangla words; optionally in a regional accent. Up to 2,000 characters. Free.
POST /v1/speech/estimate
What a text would cost. Free.
POST /v1/speech
Makes audio. 1 credit per second (HQ: 2).
GET /v1/speech
Recent audio (limit, before). Free.
GET /v1/speech/{id}
Full details of one audio and a download link that needs no key. Free.
GET /v1/speech/{id}/audio
The WAV file, or the MP3 with ?format=mp3 (Range works). Free.
Fields of POST /v1/speech: text (required), voice_id (builtin:nila or the number of your own voice), style, dialect, quality (fast or hq), format (wav or mp3) and fix_text (true fixes the text for speech first). GET /v1/voices lists every option.
সীমা আর জেনে রাখুন
লেখার দৈর্ঘ্য: প্রতি কলে সর্বোচ্চ ৫,০০০ অক্ষর (fix_text দিলে ২,০০০)। তবে ২,৫০০ অক্ষরের বেশি এক কলে না দেওয়াই ভালো: বড় লেখায় কয়েক মিনিট লাগে, আর আপনার প্রোগ্রাম আগে থেমে গেলে সেই অডিও হারিয়ে যেতে পারে। বড় স্ক্রিপ্ট কয়েক ভাগ করে পাঠান, তারপর WAV ফাইলগুলো জুড়ে নিন।
খরচ: অডিওর আসল দৈর্ঘ্য ধরে ১ সেকেন্ডে ১ ক্রেডিট, HQ হলে ২। আগে দেখতে চাইলে POST /v1/speech/estimate। ব্যর্থ হলে কিছু কাটে না।
পুনরায় চেষ্টা নিরাপদ: প্রতিটি অডিওর জন্য একটি নতুন Idempotency-Key (১–৬৪ অক্ষর: ইংরেজি অক্ষর, সংখ্যা, -, _) দিন। কল থেমে গেলে একই লেখা আর একই কী দিয়ে আবার পাঠান: প্রথম উত্তরটাই ফেরত আসবে (Idempotent-Replayed: true), ক্রেডিট দ্বিতীয়বার কাটবে না। কী প্রায় ২৪ ঘণ্টা মনে রাখা হয়।
হার সীমা: অডিও বানানো মিনিটে ১০টি, ঘণ্টায় ৩০০টি, দিনে ২,০০০টি; সব কল মিলিয়ে মিনিটে ৩০০টি; ভুল কী ১৫ মিনিটে ৩০ বার। সীমা পেরোলে 429 আর Retry-After হেডার আসে।
ফাইল ৩০ দিন থাকে। তারপর মুছে যায় (410 AUDIO_EXPIRED)। বানানোর পরেই নামিয়ে নিজের সিস্টেমে রাখুন।
ফরম্যাট: WAV (ডিফল্ট; ২৪ kHz, মনো, ১৬-বিট) অথবা MP3 (১২৮ kbps, মনো)। MP3 চাইতে "format":"mp3" দিন (ডাউনলোডে ?format=mp3; Accept: audio/mpeg দিলে সরাসরি MP3 ফাইল আসে)। MP3-র জন্য আলাদা ক্রেডিট লাগে না। কোনো অডিওর প্রথম MP3 বানাতে একটু সময় লাগে (মিনিটপ্রতি প্রায় ১ সেকেন্ড), তারপর সেটি রেখে দেওয়া হয় এবং WAV-এর সাথেই ৩০ দিন পর মুছে যায়। ওয়েবসাইটে লম্বা স্ক্রিপ্ট থেকে বানানো অডিওর MP3 হয় না।
কী গোপন রাখুন। কী ফাঁস হলে ড্যাশবোর্ড থেকে বাতিল করে নতুন বানান। প্রতিটি সিস্টেমের জন্য আলাদা কী নিন।
প্রতিটি অডিওতে অদৃশ্য ডিজিটাল জলছাপ (SynthID) থাকে। অন্যের কণ্ঠ ক্লোন করা নিষেধ। কণ্ঠ ক্লোন করতে হয় ওয়েবসাইটে (সম্মতির রেকর্ডিংসহ), API দিয়ে নয়।
Text length: up to 5,000 characters per call (2,000 with fix_text). But please keep a call to about 2,500 characters: a long text takes minutes, and if your program gives up first that audio can be lost. Send a long script in parts and join the WAV files.
Cost: 1 credit per second of the real audio length, 2 for HQ. Use POST /v1/speech/estimate to see it first. A failed call charges nothing.
Retries are safe: send a new Idempotency-Key (1–64 characters: letters, digits, -, _) for each audio. If a call times out, send the same text with the same key again: you get the first answer back (Idempotent-Replayed: true) and the credits are not charged twice. Keys are remembered for about 24 hours.
Rate limits: making audio 10 a minute, 300 an hour, 2,000 a day; all calls together 300 a minute; wrong keys 30 per 15 minutes. Over the limit you get 429 and a Retry-After header.
Files are kept for 30 days, then deleted (410 AUDIO_EXPIRED). Download the audio right after making it and keep it in your own system.
Format: WAV (the default; 24 kHz, mono, 16-bit) or MP3 (128 kbps, mono). Ask for MP3 with "format":"mp3" (or ?format=mp3 on a download; Accept: audio/mpeg returns the MP3 file itself). MP3 costs no extra credits. The first MP3 of an audio takes a moment to make (about a second per minute of audio); it is then kept and deleted with the WAV after 30 days. Audio from a long script made on the website has no MP3.
Keep the key secret. If it leaks, revoke it in the dashboard and make a new one. Use a separate key for each system.
Every audio carries an invisible digital watermark (SynthID). Cloning other people's voices is not allowed. Voices are cloned on the website (with the consent recording), not through the API.
এরর
এরর এলে উত্তর এমন: {"error":{"code":"INSUFFICIENT_CREDITS","message":"…","message_bn":"…","status":402}}। কোডে code দেখুন, message মানুষের জন্য। ref নম্বর থাকলে সাপোর্টকে জানান।
401API_KEY_REQUIRED, API_KEY_INVALID
কী নেই, ভুল, বাতিল, অথবা অ্যাকাউন্ট বন্ধ।
403API_NEEDS_PURCHASE
অডিও বানাতে ও নামাতে একবার যেকোনো প্যাকেজ কিনতে হবে।
ভয়েস সার্ভিসে সমস্যা বা ব্যস্ত। কোনো ক্রেডিট কাটে না; একটু পরে আবার চেষ্টা করুন।
An error looks like this: {"error":{"code":"INSUFFICIENT_CREDITS","message":"…","message_bn":"…","status":402}}. Check code in your program; message is for people. If there is a ref number, give it to support.
401API_KEY_REQUIRED, API_KEY_INVALID
The key is missing, wrong, revoked, or the account is closed.
403API_NEEDS_PURCHASE
Making and downloading audio needs one purchase of any package.
The voice service had a problem or is busy. No credits are charged; try again a little later.
চ্যাটবট থেকে কণ্ঠ ব্যবহার (MCP)
Claude, ChatGPT, Cursor বা Codex-এর সাথে Kontho যুক্ত করলে চ্যাটবটকেই বলতে পারেন, যেমন: “এই লাইনটা নীলার কণ্ঠে অডিও করো”। চ্যাটবট আপনার অ্যাকাউন্টের ক্রেডিটে অডিও বানায় (১ সেকেন্ডে ১ ক্রেডিট, HQ হলে ২; প্রতি অনুরোধে সর্বোচ্চ ৫,০০০ অক্ষর) আর ৩০ দিনের ডাউনলোড লিংক দেয়; লিংকের শেষে ?format=mp3 জুড়লে MP3 পাবেন। এই সংযোগে কণ্ঠ ক্লোন করা যায় না। সার্ভারের ঠিকানা: https://kontho.net/mcp।
Claude (ওয়েব/ডেস্কটপ): Customize → Connectors → Add custom connector → ঠিকানাটি দিন → “Allow” চাপুন। কী লাগে না।
Claude Code ও Codex: নিচের কমান্ড কয়েকটি চালান। Codex-এ কী লাগে না (OAuth)।
Cursor ও অন্যান্য টুল: ড্যাশবোর্ডের “API ও MCP” ট্যাবে বানানো একটি কী, হেডার হিসেবে।
Connect Kontho to Claude, ChatGPT, Cursor or Codex and you can simply ask the chatbot, for example: “Make this line into audio in Nila's voice”. The chatbot spends your account's credits (1 per second, HQ 2; up to 5,000 characters per request) and gives you a download link valid for 30 days; add ?format=mp3 to the end of the link for an MP3. Voices cannot be cloned through this connection. Server address: https://kontho.net/mcp.
Claude (web/desktop): Customize → Connectors → Add custom connector → paste the address → press “Allow”. No key needed.
ChatGPT: Settings → Connectors → Create → paste the address, Authentication: OAuth → “Allow” (a custom connector may need Developer mode or a Plus/Pro plan).
Claude Code and Codex: run the commands below. Codex needs no key (OAuth).
Cursor and other tools: a key made in the dashboard tab “API ও MCP”, sent as a header.
# Claude Code
/plugin marketplace add Ankabut-Software/kontho
/plugin install kontho@kontho
# Codex
codex mcp add kontho --url https://kontho.net/mcp
codex mcp login kontho
# Cursor and other tools (the key goes in the header)
{"mcpServers":{"kontho":{"url":"https://kontho.net/mcp","headers":{"Authorization":"Bearer <KEY>"}}}}