From 6ccfb9e023d36f5c504e82a297225b67f89ad596 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 24 Oct 2025 11:29:33 +0200 Subject: [PATCH] Optimizes token usage for timed prompts Reduces max tokens for timed prompts to improve latency and cost-efficiency Introduces dynamic max_tokens configuration based on prompt type, using a smaller token limit for time-sensitive requests --- api/anthropicClient.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/anthropicClient.ts b/api/anthropicClient.ts index b8bbaad..4abb333 100644 --- a/api/anthropicClient.ts +++ b/api/anthropicClient.ts @@ -39,9 +39,12 @@ export class AnthropicClient { } finalSystemPrompt += this.SYSTEM_PROMPT_SUFFIX; + // Use smaller max_tokens for timed prompts to reduce latency/cost + const maxTokens = type === 'timed' ? 256 : 1000; + const request: AnthropicRequest = { model, - max_tokens: 1000, + max_tokens: maxTokens, messages: [{ role: 'user', content: userMessage }], system: finalSystemPrompt };