- getting an API key
- using client libraries
- language codes and regional variants
- where to send your request
- choosing a
model_type - limits
Getting an API key
If you haven’t already signed up for a DeepL API account, you’ll need to do so. Visit our plans page, choose a plan, and sign up. When you send a request to our API, you use your API key to identify yourself. You can find that API key here. And now you’re ready to make your first API request!Finding your client library
Like many APIs, the DeepL API uses HTTP requests and responses to receive and send data. While you can construct your own HTTP requests, most people find it easier to let their favorite programming language generate requests and handle the responses. To this end, DeepL provides official client libraries for six popular languages: The DeepL community has contributed client libraries for other programming languages, including Dart, Go, and Rust. The documentation on this site frequently includes code samples in these languages. For more about how to use the DeepL API in your favorite language, try the links above.Making a translation request
Source and target languages
The source language is the language you’re translating from. The target language is the language you’re translating to. Any DeepL API translation request must include these two parameters:text: some text to translatetarget_lang: the target language
source_lang parameter. If your text is very short, contains a mix of languages, or if you want to specify the source language for any other reason, you can include source_lang.
A sample translation request
For example, if you wanted to translate the phrase “Hello, bright universe!” to Japanese:- “Hello, bright universe!” is the
text - Japanese is the
target_lang - the source language is English, so you could include this as the
source_lang, but you don’t need to.
- HTTP Request
- cURL
- Python
- JavaScript
- PHP
- C#
- Java
- Ruby
Sample request
Sample response
Sending multiple text strings
If you look at the HTTP request above, you’ll notice that the translation text is in square brackets - in an array. In fact, a translation request can include multiple text strings:- HTTP Request
- cURL
- Python
- JavaScript
- PHP
- C#
- Java
- Ruby
Sample request
Sample response
- HTTP Request
- cURL
- Python
- JavaScript
- PHP
- C#
- Java
- Ruby
Sample request
Sample response
Language codes and variants
The DeepL API can translate in any of these supported languages. Normally, any supported source language can be used as a target language, and vice versa. But it’s best to check the list to make sure. To specify a language, use its ISO-639 language code, such asFR for French or VI for Vietnamese. While most language codes have two letters, a few have three. For example, the code for Cantonese is YUE.
For certain target languages, DeepL supports a set of regional variants, which are listed among the supported languages. For example, en-GB indicates British English, and en-US indicates English spoken in the United States. To specify a variant, append to the language code a hyphen, then the ISO-3166 country code. So, for Brazilian Portuguese, use pt-BR.
In the DeepL API, language codes are case-insensitive. It accepts language codes in uppercase or lowercase, or a mix of the two. So, for Brazilian Portuguese you could use pt-BR, pt-br, PT-BR, or even pT-Br.
Regional variants can only be used in target languages. If you try a source language with a variant like ZH-HANS, the API will return an error.
If DeepL supports variants of a given language, you are encouraged to choose one. If you don’t include the variant in a raw HTTP request, DeepL will translate into the variant which has been designated as the default. If you’re using a client library, the API will throw an error.
Although you can ask the API to translate from one language variant to another, the methods described in our How To Translate Between Language Variants guide yield better results.
Where to send your request
The URL you send requests to depends on your API plan. If you are using a free plan, you’ll usehttps://api-free.deepl.com. For a paid plan, use https://api.deepl.com.
If you’re using a client library, you don’t need to worry about this, as DeepL’s client libraries detect your account type and send requests to the correct URL.
You may also wish to send requests to an API endpoint corresponding to a specific geographic region, for data residency or compliance needs, or to minimize latency. For more information, instructions on how to set this up, and code samples featuring the server_url parameter, see Regional API Endpoints.
Model type
DeepL hosts many AI models for language translation. As AI is evolving rapidly, we are constantly working on our models and deploying new ones. It would be difficult for users to determine which model to choose for a particular language pair, text, and parameters. Rather than requiring users to select a specific model for a given translation, DeepL follows a simpler approach:- The translator app offers a choice between “classic” and “next-gen” models. “Classic” models often maximize speed, and “next-gen” models generally maximize quality.
- The DeepL API offers the
model_typeparameter, which lets you choose whether you would prefer a model that maximizes translation quality or a model that runs as quickly as possible. The API will then make its best effort to execute your translation with such a model, and its response will tell you what sort of model we used.
model_type parameter can have one of three values:
latency_optimized: aims to maximize speedquality_optimized: aims to maximize qualityprefer_quality_optimized: a legacy value, whose behavior is currently identical toquality_optimized
model_type, the API normally defaults to latency_optimized.
Special cases
- If your request omits the
source_lang, the API will use next-generation models to ensure the best possible language detection. - tag handling v2 uses next-generation models. It is compatible with all
model_typevalues. - For some languages, like Thai, the API uses the same model, regardless of requested
model_type. This behavior may change as our models evolve.
Limits
The total request body size for text translation requests is limited to 128K. As a request consists of multiple elements along with your text, this means your text can’t hit 128K exactly, but has to be a little smaller. If you need to send larger strings, you can place them in documents, which have a limit of 10 MB. If that’s not high enough, get in touch with us. For more, see Usage and Limits.Summary and next steps
Congratulations! Now you know how to send the DeepL API a translation request including any of these parameters:
Here are some possible next steps:
- Play with translation requests using these parameters and other options in our playground or Postman.
- For complete information on the
/translateendpoint, see the/translatereference - See this introduction to DeepL glossaries
- To learn how to translate text in files - PDFs, presentations, powerpoints, HTML, images, and more - see the
/documentreference - To translate audio, see the
/voicereference