টেক্সট অনুবাদ API
GPT Translator API ব্যবহার করে টেক্সট অনুবাদ করুন।
এন্ডপয়েন্ট
POST https://api.gpttranslator.co/v1/translation/text-translation/api
প্রমাণীকরণ
রিকোয়েস্ট হেডারে আপনার API কী যোগ করুন:
x-api-key: YOUR_API_KEY
Content-Type: application/json
রিকোয়েস্ট বডি
আবশ্যিক ফিল্ড:
textstring: অনুবাদের জন্য সোর্স টেক্সটsourceLangstring: সোর্স ভাষার কোডtargetLangstring: টার্গেট ভাষার কোডmodelstring: অনুবাদ মডেলের নাম
ঐচ্ছিক ফিল্ড:
domainstring: ডোমেইন বিশেষায়নwritingStylestring: লেখার ধরন পছন্দtonestring: টোন পছন্দcustomPromptstring: কাস্টম অনুবাদ নির্দেশনা
ভাষার কোড আলাদাভাবে দেওয়া আছে সমর্থিত ভাষা. সমর্থিত মডেল দেওয়া আছে সমর্থিত মডেল.
ভ্যালিডেশন নিয়ম
text: আবশ্যিক। খালি রাখা যাবে না।sourceLang,targetLang: অবশ্যই^[a-zA-Z]+(-[a-zA-Z]+)?$এর সাথে মিলতে হবে, ন্যূনতম ২ অক্ষর, সর্বোচ্চ ১১ অক্ষর। অবশ্যই সমর্থিত ভাষা-এর একটি কোড হতে হবে।model: অবশ্যই সমর্থিত মডেল-এর কোনো একটি মান হতে হবে।
উদাহরণ
cURL
curl --location 'https://api.gpttranslator.co/v1/translation/text-translation/api' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"text": "hello world",
"sourceLang": "en",
"targetLang": "fr",
"model": "gpt-4.1-mini-2025-04-14"
}'
JavaScript
const response = await fetch(
"https://api.gpttranslator.co/v1/translation/text-translation/api",
{
method: "POST",
headers: {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
text: "hello world",
sourceLang: "en",
targetLang: "fr",
model: "gpt-4.1-mini-2025-04-14",
}),
},
);
const data = await response.json();
console.log(data);
Python
import requests
url = "https://api.gpttranslator.co/v1/translation/text-translation/api"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"text": "hello world",
"sourceLang": "en",
"targetLang": "fr",
"model": "gpt-4.1-mini-2025-04-14"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
রেসপন্সের ধরন
সফল 200
{
"message": "Text translation completed successfully",
"error": null,
"data": {
"translatedText": "bonjour le monde",
"originalText": "hello world",
"totalWords": 2,
"isRTL": false,
"tokensConsumed": 3
},
"statusCode": 200
}
রিকোয়েস্ট ভ্যালিডেশন ত্রুটি 400
ভ্যালিডেশন মিডলওয়্যারের ত্রুটি এই ফরম্যাটে ফেরত আসে:
{
"error": "Invalid source language. Please select a supported language."
}
অন্যান্য সম্ভাব্য ভ্যালিডেশন ত্রুটি:
Invalid target language. Please select a supported language.Invalid model type. Please enter a valid model type e.g. ...Text cannot be empty.Text is required.
API কী অনুপস্থিত/অবৈধ হেডার 401
{
"message": "Invalid api key",
"error": "Invalid api key",
"statusCode": 401,
"data": null
}
API কী বা ব্যবহারকারী সেটআপ ত্রুটি 400
ডেটাবেসে অবৈধ কী:
{
"message": "Invalid api key",
"error": "Invalid api key",
"statusCode": 400,
"data": null
}
ব্যবহারকারী সক্রিয় নয়:
{
"message": "User not found or user is not active",
"error": "User not found or user is not active",
"statusCode": 400,
"data": null
}
প্রতিষ্ঠান অনুপস্থিত:
{
"message": "Organization Id not found for the user",
"error": "Organization Id not found for the user",
"statusCode": 400,
"data": null
}
প্ল্যান সীমাবদ্ধতা 402
{
"message": "only subscribed users are allowed to use this model",
"error": "only subscribed users are allowed to use this model",
"data": null,
"statusCode": 402
}
টোকেন সীমা পূর্ণ হয়েছে 402
{
"message": "You have reached the limit of words for translation. Please upgrade your plan to continue using this feature.",
"error": "You have reached the limit of words for translation. Please upgrade your plan to continue using this feature.",
"data": {
"requiredTokens": 123,
"tokens": 45
},
"statusCode": 402
}
প্রসেসিং/সার্ভার ত্রুটি 500
{
"message": "Error in text translation for api",
"error": "Detailed server error message",
"data": null,
"statusCode": 500
}