Skip to main content

🌍 AI แปลภาษาหลายภาษา

1 ICต่อ 400 ตัวอักษร
v1.0 Active POST /v3/store/nlp/multilingual-translation

การแปลที่รวดเร็วและแม่นยำระหว่าง 28 ภาษา ปรับให้เหมาะสมสำหรับ ข้อความยาว และ ประสิทธิภาพสูง รองรับทั้งการแปล แบบครั้งเดียวและแบบกลุ่ม

ลองใช้ Demo

🚀 คุณสมบัติ

  • 28 ภาษา: ar, bn, cs, de, en, es, fa, fr, he, hi, id, it, ja, km, ko, lo, ms, my, nl, pl, pt, ru, th, tl, tr, ur, vi, zh

  • Endpoint สำหรับการแปลแบบครั้งเดียวและแบบกลุ่ม

  • รองรับข้อความไม่จำกัด – แบ่งข้อความเป็นประโยคโดยอัตโนมัติ

  • ความแม่นยำสูง – ประเมินด้วย BERTScore บนชุดข้อมูลจริง

📈 เกณฑ์มาตรฐานประสิทธิภาพ (ไทย → อังกฤษ)

ทดสอบกับคู่ประโยค 133,330 คู่จาก ชุดข้อมูล SCB MT En-TH 2020

โหมดเวลาเฉลี่ย / 100 ประโยค
🧠 กลุ่ม18.06 วินาที
🐌 ครั้งเดียว30.54 วินาที

💡 เคล็ดลับ: ใช้ API แบบกลุ่มเพื่อประสิทธิภาพที่ดีที่สุด

🧪 คุณภาพ (BERTScore)

คะแนนความคล้ายคลึงทางความหมายระหว่างการคาดการณ์และการอ้างอิง (1.0 = ตรงกันสมบูรณ์)

ต้นทาง → ปลายทางBERTScore เฉลี่ย
EN → MY0.9561
EN → TH0.9506
EN → JA0.9169
JA → EN0.9146
TH → EN0.8728
TH → MY0.8571
ZH → EN0.8571

✅ คู่ที่ทดสอบทั้งหมดได้คะแนน > 0.80

API Endpoints

🔹 การแปลแบบครั้งเดียว

POST /v1/text/translate Content-Type: application/x-www-form-urlencoded

Params:

  • text: ข้อความที่ต้องการแปล
  • source_lang: รหัสภาษาต้นทาง (เช่น en)
  • target_lang: รหัสภาษาปลายทาง (เช่น th)
  • max_length: (ไม่บังคับ) จำนวนโทเค็นเอาต์พุตสูงสุด

ตัวอย่าง:

curl -X POST "https://api.iapp.co.th/v1/text/translate" \
-H "apikey: YOUR_API_KEY" \
-F "text=Hello" \
-F "source_lang=en" \
-F "target_lang=th"

การตอบกลับ:

{
"translation": "สวัสดี",
"processing_time": 0.056
}

🔹 การแปลแบบกลุ่ม

POST /v1/text/batch_translate Content-Type: application/json

Body:

[
{
"text": "Hello",
"source_lang": "en",
"target_lang": "fr"
},
{
"text": "こんにちは",
"source_lang": "ja",
"target_lang": "en"
}
]

การตอบกลับ:

{
"results": [
{ "translation": "Bonjour", "index": 0 },
{ "translation": "Hello", "index": 1 }
]
}

🐍 ตัวอย่างโค้ด Python

import requests

def translate_text(text, source_lang, target_lang, api_key, api_url="https://api.iapp.co.th"):
"""
แปลข้อความโดยใช้ Translation API

Args:
text (str): ข้อความที่ต้องการแปล
source_lang (str): รหัสภาษาต้นทาง (เช่น 'en', 'th', 'zh')
target_lang (str): รหัสภาษาปลายทาง (เช่น 'en', 'th', 'zh')
api_key (str): API key ของคุณ
api_url (str): URL พื้นฐานของ API

Returns:
dict: การตอบกลับการแปล
"""
data = {
"text": text,
"source_lang": source_lang,
"target_lang": target_lang
}

headers = {
"apikey": api_key
}

response = requests.post(f"{api_url}/v1/text/translate", data=data, headers=headers)
response.raise_for_status() # แสดงข้อผิดพลาด HTTP
return response.json()

# ตัวอย่างการใช้งาน:
# result = translate_text("Hello", "en", "th", api_key="YOUR_API_KEY")
# print(result["translation"])

✅ โค้ดนี้ใช้รูปแบบ application/x-www-form-urlencoded สอดคล้องกับข้อกำหนด API

⚠️ ข้อผิดพลาด

Codeคำอธิบาย
400คำขอไม่ถูกต้อง
401API key หายไปหรือใช้ไม่ได้
429เกินขีดจำกัดอัตราการเรียกใช้
500ข้อผิดพลาดภายในเซิร์ฟเวอร์
503บริการไม่พร้อมใช้งาน

✅ สรุป

  • 🏁 รวดเร็ว & แม่นยำสำหรับ 28 ภาษา
  • 📄 จัดการข้อความยาวโดยอัตโนมัติ
  • 🧪 การแปลคุณภาพสูงที่พิสูจน์แล้ว
  • 📦 ใช้โหมดกลุ่มเพื่อความเร็วที่ดีที่สุด

ตัวอย่างโค้ด

Curl

curl -X POST https://api.iapp.co.th/v3/store/nlp/translation/multilingual \
-H "apikey: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Your text here", "source_lang": "th", "target_lang": "en"}'

Python

import requests
import json

url = "https://api.iapp.co.th/v3/store/nlp/translation/multilingual"
headers = {
"apikey": "YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {"text": "Your text here", "source_lang": "th", "target_lang": "en"}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())

JavaScript

const axios = require("axios");

const config = {
method: "post",
url: "https://api.iapp.co.th/v3/store/nlp/translation/multilingual",
headers: {
apikey: "YOUR_API_KEY",
"Content-Type": "application/json",
},
data: {"text": "Your text here", "source_lang": "th", "target_lang": "en"},
};

axios(config)
.then((response) => console.log(response.data))
.catch((error) => console.log(error));

PHP

<?php
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.iapp.co.th/v3/store/nlp/translation/multilingual',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => '{"text": "Your text here", "source_lang": "th", "target_lang": "en"}',
CURLOPT_HTTPHEADER => array(
'apikey: YOUR_API_KEY',
'Content-Type: application/json'
),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>

Swift

import Foundation

let url = URL(string: "https://api.iapp.co.th/v3/store/nlp/translation/multilingual")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("YOUR_API_KEY", forHTTPHeaderField: "apikey")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

let jsonData = try! JSONSerialization.data(withJSONObject: {"text": "Your text here", "source_lang": "th", "target_lang": "en"})
request.httpBody = jsonData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8)!)
}
}
task.resume()

Kotlin

import okhttp3.*
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody

val client = OkHttpClient()

val json = """
{"text": "Your text here", "source_lang": "th", "target_lang": "en"}
""".trimIndent()

val requestBody = json.toRequestBody("application/json".toMediaTypeOrNull())

val request = Request.Builder()
.url("https://api.iapp.co.th/v3/store/nlp/translation/multilingual")
.addHeader("apikey", "YOUR_API_KEY")
.post(requestBody)
.build()

client.newCall(request).execute().use { response ->
println(response.body?.string())
}

Java

import okhttp3.*;

OkHttpClient client = new OkHttpClient();

String json = "{"text": "Your text here", "source_lang": "th", "target_lang": "en"}";

RequestBody body = RequestBody.create(
MediaType.parse("application/json"),
json
);

Request request = new Request.Builder()
.url("https://api.iapp.co.th/v3/store/nlp/translation/multilingual")
.addHeader("apikey", "YOUR_API_KEY")
.post(body)
.build();

try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}

Dart

import 'package:http/http.dart' as http;
import 'dart:convert';

var headers = {
'apikey': 'YOUR_API_KEY',
'Content-Type': 'application/json'
};

var data = {"text": "Your text here", "source_lang": "th", "target_lang": "en"};

var response = await http.post(
Uri.parse('https://api.iapp.co.th/v3/store/nlp/translation/multilingual'),
headers: headers,
body: jsonEncode(data)
);

print(response.body);