Map Inline Formatting Endpoint
const url = 'https://example.com/format/map_inline_formatting';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"source_text":"example","target_translation":"example","source_lang":"example","target_lang":"example","spans":[{"id":"example","text":"example","type":"example"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/format/map_inline_formatting \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "source_text": "example", "target_translation": "example", "source_lang": "example", "target_lang": "example", "spans": [ { "id": "example", "text": "example", "type": "example" } ] }'Map inline formatting spans from source text to the corresponding substrings in the target translation.
Given a source text with named formatting spans (bold, italic, underline, etc.) and the target translation, this endpoint returns the exact substrings in the target that should carry the same formatting. A local self-check filters out any mapping where the returned text is not an exact substring of the target_translation, preventing hallucinated positions.
Requires OpenAI API key to be configured.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Full source text
Full translated text
Source language code (e.g. ‘en’)
Target language code (e.g. ‘de’)
Formatting spans to map from source to target
object
UUID of the source formatting span
The formatted text in the source
Formatting type: bold, italic, underline, etc.
Examplegenerated
{ "source_text": "example", "target_translation": "example", "source_lang": "example", "target_lang": "example", "spans": [ { "id": "example", "text": "example", "type": "example" } ]}Responses
Section titled “Responses”Successful Response
object
Successfully mapped formatting spans
object
UUID of the source span this mapping refers to
Exact substring of the target translation to format
Model confidence for this mapping
Spans dropped due to failed self-check or low confidence
Processing time in milliseconds
Whether the mapping call succeeded
Examplegenerated
{ "mappings": [ { "source_id": "example", "target_text": "example", "confidence": 1 } ], "dropped_count": 1, "processing_time_ms": 1, "success": true, "error_message": "example", "usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 1, "quantization": "example", "gpu_mem_allocated_gb": 1, "gpu_mem_reserved_gb": 1 }}Validation Error
object
object
object
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example", "input": "example", "ctx": {} } ]}