@@ -23,8 +23,11 @@ class LlmProperties : MachineTranslationServiceProperties {
2323
2424 @DocProperty(
2525 description = """
26- List of LLM providers. Example:
27-
26+ List of LLM providers. When `provider-defaults` is also set, list entries are merged with the
27+ matching map entry (by name). List values override map defaults only when explicitly set
28+ (non-null for nullable fields, non-default for `type` / `maxTokens`).
29+ `enabled` is always taken from the list entry.
30+
2831 ``` yaml
2932 providers:
3033 - name: openai-gpt-4o-mini
@@ -34,9 +37,9 @@ class LlmProperties : MachineTranslationServiceProperties {
3437 model: gpt-4o-mini
3538 format: "json_schema"
3639 ```
37-
40+
3841 or using environment variables:
39-
42+
4043 ```
4144 TOLGEE_LLM_PROVIDERS_0_NAME=MySuperDuperAI
4245 TOLGEE_LLM_PROVIDERS_0_TYPE=OPENAI
@@ -45,12 +48,45 @@ class LlmProperties : MachineTranslationServiceProperties {
4548 TOLGEE_LLM_PROVIDERS_0_MODEL=gpt-4o-mini
4649 TOLGEE_LLM_PROVIDERS_0_FORMAT=json_schema
4750 ```
48-
51+
4952 Check [llm providers documentation](/platform/projects_and_organizations/llm-providers#self-hosted-server-configuration) for more information.
5053 """ ,
5154 )
5255 var providers: MutableList <LlmProvider > = mutableListOf ()
5356
57+ @DocProperty(
58+ description = """
59+ Map of provider defaults keyed by provider name. Use this to separate non-secret configuration
60+ (model, prices, type) from secrets (API keys) in Kubernetes deployments.
61+
62+ ``` yaml
63+ provider-defaults:
64+ gpt-5-mini:
65+ type: OPENAI
66+ model: gpt-5-mini
67+ token-price-in-credits-input: 2.0
68+ token-price-in-credits-output: 1.5
69+ ```
70+
71+ or using environment variables (in a ConfigMap):
72+
73+ ```
74+ TOLGEE_LLM_PROVIDER_DEFAULTS_GPT_5_MINI_TYPE=OPENAI
75+ TOLGEE_LLM_PROVIDER_DEFAULTS_GPT_5_MINI_MODEL=gpt-5-mini
76+ TOLGEE_LLM_PROVIDER_DEFAULTS_GPT_5_MINI_TOKEN_PRICE_IN_CREDITS_INPUT=2.0
77+ TOLGEE_LLM_PROVIDER_DEFAULTS_GPT_5_MINI_TOKEN_PRICE_IN_CREDITS_OUTPUT=1.5
78+ ```
79+
80+ Then supply only the API key via the `providers` list (in a Secret):
81+
82+ ```
83+ TOLGEE_LLM_PROVIDERS_0_NAME=gpt-5-mini
84+ TOLGEE_LLM_PROVIDERS_0_API_KEY=sk-proj-...
85+ ```
86+ """ ,
87+ )
88+ var providerDefaults: MutableMap <String , LlmProviderDefaults > = mutableMapOf ()
89+
5490 @DocProperty(
5591 description = """
5692 Named fallback mapping. When a provider is not found, Tolgee will try the fallback provider.
@@ -133,4 +169,61 @@ class LlmProperties : MachineTranslationServiceProperties {
133169 const val MAX_TOKENS_DEFAULT : Long = 2000
134170 }
135171 }
172+
173+ class LlmProviderDefaults (
174+ @DocProperty(description = " Enable/disable provider" )
175+ var enabled : Boolean = true ,
176+ @DocProperty(description = " Provider type, an API type" )
177+ var type : LlmProviderType = LlmProviderType .OPENAI ,
178+ @DocProperty(description = " Provider API Key (optional for some providers)" )
179+ var apiKey : String? = null ,
180+ @DocProperty(description = " Provider API Url" )
181+ var apiUrl : String? = null ,
182+ @DocProperty(description = " Provider model (optional for some providers)" )
183+ var model : String? = null ,
184+ @DocProperty(description = " Provider deployment (optional for some providers)" )
185+ var deployment : String? = null ,
186+ @DocProperty(
187+ description = """ Maximum number of tokens to generate.
188+ `max_completion_tokens` option for OpenAI API.
189+ `max_tokens` for Anthropic API.""" ,
190+ )
191+ var maxTokens : Long? = null ,
192+ @DocProperty(description = " ChatGPT reasoning effort" )
193+ var reasoningEffort : String? = null ,
194+ @DocProperty(description = " Set to `json_schema` if the API supports JSON Schema" )
195+ var format : String? = null ,
196+ @DocProperty(
197+ description = " Load-balancing instruction HIGH = used for suggestions, LOW = used for batch operations" ,
198+ )
199+ var priority : LlmProviderPriority ? = null ,
200+ @DocProperty(
201+ description =
202+ " Specify attempts timeout(s) (Example: [30, 30] - Tolgee will make two attempts, each with timeout of 30s)" ,
203+ )
204+ var attempts : List <Int >? = null ,
205+ @DocProperty(hidden = true )
206+ var tokenPriceInCreditsInput : Double? = null ,
207+ @DocProperty(hidden = true )
208+ var tokenPriceInCreditsOutput : Double? = null ,
209+ ) {
210+ fun toLlmProvider (name : String ): LlmProvider {
211+ return LlmProvider (
212+ enabled = enabled,
213+ name = name,
214+ type = type,
215+ apiKey = apiKey,
216+ apiUrl = apiUrl,
217+ model = model,
218+ deployment = deployment,
219+ maxTokens = maxTokens ? : LlmProvider .MAX_TOKENS_DEFAULT ,
220+ reasoningEffort = reasoningEffort,
221+ format = format,
222+ priority = priority,
223+ attempts = attempts,
224+ tokenPriceInCreditsInput = tokenPriceInCreditsInput,
225+ tokenPriceInCreditsOutput = tokenPriceInCreditsOutput,
226+ )
227+ }
228+ }
136229}
0 commit comments