How do I get my DeepL API key and make my first /translate request?
Language Translation AI

How do I get my DeepL API key and make my first /translate request?

9 min read

Most teams reach for the DeepL API when they want to stop copy‑pasting text into a browser and start translating directly from their own tools, websites, or internal systems. To do that, you need two things: a DeepL API key and a working /translate request you can reuse and automate.

This guide walks you step by step through:

  • Getting your DeepL API key
  • Testing your first /translate call
  • Avoiding common errors that derail first integrations

The examples are intentionally simple—so you can confirm everything works before wiring the DeepL API into production workflows.


Step 1: Choose the right DeepL plan for API access

You can’t call the DeepL API without the right subscription. When you sign up, make sure you choose a plan that explicitly mentions API access (for example, a DeepL API or DeepL Pro plan with API).

These plans are designed for:

  • Embedding translation into your product or website via DeepL API
  • Automating document translation from internal tools
  • Connecting DeepL to CAT tools, middleware, or backend services

If you only have basic web translator access without API rights, you won’t see an API key in your account.


Step 2: Get your DeepL API key from the account dashboard

Once your plan with API access is active, you can retrieve your key from the DeepL account portal.

Typical steps:

  1. Sign in to your DeepL account
    Go to https://www.deepl.com and log in with your work email.

  2. Open your account settings
    Navigate to the account area (often surfaced as “Account,” “Subscription,” or your profile name).

  3. Locate the API section
    Look for a section labeled something like:

    • “DeepL API”
    • “API settings”
    • “Authentication key” or “API key”
  4. Copy your API key

    • You’ll see a long string of characters (your authentication key).
    • Copy it and store it in a secure location such as:
      • A secrets manager (e.g., AWS Secrets Manager, HashiCorp Vault)
      • A CI/CD secret
      • An environment variable in your application stack
  5. Treat the key like a password

    • Never commit the key to Git or share it in screenshots.
    • Use environment variables locally (for example, DEEPL_API_KEY) and inject them into your app configuration.

Step 3: Understand the /translate endpoint basics

DeepL’s /translate endpoint is the core of text translation via API. At a minimum, each request needs:

  • An auth key: your API key, usually in the Authorization header
  • One or more text parameters: the content you want to translate
  • A target_lang: the language you want to translate into (e.g., EN, DE, FR)

You can also specify:

  • source_lang: if you don’t want auto‑detect
  • formality: to control tone in supported languages (e.g., more, less)
  • glossary_id: to enforce your terminology when glossaries are available in your plan

DeepL provides endpoints for both free and paid API subscriptions. The host and path can differ between these; always use the base URL given in your account documentation for your specific plan.


Step 4: Make your first /translate request from the command line

Before you touch application code, it’s smart to validate your key and endpoint from the command line. curl is the fastest way to do this.

Replace YOUR_AUTH_KEY and the URL with the values provided in your DeepL account:

curl https://api.deepl.com/v2/translate \
  -H "Authorization: DeepL-Auth-Key YOUR_AUTH_KEY" \
  -d "text=Hello world!" \
  -d "target_lang=DE"

If everything is configured correctly, you should see a JSON response similar to:

{
  "translations": [
    {
      "detected_source_language": "EN",
      "text": "Hallo Welt!"
    }
  ]
}

If you see an error instead, jump down to the Common errors section and match the message.


Step 5: Call /translate from your application (code examples)

Once the curl test works, move your /translate call into your preferred language or environment. Always keep secrets out of your source code—use environment variables.

Example in Python

import os
import requests

DEEPL_API_KEY = os.getenv("DEEPL_API_KEY")
DEEPL_ENDPOINT = "https://api.deepl.com/v2/translate"

def translate_text(text: str, target_lang: str = "DE") -> str:
    if not DEEPL_API_KEY:
        raise RuntimeError("DEEPL_API_KEY is not set")

    headers = {
        "Authorization": f"DeepL-Auth-Key {DEEPL_API_KEY}"
    }

    data = {
        "text": text,
        "target_lang": target_lang
    }

    response = requests.post(DEEPL_ENDPOINT, headers=headers, data=data)
    response.raise_for_status()
    result = response.json()

    return result["translations"][0]["text"]

if __name__ == "__main__":
    original = "How do I get my DeepL API key and make my first /translate request?"
    translated = translate_text(original, target_lang="FR")
    print(translated)

Example in Node.js (using node-fetch or native fetch)

import 'dotenv/config';

const DEEPL_API_KEY = process.env.DEEPL_API_KEY;
const DEEPL_ENDPOINT = 'https://api.deepl.com/v2/translate';

async function translateText(text, targetLang = 'DE') {
  if (!DEEPL_API_KEY) {
    throw new Error('DEEPL_API_KEY is not set');
  }

  const params = new URLSearchParams();
  params.append('text', text);
  params.append('target_lang', targetLang);

  const response = await fetch(DEEPL_ENDPOINT, {
    method: 'POST',
    headers: {
      Authorization: `DeepL-Auth-Key ${DEEPL_API_KEY}`,
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params.toString(),
  });

  if (!response.ok) {
    const errorText = await response.text();
    throw new Error(`DeepL API error: ${response.status} – ${errorText}`);
  }

  const result = await response.json();
  return result.translations[0].text;
}

(async () => {
  const text = 'Welcome to your first DeepL /translate request.';
  const translated = await translateText(text, 'ES');
  console.log(translated);
})();

Example in Java (using HttpClient)

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.stream.Collectors;

public class DeepLExample {
    private static final String DEEPL_API_KEY = System.getenv("DEEPL_API_KEY");
    private static final String DEEPL_ENDPOINT = "https://api.deepl.com/v2/translate";

    public static void main(String[] args) throws Exception {
        if (DEEPL_API_KEY == null) {
            throw new IllegalStateException("DEEPL_API_KEY is not set");
        }

        String text = "This is my first request to the DeepL /translate endpoint.";
        String targetLang = "IT";

        Map<String, String> params = Map.of(
                "text", text,
                "target_lang", targetLang
        );

        String form = params.entrySet().stream()
                .map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" +
                          URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
                .collect(Collectors.joining("&"));

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(DEEPL_ENDPOINT))
                .header("Authorization", "DeepL-Auth-Key " + DEEPL_API_KEY)
                .header("Content-Type", "application/x-www-form-urlencoded")
                .POST(HttpRequest.BodyPublishers.ofString(form))
                .build();

        HttpClient client = HttpClient.newHttpClient();
        HttpResponse<String> response =
                client.send(request, HttpResponse.BodyHandlers.ofString());

        if (response.statusCode() >= 400) {
            throw new RuntimeException("DeepL API error: " + response.statusCode()
                                       + " – " + response.body());
        }

        System.out.println(response.body());
    }
}

These minimal examples are enough to:

  • Confirm that your API key is valid
  • Validate the endpoint URL
  • Check that your language codes and parameters are correct

Once you have a successful response, you can layer in features like glossaries, formality control, and document translation.


Step 6: Add key parameters to control translation output

The DeepL API’s /translate endpoint is more than a simple source/target call. For real-world business content, you’ll usually want extra control.

Common parameters include:

  • source_lang

    • Use when you don’t want auto‑detect or you work with similar languages.
    • Example: source_lang=EN, target_lang=FR.
  • formality (for supported languages)

    • Control politeness level in translations.
    • Typical values: more, less, sometimes prefer_more, prefer_less.
    • Example: -d "formality=more" for customer‑facing French or German.
  • split_sentences and preserve_formatting

    • Useful for technical content, code snippets, or structured strings.
    • Helps DeepL keep layout and in‑line punctuation closer to the source.
  • glossary_id (where available in your plan)

    • Enforce your company terminology at scale:
      • Product names
      • Legal terms
      • Support phrasing
    • Especially important in regulated industries where wording is non‑negotiable.

Adding these parameters early saves you from re‑reviewing and post‑editing later.


Step 7: Handle responses and errors correctly

When you design around the /translate API, build two habits from the start:

  1. Parse responses defensively

    • Always check that translations exists and has at least one element.
    • Plan for multi‑segment translations if you send multiple text fields in one request.
  2. Log and classify errors
    Typical classes of errors to differentiate in your logs:

    • Authentication/authorization (wrong or missing key)
    • Usage or quota limits
    • Validation errors (missing target_lang, unsupported language codes)
    • Temporary network or service‑side issues

This makes it easier to alert on real problems and handle them gracefully in production.


Common issues when making your first /translate request

When teams ask “How do I get my DeepL API key and make my first /translate request?” the same few pitfalls usually show up. Here’s how to spot and fix them quickly.

1. “Authorization failed” or 401 errors

Likely causes:

  • The API key is from a plan without API rights.
  • The Authorization header is missing or mis‑formatted.
  • There’s a trailing space or character copied with the key.

Checklist:

  • Confirm the plan includes DeepL API access.

  • Ensure the header looks like:

    Authorization: DeepL-Auth-Key YOUR_AUTH_KEY
    
  • Regenerate the key in your account portal if you suspect it has leaked.

2. 403 / 429 errors (access or quota issues)

Likely causes:

  • Subscription limits reached (character or usage quota).
  • The key was disabled or revoked.

What to do:

  • Check your DeepL account usage dashboard.
  • If you’re testing from scripts, make sure you’re not unintentionally hammering the API in a loop.
  • Work with your internal admin or DeepL Sales if you need higher API volume.

3. “Target language not supported” or parameter validation errors

Likely causes:

  • Incorrect language code (e.g., EN-US vs. EN where a specific regional code isn’t supported).
  • Missing required parameter like target_lang.

What to do:

  • Use the language list and codes documented in your DeepL account or API docs.
  • Add server‑side validation for the language codes you allow.

4. Leaking the API key in logs or repositories

This isn’t a technical error—it’s a security risk that’s easy to create accidentally.

Avoid:

  • Adding the API key directly to source files.
  • Logging full headers or environment dumps.

Do instead:

  • Keep the key in environment variables or secrets managers.
  • Redact the Authorization header in any request logging middleware.
  • Rotate the key in DeepL if you suspect exposure.

In regulated environments (finance, healthcare, public sector), this is non‑negotiable: you should be able to prove how API keys and translated content are handled, stored, and deleted.


From first request to real workflows

Once you’ve successfully:

  • Retrieved your DeepL API key
  • Validated a /translate call via curl
  • Integrated a minimal request into your code

you’re ready to connect DeepL API to real business workflows:

  • Customer support: Automatically translate inbound tickets and outbound responses while preserving terminology with glossaries.
  • Product & documentation: Localize UI strings and docs directly from your content pipeline, without copy‑paste.
  • Operations & compliance: Translate process documents and policies at scale while maintaining layout and visual context in supported document flows.
  • Internal tools: Embed translation buttons and shortcuts in the systems your teams already use.

Each of these benefits from the same building block you just set up: a clean, secure /translate request with the right key and parameters.


Final verdict

To answer “How do I get my DeepL API key and make my first /translate request?” in one line:

  1. choose a DeepL plan with API access and copy your authentication key from the account portal,
  2. validate it with a simple /translate curl request,
  3. move that request into your application code with proper security and error handling.

Once those three steps are done, you’re no longer testing—you’re ready to standardize translation inside your products, services, and internal workflows.


Next step

Get Started