ส่ง text เป็นข้อความเดี่ยวหรืออาร์เรย์ของหลายท่อน การควบคุมระดับภาษา คำทับศัพท์ อภิธานศัพท์ และตัวอย่างสไตล์อยู่ในคู่มือการแปลภาษา
เฮดเดอร์#
authorizationBearer pxa_...จำเป็นAuthorization: Bearer pxa_... (recommended).
x-api-keypxa_...Alternative to the Authorization header. Ignored when Authorization is present.
idempotency-keystringMakes a retry safe: two requests carrying the same key are charged once. One request per key runs at a time. A concurrent duplicate answers 409 idempotency_in_flight. Reuse a key only to retry an identical request. A changed payload is rejected with 422. Accepts up to 200 printable ASCII characters other than space.
เนื้อหา#
textstring or object or array of string or objectsจำเป็นThe text to translate: one string, or an array of up to 200 segments translated together (one request, one charge, shared document context; segment boundaries are preserved in the response). Translated characters cost 25 credits per 1000. Reference characters, meaning instructions, context, examples, do_not_translate strings, and glossary, cost 8 credits per 1000 because the model reads them without translating them. Both are billed per character, summed, and rounded up once to the next hundredth of a credit, minimum 2 credits per request. This field accepts at most 20,000 characters, counted once per requested rendering, because each rendering produces that much Thai. The whole request accepts at most 200,000 billable characters. The response reports the exact split in usage.
modelstringจำเป็นTranslation model id, for example paxa-translation-lite-v1. GET /v1/models lists the served catalog.
sourcestringSource language as an ISO 639-1 code, or "auto" (the default) to detect it per segment. Codes accepted as explicit pins today: en, zh, ja, ko, ar, fr, de, hi, id, ms, pt, ru, es, vi. Auto-detection accepts any input language, including mixed-language text.
target"th"Target language. Thai is the only target served today; the field exists so more targets can arrive without a breaking change.
formality"auto" or "formal" or "casual"Thai register: "formal" produces polite written Thai (polite particles where natural, formal vocabulary), "casual" produces conversational Thai, and "auto" (the default) matches the tone of the source.
borrowed_words"auto" or "transliterate" or "preserve"How to handle borrowed words. "auto", the default, uses the established Thai form where one exists. "transliterate" renders borrowed words in Thai script. "preserve" keeps technical terms and proper nouns in their original script.
format"text" or "markdown" or "html"What the segments are written in. "text" (the default) treats them as prose. "markdown" and "html" translate only the human-readable prose. Link targets, code, tags, and attributes come back untouched. Thai is written without spaces between words. An inline tag moved by one character therefore changes where a word breaks, which is why these modes exist.
alternativesintegerHow many distinct renderings to return per segment, best first. Above 1 the extras arrive in the alternatives array of each result. Each rendering is a full pass over the text. The text rate therefore multiplies by this number, and so does the text ceiling: asking for 5 renderings leaves a 5th of the character allowance for the text itself. Reference material is read once and charged once. At most 5.
do_not_translatearray of stringsStrings that must appear in the translation exactly as written: product names, code identifiers, citations. Applied on top of borrowed_words, which decides everything else.
instructionsstringFree-form direction for the translator, covering tone, register, terminology, house rules, and anything the fixed options cannot express. Applied to every segment. Its characters bill at the reference rate. At most 4,000 characters. Instructions govern style only. They cannot change the response shape. They cannot make the model act on the text it is translating either.
contextstringBackground that conditions the translation without being translated: the surrounding document, the domain, or the intended audience. Its characters bill at the reference rate. At most 100,000 characters.
examplesarray of objectsStyle examples the translation imitates in tone, register, and phrasing. Accepts up to 100 source and target pairs. Both sides of every pair bill at the reference rate.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
examples[].sourcestringจำเป็นA source sentence in the style to follow.
examples[].targetstringจำเป็นIts preferred Thai translation.
glossaryarray of objectsTerminology the translation must use. Accepts up to 5,000 term pairs. The model applies each term contextually, inflecting, casing, and placing it grammatically. Send a whole glossary. Terms whose source does not appear in the text are dropped before the request runs. Dropped terms are neither sent to the model nor billed. Matching ignores case, accents, and typographic apostrophes. It sees through suffixes and German compounds. It needs no word boundaries, and works in Chinese, Japanese, and Thai. Both sides of every surviving pair bill at the reference rate. The response reports how many were sent.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
glossary[].sourcestringจำเป็นThe term as it appears in the source text.
glossary[].targetstringจำเป็นThe Thai rendering to use for it.
glossary[].alwaysbooleanSend this term even when it does not appear in the text. Use it for a term that governs a concept, such as an abbreviation the text spells out. Use it also when inflection changes the stem of the word, as an irregular plural or a Russian case ending does.
glossary_mode"matched" or "all"How to handle the glossary. "matched", the default, sends and bills only the terms whose source appears in the text. "all" sends and bills every term you attach, for callers who would rather pay than reason about matching.
การตอบกลับ#
The translated text.
translationsarray of objectsจำเป็นOne entry per input segment in input order; exactly one entry when text was a single string.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
translations[].idstringThe id you gave this segment, echoed back. Absent when the segment was sent as a bare string.
translations[].textstringจำเป็นThe Thai translation of this segment.
translations[].detected_sourcestringจำเป็นThe detected (or explicitly pinned) source language of this segment as an ISO 639-1 code; "und" when detection is inconclusive.
translations[].alternativesarray of stringsFurther renderings of this segment, best first, when alternatives was above 1. The primary rendering stays in text and is not repeated here.
translations[].reviewobjectPresent only when a delivered translation is worth checking. These are our own checks on the result. They never fail or refuse a request, and the translation is delivered and charged either way. A response whose segments carry no review member passed every check.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
translations[].review.reasonstringจำเป็นWhy this segment is worth a look. `empty`, the model returned nothing. `untranslated`, the output matches the input. `glossary_term_missing`, a term you sent does not appear. `preserved_span_missing`, a do_not_translate string is absent. `too_long`, the result exceeds max_length. `markup_changed`, the markup structure differs.
translations[].review.detailstringThe specific term, span, or measurement behind the reason, when there is one.
usageobjectจำเป็นWhat the request was billed for.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
usage.text_charsintegerจำเป็นCharacters of text, summed across segments.
usage.reference_charsintegerจำเป็นCharacters the model read without translating: instructions, context, examples, do_not_translate strings, and the glossary terms actually sent.
usage.billable_charsintegerจำเป็นtext_chars plus reference_chars.
usage.creditsnumberจำเป็นWhat this delivery cost, in credits, exact to a hundredth. An idempotent replay reports the ORIGINAL request's charge, since that one charge is what paid for this delivery too; your balance moves only once.
usage.glossary_terms_sentintegerจำเป็นGlossary terms that reached the model and were billed for.
usage.glossary_terms_availableintegerจำเป็นGlossary terms attached to the request. The gap between this and glossary_terms_sent is what pruning dropped.