Skip to content

Map Inline Formatting Endpoint

POST
/format/map_inline_formatting
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.

Media typeapplication/json
FormattingRequest
object
source_text
required
Source Text

Full source text

string
>= 1 characters
target_translation
required
Target Translation

Full translated text

string
>= 1 characters
source_lang
required
Source Lang

Source language code (e.g. ‘en’)

string
>= 1 characters <= 20 characters
target_lang
required
Target Lang

Target language code (e.g. ‘de’)

string
>= 1 characters <= 20 characters
spans
required
Spans

Formatting spans to map from source to target

Array<object>
>= 1 items
FormattingSpan
object
id
required
Id

UUID of the source formatting span

string
text
required
Text

The formatted text in the source

string
>= 1 characters
type
required
Type

Formatting type: bold, italic, underline, etc.

string
Examplegenerated
{
"source_text": "example",
"target_translation": "example",
"source_lang": "example",
"target_lang": "example",
"spans": [
{
"id": "example",
"text": "example",
"type": "example"
}
]
}

Successful Response

Media typeapplication/json
FormattingResponse
object
mappings
required
Mappings

Successfully mapped formatting spans

Array<object>
FormattingMapping
object
source_id
required
Source Id

UUID of the source span this mapping refers to

string
target_text
required
Target Text

Exact substring of the target translation to format

string
confidence
required
Confidence

Model confidence for this mapping

number
<= 1
dropped_count
required
Dropped Count

Spans dropped due to failed self-check or low confidence

integer
processing_time_ms
required
Processing Time Ms

Processing time in milliseconds

number
success
required
Success

Whether the mapping call succeeded

boolean
error_message
Any of:
string
usage
Any of:
TokenUsage
object
prompt_tokens
Any of:
integer
completion_tokens
Any of:
integer
total_tokens
Any of:
integer
quantization
Any of:
string
gpu_mem_allocated_gb
Any of:
number
gpu_mem_reserved_gb
Any of:
number
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

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Examplegenerated
{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example",
"input": "example",
"ctx": {}
}
]
}