Skip to main content
Machine Translation Contextual question answering Summarisation

Request format

1. Request body​

{

"messages": [ ... ],

"max_tokens": 1024,

"temperature": 0.0

}

messages must follow one of six fixed prompt templates. Only the substituted variables may change; altering the wording, order or system prompt is unsupported and may degrade output.

2. Prompt templates​

TaskSystem promptUser turn content
TranslationYou are a translator.\{text\}\n\nTranslate the given text from \{src_lang\} to \{trg_lang\}.
Translation with glossaryYou are a translator.\{text\}\n\nTranslate the given text from \{src_lang\} to \{trg_lang\}, using this glossary \{terms_json\}.
Translation with examplesYou are a translator.Each example as a prior user/assistant pair in the plain translation format, followed by the request turn in the plain format
Translation with glossary and examplesYou are a translator.Examples in the plain format, final request turn in the glossary format
Contextual question answeringYou are answering questions.\{context\}\n\n\{question\}
SummarisationYou are answering questions.\{context\}\n\n\{instruction\}

Complete request samples for every template are in Appendix A.

3. Variable rules​

  • {src_lang}, {trg_lang}: English language names, e.g. English, Latvian, German.

  • {terms_json}: JSON object mapping each source term to a list of allowed target terms, e.g. {"pie": ["kūka"], "like": ["patīk"]}, serialised without ASCII escaping (json.dumps(terms, ensure_ascii=False)).

  • {text} and {context}: UTF-8 text; newlines allowed.

  • {question} and {instruction}: a single line, no newline characters.

  • The separator between the payload and the instruction is exactly two newline characters (\n\n).

  • Total request (all messages plus max_tokens) must fit within the 65,536-token context window.

4. Generation parameters​

  • max_tokens: set to the expected output length; output is truncated with finish_reason: "length" if reached.
  • temperature: 0.0 recommended for translation and question answering.

5. Batch Transform​

One request object per line in a .jsonl file. To associate each output line with its input, set DataProcessing.JoinSource to Input in the transform job; the input record is then prepended to the corresponding output record.

{"messages":[{"role":"system","content":"You are a translator."},{"role":"user","content":"I like pies.\n\nTranslate the given text from English to Latvian."}],"max_tokens":256}

{"messages":[{"role":"system","content":"You are answering questions."},{"role":"user","content":"I like pies.\n\nDo I like pies?"}],"max_tokens":128}