translate_document
Translate a document using the specified translation algorithm.The document content to translate. Obtain this using
load_document().Translation configuration including source/target languages, model settings, and algorithm.
Model interface to use for translation. Create using
create_translator().Optional Rich progress bar instance for tracking translation progress.
Optional checkpoint manager for saving/resuming translation state.
Optional glossary manager for maintaining consistent term translations.
The translated text.
Total number of tokens used during translation.
Total cost in USD.
Time taken in seconds.
List of page numbers that failed to translate (page-by-page algorithm only).
Mapping from page number to error message for failed pages.
Non-fatal warnings during translation.
load_document
Load a document and prepare it for translation.Path to the document to load. Supported formats:
.pdf, .docx, .txt.Optional settings passed to the document processor. For PDFs, you can specify
{"dpi": 300} to control image resolution.Individual pages ready for translation. Text files contain strings, while image-based content (like scanned PDFs) contains bytes.
MIME type of the content. Either
"text/plain" for text content or "image/png" for image content.Document metadata including file type, total pages, title, author, and creation/modification dates.
estimate_cost
Estimate the cost and time required to translate a document.Path to the document to estimate. Used to calculate approximate token count.
Model provider to use for cost calculation. Options:
ModelType.OPENAI, ModelType.ANTHROPIC, ModelType.GEMINI, ModelType.OLLAMA.Translation algorithm. Options:
"page", "sliding-window", "context-aware". Context-aware uses more input tokens due to context overhead.Optional maximum cost threshold in USD. If provided, warnings are generated if the estimate exceeds this value.
Whether glossary is enabled. Glossary adds approximately 20% token overhead.
Model reasoning effort level. Options:
"minimal", "low", "medium", "high". Higher levels significantly increase cost and time.Total estimated tokens (input + output).
Estimated cost in USD.
Estimated time in seconds.
Cost classification:
"low" (< 1-5-20).List of warning messages about document size, cost thresholds, algorithm overhead, or reasoning effort.
create_translator
Create a translator instance for performing translations.Translation configuration. The model provider is determined from
config.model.Configured translator instance implementing the
ModelInterface protocol. Currently returns a LiteLLMTranslator instance that supports all model providers.Model selection (provider and model name) is handled per-request via
TranslationRequest.model and TranslationRequest.model_params, not at translator construction time. This allows using the same translator instance with different models.