From 08c6e911c30ba0bce6f709a63e0d2e6231e43107 Mon Sep 17 00:00:00 2001 From: Christiaan de Die le Clercq Date: Thu, 25 Jun 2026 18:53:31 +0200 Subject: [PATCH] AI-Translations: Fix Anthropic Claude CORS error and change max_tokens Claude cannot run in DatoCMS because of a CORS error, for this we add a header to allow CORS. Also, there is no max_output_tokens value in the Claude API docs, currently it errors with a missing max tokens parameter, so changed this as well. --- .../src/utils/translation/providers/AnthropicProvider.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ai-translations/src/utils/translation/providers/AnthropicProvider.ts b/ai-translations/src/utils/translation/providers/AnthropicProvider.ts index 89f5dfbb..db2ec0f2 100644 --- a/ai-translations/src/utils/translation/providers/AnthropicProvider.ts +++ b/ai-translations/src/utils/translation/providers/AnthropicProvider.ts @@ -85,6 +85,7 @@ export default class AnthropicProvider implements TranslationProvider { 'content-type': 'application/json', 'x-api-key': this.apiKey, 'anthropic-version': '2023-06-01', + 'anthropic-dangerous-direct-browser-access': 'true', }, body: JSON.stringify(body), signal, @@ -152,7 +153,7 @@ export default class AnthropicProvider implements TranslationProvider { const body: Record = { model: this.model, - max_output_tokens: this.maxOutputTokens, + max_tokens: this.maxOutputTokens, temperature: this.temperature, messages: [{ role: 'user', content: prompt }], };