Ana içeriğe geç

Metin Çeviri API'si

GPT Translator API'si ile metin çevirin.

Uç nokta​

POST https://api.gpttranslator.co/v1/translation/text-translation/api

Kimlik doğrulama​

API anahtarınızı istek başlıklarına ekleyin:

x-api-key: YOUR_API_KEY
Content-Type: application/json

İstek gövdesi​

Zorunlu alanlar:

  • text string: Çevrilecek kaynak metin
  • sourceLang string: Kaynak dil kodu
  • targetLang string: Hedef dil kodu
  • model string: Çeviri modelinin adı

İsteğe bağlı alanlar:

  • domain string: Alan uzmanlığı
  • writingStyle string: Yazım stili tercihi
  • tone string: Ton tercihi
  • customPrompt string: Özel çeviri talimatları

Dil kodları ayrıca Desteklenen Diller sayfasında belgelenmiştir. Desteklenen modeller Desteklenen Modeller sayfasında belgelenmiştir.

Doğrulama kuralları​

  • text: Zorunlu. Boş olamaz.
  • sourceLang, targetLang: ^[a-zA-Z]+(-[a-zA-Z]+)?$ ile eşleşmelidir, en az 2, en fazla 11 karakter. Desteklenen Diller içindeki bir kod olmalıdır.
  • model: Desteklenen Modeller içindeki değerlerden biri olmalıdır.

Örnekler​

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())

Yanıt türleri​

Başarılı 200​

{
"message": "Text translation completed successfully",
"error": null,
"data": {
"translatedText": "bonjour le monde",
"originalText": "hello world",
"totalWords": 2,
"isRTL": false,
"tokensConsumed": 3
},
"statusCode": 200
}

İstek doğrulama hatası 400​

Doğrulama middleware hataları şu biçimde döndürülür:

{
"error": "Invalid source language. Please select a supported language."
}

Diğer olası doğrulama hataları:

  • 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 anahtarı eksik/geçersiz başlık 401​

{
"message": "Invalid api key",
"error": "Invalid api key",
"statusCode": 401,
"data": null
}

API anahtarı veya kullanıcı yapılandırma hataları 400​

Veritabanında geçersiz anahtar:

{
"message": "Invalid api key",
"error": "Invalid api key",
"statusCode": 400,
"data": null
}

Kullanıcı aktif değil:

{
"message": "User not found or user is not active",
"error": "User not found or user is not active",
"statusCode": 400,
"data": null
}

Kuruluş eksik:

{
"message": "Organization Id not found for the user",
"error": "Organization Id not found for the user",
"statusCode": 400,
"data": null
}

Plan kısıtlaması 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
}

Token sınırına ulaşıldı 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
}

İşleme/sunucu hatası 500​

{
"message": "Error in text translation for api",
"error": "Detailed server error message",
"data": null,
"statusCode": 500
}