Roam Moon Cloud

AI services

Integrate AI translation

Send text and get back a translation between any two of 100 supported languages, priced by how much text you send.

Request

Send a JSON body:

FieldMeaning
texttext is required. Up to 10,000 characters (the console tester caps its own input tighter, at 1,000).
sourceLanguagesourceLanguage is optional, one of the 100 supported codes below. When omitted, it defaults to "en" rather than being detected.
targetLanguagetargetLanguage is required, one of the 100 supported codes below.

Examples

curl -X POST https://core.roammoon.com/v1/ai/translation/translate \
  -H "X-API-Key: rm_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello, world!", "sourceLanguage": "en", "targetLanguage": "vi"}'

Response

Returns the translated text along with what was actually charged:

JSON
{
  "translatedText": "Xin chào, thế giới!",
  "sourceLanguage": "en",
  "targetLanguage": "vi",
  "characterCount": 13,
  "creditsCharged": 1
}

Fields that matter

FieldMeaning
translatedTextThe translated text.
characterCountLength of the input text you sent.
creditsChargedWhat this call actually cost: ceil(characterCount / 100), minimum 1.

Billing

Unlike the platform's other AI services, this one is priced by size rather than a flat rate per call: 1 credit per 100 characters of input text, rounded up, minimum 1 credit. A 10,000-character request costs at most 100 credits. Credits are charged only when the translation succeeds; every failure is refunded.

The charge policy is charge-on-success: credit is reserved when the request is accepted and only committed once processing succeeds. A failure refunds the reservation.

Supported languages

Both sourceLanguage and targetLanguage accept any of these 100 codes.

LanguageCodeLanguageCode
AfrikaansafGandalg
AmharicamLingalaln
ArabicarLaolo
AsturianastLithuanianlt
AzerbaijaniazLatvianlv
BashkirbaMalagasymg
BelarusianbeMacedonianmk
BulgarianbgMalayalamml
BengalibnMongolianmn
BretonbrMarathimr
BosnianbsMalayms
CatalancaBurmesemy
CebuanocebNepaline
CzechcsDutchnl
WelshcyNorwegianno
DanishdaNorthern Sothons
GermandeOccitanoc
GreekelOriyaor
EnglishenPunjabipa
SpanishesPolishpl
EstonianetPashtops
PersianfaPortuguesept
FulahffRomanianro
FinnishfiRussianru
FrenchfrSindhisd
Western FrisianfySinhalasi
IrishgaSlovaksk
Scottish GaelicgdSloveniansl
GalicianglSomaliso
GujaratiguAlbaniansq
HausahaSerbiansr
HebrewheSwatiss
HindihiSundanesesu
CroatianhrSwedishsv
Haitian CreolehtSwahilisw
HungarianhuTamilta
ArmenianhyThaith
IndonesianidTagalogtl
IgboigTswanatn
IlokoiloTurkishtr
IcelandicisUkrainianuk
ItalianitUrduur
JapanesejaUzbekuz
JavanesejvVietnamesevi
GeorgiankaWolofwo
KazakhkkXhosaxh
KhmerkmYiddishyi
KannadaknYorubayo
KoreankoChinesezh
LuxembourgishlbZuluzu

Getting good results

  • Set sourceLanguage explicitly whenever your text isn't English. Leaving it out does not detect the language, it assumes English.
  • Shorter, well-formed sentences translate more reliably than long runs of text with mixed languages, slang, or heavy formatting.
  • This is machine translation, not a human review. For anything published, legal, or safety-critical, have a fluent speaker check the result before it goes out.

Errors

Every error uses the same shape. Branch on code, not on message, because messages can change.

JSON
{
  "error": {
    "code": "TEXT_TOO_LONG",
    "message": "The \"text\" field must be 10000 characters or fewer."
  }
}
HTTPCodeWhat to do
401API_KEY_REQUIREDThe X-API-Key header is missing.
401API_KEY_INVALIDThe key is wrong, disabled or expired. Check it or create a new one.
403API_KEY_FORBIDDENThe key is not permitted to use this service.
400INVALID_TRANSLATION_REQUESTThe "text" field is missing or empty. No credit is charged.
400TEXT_TOO_LONGThe text exceeds 10,000 characters. Shorten it or split it into multiple calls.
400UNSUPPORTED_LANGUAGEsourceLanguage or targetLanguage is not one of the supported codes.
402CREDIT_LIMIT_EXCEEDEDThe period's credits are exhausted. Upgrade or wait for the next period.
415JSON_BODY_REQUIREDContent-Type must be application/json.
429RATE_LIMIT_EXCEEDEDPer-minute request limit exceeded. Slow down.
502TRANSLATION_UPSTREAM_ERRORThe translation model could not complete the request. Retryable.

Retrying safely

502 is retryable, so use exponential backoff. Other errors return the same result on retry. Only a successful translation is charged, so retrying after a failure costs nothing extra. The exception is a network timeout: if the first attempt actually succeeded, the retry is charged as a second call.