Auto-generated C# SDK for DeepL — translation, text rephrasing (Write API), document translation, multilingual glossaries, style rules, voice API, and account management. OpenAPI spec from the official DeepLcom/openapi repo.
dotnet build DeepL.slnx
dotnet test src/tests/IntegrationTests/Bearer token auth (converted to DeepL-Auth-Key scheme via Authorized hook):
var client = new DeepLClient(apiKey); // DEEPL_API_KEY env varsrc/libs/DeepL/openapi.yaml— OpenAPI spec (downloaded from DeepLcom/openapi)src/libs/DeepL/generate.sh— Downloads spec, fixes allOf string types, runs autosdk with--security-schemesrc/libs/DeepL/Generated/— Never edit — auto-generated codesrc/libs/DeepL/Extensions/DeepLClient.Auth.cs—Authorizedhook:Bearer → DeepL-Auth-Keysrc/tests/IntegrationTests/Tests.cs— Test helper with bearer authsrc/tests/IntegrationTests/Examples/— Example tests (also generate docs)
The generate.sh applies fixes via yq and --security-scheme:
CLI flags:
--security-scheme Http:Header:Bearer— Overrides spec'sapiKeyauth with standard HTTP bearer
Pre-generation (yq):
- allOf string flattening: Flattens
allOf-wrapping-string schemas (CommaSeparatedList, TagList types) to avoid C# reserved keywordstringas property name
DeepL uses Authorization: DeepL-Auth-Key <key> (not Bearer). The Authorized hook in Extensions/DeepLClient.Auth.cs modifies the shared Authorizations list:
partial void Authorized(Authorization authorization)
{
if (authorization.Type == "Bearer" && authorization.Value is { } apiKey)
{
authorization.Type = "DeepL-Auth-Key";
authorization.Value = apiKey;
}
}Note:
--security-scheme ApiKey:Header:<name>cannot express DeepL's auth because it uses a custom scheme name in theAuthorizationheader (not a separate custom header).
DeepL API has tagged operations generating sub-clients:
client.TranslateText.TranslateTextAsync(...)— Text translationclient.RephraseText.RephraseTextAsync(...)— Write API (rephrasing)client.TranslateDocuments.TranslateDocumentAsync(...)— Document translationclient.MetaInformation.GetUsageAsync()— Account usageclient.MetaInformation.GetLanguagesAsync()— Supported languagesclient.ManageMultilingualGlossaries.*— Glossary management (v3)client.StyleRules.*— Style rule management (v3)client.VoiceAPI.*— Voice streaming (v3)client.AdminApi.*— Developer key management
The Voice API provides real-time speech translation via WebSocket:
- REST endpoint (
GetVoiceStreamingUrlAsync) returns an ephemeralwss://URL + token - Client connects to WebSocket and streams audio bytes
- Server returns transcription + multi-language translations in real-time
Not ISpeechToTextClient compatible — the bi-directional WebSocket streaming pattern doesn't map to MEAI's single-request transcription model. Use the SDK's native client.VoiceAPI.GetVoiceStreamingUrlAsync() + a WebSocket client.
Three-step async pattern:
- Upload:
client.TranslateDocuments.TranslateDocumentAsync(targetLang, fileBytes, filename)→ returnsDocumentId+DocumentKey - Poll:
client.TranslateDocuments.GetDocumentStatusAsync(docId, docKey)→ checkStatus(Queued → Translating → Done) - Download:
client.TranslateDocuments.DownloadDocumentAsync(docId, docKey)→ returnsbyte[](one-time download)