From d1bfebd34789647ef85a130a2f475abbe85f285b Mon Sep 17 00:00:00 2001 From: Mike Lambert Date: Sun, 8 Feb 2026 14:09:32 -0500 Subject: [PATCH 1/2] Add User-Agent header for Anthropic API calls Passes User-Agent: bolt.diy/1.0.0 to the Anthropic SDK so Anthropic can identify traffic from bolt.diy. Co-Authored-By: Claude Opus 4.6 --- app/lib/modules/llm/providers/anthropic.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/lib/modules/llm/providers/anthropic.ts b/app/lib/modules/llm/providers/anthropic.ts index 56899e0235..20020567f0 100644 --- a/app/lib/modules/llm/providers/anthropic.ts +++ b/app/lib/modules/llm/providers/anthropic.ts @@ -127,7 +127,10 @@ export default class AnthropicProvider extends BaseProvider { }); const anthropic = createAnthropic({ apiKey, - headers: { 'anthropic-beta': 'output-128k-2025-02-19' }, + headers: { + 'anthropic-beta': 'output-128k-2025-02-19', + 'User-Agent': 'bolt.diy/1.0.0', + }, }); return anthropic(model); From 4c54faa2d7a2467167d9a298f9f3a6e7aaf0fe0a Mon Sep 17 00:00:00 2001 From: Mike Lambert Date: Sun, 15 Feb 2026 18:57:19 -0500 Subject: [PATCH 2/2] Add test for Anthropic provider User-Agent header Verifies that createAnthropic is called with a User-Agent header matching bolt.diy/. Co-Authored-By: Claude Opus 4.6 --- .../modules/llm/providers/anthropic.spec.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/lib/modules/llm/providers/anthropic.spec.ts diff --git a/app/lib/modules/llm/providers/anthropic.spec.ts b/app/lib/modules/llm/providers/anthropic.spec.ts new file mode 100644 index 0000000000..227c99252d --- /dev/null +++ b/app/lib/modules/llm/providers/anthropic.spec.ts @@ -0,0 +1,34 @@ +import { describe, expect, it, vi } from 'vitest'; + +vi.mock('@ai-sdk/anthropic', () => ({ + createAnthropic: vi.fn().mockReturnValue(vi.fn().mockReturnValue({ id: 'mock-model' })), +})); + +vi.mock('~/lib/modules/llm/manager', () => ({ + LLMManager: { + getInstance: vi.fn().mockReturnValue({ env: {} }), + }, +})); + +import AnthropicProvider from './anthropic'; +import { createAnthropic } from '@ai-sdk/anthropic'; + +describe('AnthropicProvider', () => { + it('passes User-Agent header when creating Anthropic client', () => { + const provider = new AnthropicProvider(); + provider.getModelInstance({ + model: 'claude-3-5-sonnet-20241022', + serverEnv: {} as any, + apiKeys: { ANTHROPIC_API_KEY: 'test-key' }, + providerSettings: {}, + }); + + expect(createAnthropic).toHaveBeenCalledWith( + expect.objectContaining({ + headers: expect.objectContaining({ + 'User-Agent': expect.stringMatching(/^bolt\.diy\//), + }), + }), + ); + }); +});