Translation
TranslationOpenRouter Translation

OpenRouter Translation

Use OpenRouter as a translation provider into directive @strTranslate, to translate a field value to your desired language.

Description

Make OpenRouter's API available as a translation provider in directive @strTranslate.

Add directive @strTranslate to any field of type String, to translate it to the desired language.

For instance, this query translates the post's title and content fields from English to French using the OpenRouter API:

{
  posts {
    title @strTranslate(
      from: "en",
      to: "fr",
      provider: openrouter
    )
    
    content @strTranslate(
      from: "en",
      to: "fr",
      provider: openrouter
    )
  }
}

OpenRouter Authorization

In order to use OpenRouter, it is mandatory to provide your OpenRouter API key, via tab "Plugin Management => OpenRouter Translation" on the Settings page.

Create the API key in your OpenRouter's account.

Then follow one of the methods below to input the value.

By Settings

Input the API key in the corresponding inputs in the Settings page, and click on "Save Changes (All)":

Setting OpenRouter's API key
Setting OpenRouter's API key

In wp-config.php

Add constant GATOGRAPHQL_OPENROUTER_TRANSLATION_SERVICES_OPENROUTER_API_KEY in wp-config.php:

define( 'GATOGRAPHQL_OPENROUTER_TRANSLATION_SERVICES_OPENROUTER_API_KEY', '{your API key}' );

By environment variable

Define environment variable OPENROUTER_TRANSLATION_SERVICES_OPENROUTER_API_KEY.

OpenRouter model

You can customize which OpenRouter model to use to execute the translation.

All models that support structured outputs are supported:

  • Goliath 120B (alpindale/goliath-120b)
  • Venice: Uncensored (free) (cognitivecomputations/dolphin-mistral-24b-venice-edition:free)
  • Cohere: Command (cohere/command)
  • Cohere: Command A (cohere/command-a)
  • Cohere: Command R (cohere/command-r)
  • Cohere: Command R+ (cohere/command-r-plus)
  • DeepSeek: DeepSeek V3 (deepseek/deepseek-chat)
  • DeepSeek: R1 (deepseek/deepseek-r1)
  • DeepSeek: R1 0528 (deepseek/deepseek-r1-0528)
  • DeepSeek: R1 0528 (free) (deepseek/deepseek-r1-0528:free)
  • DeepSeek: R1 Distill Llama 70B (deepseek/deepseek-r1-distill-llama-70b)
  • Google: Gemini 2.0 Flash (google/gemini-2.0-flash-001)
  • Google: Gemini 2.0 Flash Lite (google/gemini-2.0-flash-lite-001)
  • Google: Gemini 2.5 Flash (google/gemini-2.5-flash)
  • Google: Gemini 2.5 Pro (google/gemini-2.5-pro)
  • Google: Gemini 1.5 Flash (google/gemini-flash-1.5)
  • Google: Gemini 1.5 Flash 8B (google/gemini-flash-1.5-8b)
  • Google: Gemini 1.5 Pro (google/gemini-pro-1.5)
  • Google: Gemma 3 12B (free) (google/gemma-3-12b-it:free)
  • Google: Gemma 3 27B (free) (google/gemma-3-27b-it:free)
  • Google: Gemma 3 4B (free) (google/gemma-3-4b-it:free)
  • MythoMax 13B (gryphe/mythomax-l2-13b)
  • Meta: Llama 3.1 405B Instruct (meta-llama/llama-3.1-405b-instruct)
  • Meta: Llama 3.1 405B Instruct (free) (meta-llama/llama-3.1-405b-instruct:free)
  • Meta: Llama 3.1 70B Instruct (meta-llama/llama-3.1-70b-instruct)
  • Meta: Llama 3.1 8B Instruct (meta-llama/llama-3.1-8b-instruct)
  • Meta: Llama 3.3 70B Instruct (meta-llama/llama-3.3-70b-instruct)
  • Meta: Llama 4 Maverick (meta-llama/llama-4-maverick)
  • Meta: Llama 4 Scout (meta-llama/llama-4-scout)
  • MiniMax: MiniMax M1 (minimax/minimax-m1)
  • Mistral: Codestral 2501 (mistralai/codestral-2501)
  • Mistral: Devstral Medium (mistralai/devstral-medium)
  • Mistral: Devstral Small 1.1 (mistralai/devstral-small)
  • Mistral: Devstral Small 2505 (mistralai/devstral-small-2505)
  • Mistral: Magistral Medium 2506 (mistralai/magistral-medium-2506)
  • Mistral: Magistral Medium 2506 (thinking) (mistralai/magistral-medium-2506:thinking)
  • Mistral: Magistral Small 2506 (mistralai/magistral-small-2506)
  • Mistral: Ministral 3B (mistralai/ministral-3b)
  • Mistral: Ministral 8B (mistralai/ministral-8b)
  • Mistral Large (mistralai/mistral-large)
  • Mistral Large 2407 (mistralai/mistral-large-2407)
  • Mistral Large 2411 (mistralai/mistral-large-2411)
  • Mistral: Mistral Medium 3 (mistralai/mistral-medium-3)
  • Mistral: Mistral Nemo (mistralai/mistral-nemo)
  • Mistral: Saba (mistralai/mistral-saba)
  • Mistral Small (mistralai/mistral-small)
  • Mistral: Mistral Small 3 (mistralai/mistral-small-24b-instruct-2501)
  • Mistral: Mistral Small 3.1 24B (mistralai/mistral-small-3.1-24b-instruct)
  • Mistral: Mistral Small 3.1 24B (free) (mistralai/mistral-small-3.1-24b-instruct:free)
  • Mistral: Mistral Small 3.2 24B (mistralai/mistral-small-3.2-24b-instruct)
  • Mistral: Mistral Small 3.2 24B (free) (mistralai/mistral-small-3.2-24b-instruct:free)
  • Mistral Tiny (mistralai/mistral-tiny)
  • Mistral: Mixtral 8x22B Instruct (mistralai/mixtral-8x22b-instruct)
  • Mistral: Pixtral 12B (mistralai/pixtral-12b)
  • Mistral: Pixtral Large 2411 (mistralai/pixtral-large-2411)
  • MoonshotAI: Kimi K2 (moonshotai/kimi-k2)
  • NeverSleep: Lumimaid v0.2 8B (neversleep/llama-3.1-lumimaid-8b)
  • OpenAI: ChatGPT-4o (openai/chatgpt-4o-latest)
  • OpenAI: Codex Mini (openai/codex-mini)
  • OpenAI: GPT-4.1 (openai/gpt-4.1)
  • OpenAI: GPT-4.1 Mini (openai/gpt-4.1-mini)
  • OpenAI: GPT-4.1 Nano (openai/gpt-4.1-nano)
  • OpenAI: GPT-4o (openai/gpt-4o)
  • OpenAI: GPT-4o (extended) (openai/gpt-4o:extended)
  • OpenAI: GPT-4o-mini (openai/gpt-4o-mini)
  • OpenAI: o1 (openai/o1)
  • OpenAI: o1-pro (openai/o1-pro)
  • OpenAI: o3 (openai/o3)
  • OpenAI: o3 Mini (openai/o3-mini)
  • OpenAI: o3 Mini High (openai/o3-mini-high)
  • OpenAI: o3 Pro (openai/o3-pro)
  • OpenAI: o4 Mini (openai/o4-mini)
  • OpenAI: o4 Mini High (openai/o4-mini-high)
  • Qwen: Qwen2.5 VL 32B Instruct (qwen/qwen2.5-vl-32b-instruct)
  • Qwen: Qwen2.5 VL 72B Instruct (free) (qwen/qwen2.5-vl-72b-instruct:free)
  • Qwen: Qwen3 235B A22B (qwen/qwen3-235b-a22b)
  • Qwen: Qwen3 235B A22B (free) (qwen/qwen3-235b-a22b:free)
  • Qwen: Qwen3 30B A3B (qwen/qwen3-30b-a3b)
  • Qwen: Qwen3 32B (qwen/qwen3-32b)
  • Qwen: Qwen3 4B (free) (qwen/qwen3-4b:free)
  • Qwen: QwQ 32B (free) (qwen/qwq-32b:free)
  • Sao10K: Llama 3.1 Euryale 70B v2.2 (sao10k/l3.1-euryale-70b)
  • Sao10K: Llama 3.3 Euryale 70B (sao10k/l3.3-euryale-70b)
  • TheDrummer: Rocinante 12B (thedrummer/rocinante-12b)
  • TheDrummer: Skyfall 36B V2 (thedrummer/skyfall-36b-v2)
  • TheDrummer: UnslopNemo 12B (thedrummer/unslopnemo-12b)
  • TheDrummer: Valkyrie 49B V1 (thedrummer/valkyrie-49b-v1)
  • ReMM SLERP 13B (undi95/remm-slerp-l2-13b)
  • xAI: Grok 3 (x-ai/grok-3)
  • xAI: Grok 3 Mini (x-ai/grok-3-mini)
  • xAI: Grok 4 (x-ai/grok-4)
  • 01.AI: Yi Large (01-ai/yi-large)

Follow one of the methods below to input the value.

By Settings

Input the model in the corresponding input in the Settings page, and click on "Save Changes (All)":

Setting the OpenRouter model
Setting the OpenRouter model

In wp-config.php

Add constant GATOGRAPHQL_OPENROUTER_TRANSLATION_SERVICES_MODEL in wp-config.php:

define( 'GATOGRAPHQL_OPENROUTER_TRANSLATION_SERVICES_MODEL', 'codestral-latest' );

By environment variable

Define environment variable OPENROUTER_TRANSLATION_SERVICES_MODEL.

Translation prompt

You can customize the prompt to pass OpenRouter to execute the translation.

Follow one of the methods below to input the value.

By Settings

Input the "System message" and "Prompt template" in the corresponding inputs in the Settings page, and click on "Save Changes (All)":

Setting the prompt for OpenRouter
Setting the prompt for OpenRouter

In wp-config.php

Add constants GATOGRAPHQL_OPENROUTER_TRANSLATION_SERVICES_SYSTEM_MESSAGE and GATOGRAPHQL_OPENROUTER_TRANSLATION_SERVICES_PROMPT_TEMPLATE in wp-config.php:

define( 'GATOGRAPHQL_OPENROUTER_TRANSLATION_SERVICES_SYSTEM_MESSAGE', 'You are a helpful translator' );
define( 'GATOGRAPHQL_OPENROUTER_TRANSLATION_SERVICES_PROMPT_TEMPLATE', 'Please translate strings from {$sourceLang} to {$targetLang}' );

By environment variable

Define environment variables OPENROUTER_TRANSLATION_SERVICES_SYSTEM_MESSAGE and OPENROUTER_TRANSLATION_SERVICES_PROMPT_TEMPLATE.