Microsoft.Extensions.AI Integration
Cross-SDK comparison
See the centralized MEAI documentation for feature matrices and comparisons across all tryAGI SDKs.
The DeepL SDK provides AIFunction tool wrappers compatible with Microsoft.Extensions.AI. These tools can be used with any IChatClient to give AI models translation, text improvement, and document translation capabilities.
Installation
1 | |
Translation Tool
Use AsTranslateTool() to create an AIFunction that wraps DeepL text translation. Pass it to any IChatClient via ChatOptions.Tools.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
Rephrase Tool
Use AsRephraseTool() to create an AIFunction that wraps DeepL's Write API for text improvement.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Document Translation Tool
Use AsTranslateDocumentTool() to create an AIFunction that handles the full document translation workflow (upload, poll, download). Supports DOCX, PPTX, XLSX, PDF, HTML, TXT, and more.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Note
The document translation tool accepts base64-encoded file content and returns the translated document as base64. This is best suited for agents that handle file I/O.
Combining All Tools
You can provide all three tools simultaneously, letting the model decide which to use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
Tool Details
| Method | Tool Name | Description |
|---|---|---|
AsTranslateTool() |
TranslateText |
Translates text between 30+ languages with automatic source detection |
AsRephraseTool() |
RephraseText |
Improves text clarity, tone, and style using DeepL Write API |
AsTranslateDocumentTool() |
TranslateDocument |
Translates documents (DOCX, PDF, TXT, etc.) with automatic polling |
AsTranslateTool Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
defaultTargetLanguage |
TargetLanguage |
En |
Default target language when the model doesn't specify one |
formality |
Formality? |
null |
Formality level: Default, Less, More, PreferLess, PreferMore |
AsRephraseTool Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
writingStyle |
WritingStyle? |
null |
Style: Academic, Business, Casual, Simple, or Default |
tone |
WritingTone? |
null |
Tone: Confident, Diplomatic, Enthusiastic, Friendly, or Default |
AsTranslateDocumentTool Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
defaultTargetLanguage |
TargetLanguage |
En |
Default target language when the model doesn't specify one |
formality |
Formality? |
null |
Formality level for the translation |
pollIntervalMs |
int |
1000 |
Polling interval in milliseconds when waiting for translation |
Language Codes
The translation tools accept standard language codes as strings:
| Code | Language | Code | Language |
|---|---|---|---|
DE |
German | FR |
French |
ES |
Spanish | IT |
Italian |
PT-BR |
Portuguese (Brazil) | PT-PT |
Portuguese (Portugal) |
EN-US |
English (US) | EN-GB |
English (UK) |
JA |
Japanese | ZH-HANS |
Chinese (Simplified) |
KO |
Korean | RU |
Russian |
See the DeepL documentation for the full list of 30+ supported languages.