BYO Lite is in beta and enabled per organization. Details can change before general availability.
Prerequisites
- BYO Lite is enabled for your organization. It is in beta, so to have it enabled, contact your account manager or Phrase support.
- An engine with its own HTTP API, and its URL and credentials, such as an API key.
- For a custom template, a JSON template that you wrote, or one you adapted from the pre-built template.
Quickstart
To connect an OpenAI-compatible service with the pre-built template:- In the engine settings, set Engine API to Pre-built template and select OpenAI-compatible.
- Under Credentials, enter the Base engine URL, for example
https://api.openai.com/v1. Include the API version of your service, see Base engine URL by service. - Set Authentication method to HTTP header. Enter the Header name, usually
Authorization, and the Header value, for exampleBearer <your API key>. Phrase sends the value exactly as you enter it, so include any prefix such asBearer. - Optionally add metadata under Custom labels, for example the key
model, see Metadata in a template. - Select Validate connection, then Save. Validation uses the settings as they are in the form, so you can run it before you save. See Engine validation test for the checks it runs.
Ways to connect
In the engine settings, Engine API offers three options. The two template options are marked Lite.
Phrase validates the template before the engine is saved.
What works like the full adapter
BYO Lite uses the same engine settings and the same behavior on Phrase’s side as the full adapter. Read these sections of the BYO Engine guide:- Authentication: the OAuth 2.0 client credentials option and the token request. For an HTTP header, you enter the header name and value yourself, see the Quickstart.
- Retries and timeouts: which status codes are retried, and the time limits for each call.
- Segment counts: how many segments Phrase sends in one call. Use
maxSegmentsif your engine accepts fewer. - Dynamic metadata: the placeholders you can use in metadata values.
Template structure
A template is a single JSON file of up to 8 KB. Keys that are not listed here are rejected. A template needs only three blocks:
Each
request and response value is a JSONata expression. A request expression builds the request body of your engine from the variables Phrase provides. A response expression reads the translated text out of the engine’s response. For translate, it must return one translated string per segment, in the same order. Wrap a single value in [...] so that one segment still produces a list. See How Phrase reads the responses for what every expression must return.
maxSegments is the highest number of segments your engine accepts in one call. If Phrase has more, it splits them into several calls and joins the results in the original order, so the template only ever describes one call. The 500 segments of the engine validation test are split the same way.
You can try an expression before you save the template. Paste a sample response of your engine into the JSONata exerciser and run your response expression against it. The exerciser doesn’t know the Phrase variables, such as $segments, or the functions $langOut, $langIn and $fromJson, so replace them with sample values there. An expression that runs longer than 2 seconds fails.
Every path in a template (translate, status, languages and the asynchronous blocks) is added to the Base engine URL you enter in the engine settings. With the base URL https://api.example.com and the path /v1/translate, Phrase calls https://api.example.com/v1/translate. If the base URL already ends with a path, such as https://gateway.example.com/openai, the template path is added after it. Repeated slashes are merged, so it doesn’t matter whether either side has a slash at the junction.
The following example shows every block:
- In
translateAsyncStatusandtranslateAsyncResult,{jobId}in the path is replaced with the job ID returned bytranslateAsync. ThedoneWhenandfailedWhenexpressions are evaluated against the status response. While neither matches, Phrase keeps polling.detailis evaluated only whenfailedWhenmatches, and becomes the failure message. headersaccepts up to 10 headers with values of up to 256 characters.Authorization,Host,Content-Type,Content-Length,CookieandX-Phrase-Action-Idcan’t be set, because Phrase manages them.- The
$evaland$errorfunctions are not allowed.
Block reference
These are the fields of the blocks other thantranslate. Every method is GET or POST. The status and languages calls have no request, so a POST sends an empty JSON object and a GET sends no body.
status
path,method(required): the health check call.okWhen(required): a JSONata expression evaluated against the engine’s response. The engine counts as healthy when it is true.
languages
mode(required):staticorendpoint, see Supported languages in a template.path,method,response(required inendpointmode): the call to your engine, and the expression that reads the languages from its response.
error
message(required): a JSONata expression that reads the error message from the engine’s error response.code(optional): a JSONata expression that reads an error code.
translateAsync
request,response(required): submits the job.requestis built like the one intranslate, andresponsereturns the job ID.path,method(optional): default to/translateAsyncandPOST.
translateAsyncStatus
doneWhen(required): a JSONata expression that is true when the job has finished.failedWhen(optional): a JSONata expression that is true when the job has failed. Without it, Phrase keeps polling until the asynchronous time limit runs out.detail(optional): reads the failure message, only whenfailedWhenmatches.path,method,request(optional): default to/translateAsyncStatus/{jobId}andGET, with no body.
translateAsyncResult
response(required): reads the translated strings, liketranslate.response.path,method,request(optional): default to/translateAsyncResult/{jobId}andGET, with no body.
How Phrase reads the responses
Everyresponse, doneWhen, failedWhen, detail, okWhen and error expression is evaluated against the JSON body that your engine returned. These expressions have no Phrase variables, so they can’t use $segments, $source or $meta, but the functions $langOut, $langIn and $fromJson are available. Each one has to return a specific shape:
Write
okWhen, doneWhen and failedWhen as comparisons, such as status = 'ok' or $exists(character_limit). A bare field such as status returns text, which doesn’t count as true, so the engine would always be reported as unhealthy.
Examples. An engine that answers a translation request with this body:
"response": "translations.text[]", which returns ["Hallo", "Welt"]. A language model answers with the translations as text inside its reply, so a template parses it with $fromJson:
failedWhen is true, and checks doneWhen before failedWhen. Without failedWhen, it keeps polling until the time limit in Retries and timeouts runs out. The block example above shows all three asynchronous blocks.
Single values and lists. JSONata returns a bare value, not a list, when a path matches exactly once. For translations.text, the same expression gives different results depending on how many segments the call carried:
Phrase turns a single string back into a list for
translate.response, translateAsyncResult.response and for the codes of languages.response with crossProduct, so both forms work there. It does not do this for language pairs. If your engine could return exactly one language, end the expression with []:
$segments.text is a bare string and not a list. If your engine expects a list, write [$segments.text].
Supported languages in a template
Thelanguages block has two modes.
static lists the languages in the template. Use either pairs, a list of { "sourceLanguage", "targetLanguage" } objects, or codes, a flat list of language codes. Phrase combines the codes into all pairs, leaving out same-to-same pairs. You can also add codesFrom, a JSONata expression evaluated against the metadata. When it returns at least one valid language code, or a comma-separated string of codes, those codes replace pairs or codes. This lets you restrict the languages per engine without editing the template.
pairs when your engine doesn’t support every combination, for example when it translates only from English, or only into some languages. Phrase offers exactly the pairs you list, in that direction only:
endpoint asks your engine. Phrase calls path with method, and response turns the answer into a list of { "sourceLanguage", "targetLanguage" } pairs. If your engine returns only a flat list of codes, set crossProduct to true and let response return that list. Phrase then builds the pairs itself.
Use Phrase locale codes in pairs, codes and codesFrom, for example pt-br. If your engine uses other codes, add them to languageMap, see Mapping language codes.
Mapping language codes
Phrase gives your template locale codes such aspt-br or zh-hans, in $source and $target. If your engine uses different codes, you don’t need to convert them in the request expression. Add a top-level languageMap that maps Phrase codes to your engine’s codes, and call $langOut in the request:
- The keys are Phrase locale codes, and the values are your engine’s codes, sent exactly as written. Keys are matched without regard to case.
$langOut(code)converts a Phrase code to an engine code. Several Phrase codes can share one engine code, for examplezh-cnandzh-sgcan both map tozh.- A code that is not in the map is converted to upper case, so
jabecomesJA. If your engine expects lower-case codes, or the same code as Phrase, list every code you offer in the map, for example"ja": "ja". $langIn(code)converts an engine code back to a Phrase code. A code that is not in the map is converted to lower case. When several Phrase codes share one engine code,$langInreturns only one of them.- Both functions are available in every expression of the template.
$lowercase($target) for lower-case codes, or $split($target, '-')[0] for the base language without the region. A language model doesn’t need a map at all, because a prompt can use $sourceName and $targetName, which is why the pre-built template has none.
With mode set to endpoint, the codes in your engine’s answer are not converted automatically. Call $langIn in the response expression, as in this example for an engine that returns { "language": "PT-BR" } entries:
Variables
These variables are available inrequest expressions:
response, doneWhen, failedWhen, detail, okWhen and error expressions are evaluated against the engine’s response body and have no other variables.
On top of the standard JSONata functions, these functions are available: $langOut and $langIn for language codes, and $fromJson(text), which parses JSON out of a text. $fromJson is meant for language models, which often wrap their answer in a markdown code block or add a sentence before it. If the text is not pure JSON, it uses the last JSON object it finds.
Glossary. For each request, Phrase searches the term bases attached to the job and puts the entries that match the segments of that request into $glossary, without duplicates. If your engine supports glossaries, map them in the request. For a language model, list them in the prompt:
Metadata in a template
Metadata is a set of custom key/value pairs that you add to the engine. In the Phrase UI they are called Custom labels, and in the OpenAPI schema they are themetadata object. A template reads them from $meta, for example $meta.model. The placeholders from Dynamic metadata are resolved before the template runs. Values you enter as Custom labels are text, so convert them in the template when you need a number. A key that is not set has no value, so check it before you use it.
The pre-built template reads these keys:
Custom instructions. Set
custom_instructions to add your own rules to every translation, such as tone of voice, terminology or style. The text is added to the prompt after the built-in translation rules. It applies to every request of the engine, so use a separate engine for rules that differ between projects. The placeholders from Dynamic metadata work here too, but they insert only an ID, not project-specific text. There is no fixed length limit. The text is sent with every request, so it counts against the context size and cost of your model, and you should keep it short.
model to the name of any model your endpoint offers. Without it, the pre-built template uses gpt-4.1-mini. The template sends temperature 0 by default. It leaves it out for model names that contain claude, because those models reject it. A temperature you set always wins.
Languages. Set languages to a comma-separated list of Phrase locale codes, such as en,de,fr, to limit the languages the engine offers. Phrase combines them into all pairs. Without it, the pre-built template offers its built-in list of languages. At most 100 codes are used, and unknown codes are ignored.
Pre-built template
The pre-built template connects to OpenAI and to other services that implement the OpenAI chat completions API. Set the Base engine URL to the base URL of the service, including its API version, for examplehttps://api.openai.com/v1. The template:
- calls
POST /chat/completionswith up to 50 segments per request, and checks health withGET /models. Both paths are added to the base engine URL; - asks the model to translate the segments, to keep inline tags and to return JSON, and adds your glossary and
custom_instructions; - reads the translations from the first answer of the model, even when it is wrapped in a markdown code block;
- reads the error message from the
errorobject of the response; - sends a static
anthropic-versionheader (2023-06-01). If your service doesn’t need it, remove theheadersblock from your copy of the template.
openai-compatible template
Download the template that Phrase uses for OpenAI-compatible engines.
Base engine URL by service
If you set up the pre-built template before November 5, 2026 with a base URL that has no API version, such as
https://api.openai.com, add the version to the Base engine URL, for example https://api.openai.com/v1. Without it, calls to /chat/completions and /models fail with a 404 error.
These are the addresses the services document at the time of writing, so check your provider’s documentation if a call fails. A few services need more than the base URL:
- Every service except OpenAI needs the
modelcustom label set to one of its model names. Without it, the template usesgpt-4.1-mini, which only OpenAI offers. - Azure OpenAI expects the key in an
api-keyheader. Set Header name toapi-keyand Header value to the key alone, withoutBearer. - Some services, such as Perplexity, use paths other than
/chat/completionsor have no/modelslist. Check the API reference of your service. If the paths differ, use a Custom template with its owntranslate.path. - A service that doesn’t list models at
/modelsfails the status check of the validation. Use a Custom template with a differentstatus.path, or without astatusblock.
Troubleshooting
Next steps
- Read the BYO Engine guide if you need the full adapter.
- Look up the expression syntax in the JSONata documentation.
- Start from the pre-built template and adapt it.