Skip to content

Commit 60a5663

Browse files
committed
feat: Enable Anthropic web search by updating beta headers and removing tool filtering, and reorder validator imports.
1 parent 9ff88fc commit 60a5663

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/ax/ai/anthropic/api.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,6 @@ class AxAIAnthropicImpl
291291
...configToolsCleaned,
292292
];
293293

294-
// Anthropic Vertex does not support server tools like web_search; filter them out
295-
if (this.isVertex && tools.length > 0) {
296-
tools = tools.filter(
297-
(t: any) => !(t && typeof t === 'object' && 'type' in t)
298-
);
299-
}
300294
if (tools.length === 0) {
301295
tools = undefined;
302296
}
@@ -870,7 +864,8 @@ export class AxAIAnthropic<TModelKey = string> extends AxBaseAI<
870864
apiURL = 'https://api.anthropic.com/v1';
871865
headers = async () => ({
872866
'anthropic-version': '2023-06-01',
873-
'anthropic-beta': 'structured-outputs-2025-11-13',
867+
'anthropic-beta':
868+
'structured-outputs-2025-11-13, web-search-2025-03-05',
874869
'x-api-key': typeof apiKey === 'function' ? await apiKey() : apiKey,
875870
});
876871
}

src/ax/dsp/generate.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ import {
4747
} from './functions.js';
4848
import { axGlobals } from './globals.js';
4949
import { toJsonSchema } from './jsonSchema.js';
50-
import {
51-
validateURL,
52-
validateStringConstraints,
53-
validateNumberConstraints,
54-
} from './validators.js';
5550
import {
5651
type AxGenMetricsInstruments,
5752
getOrCreateGenMetricsInstruments,
@@ -90,6 +85,11 @@ import type {
9085
AxSetExamplesOptions,
9186
} from './types.js';
9287
import { mergeDeltas } from './util.js';
88+
import {
89+
validateNumberConstraints,
90+
validateStringConstraints,
91+
validateURL,
92+
} from './validators.js';
9393

9494
export type AxGenerateResult<OUT> = OUT & {
9595
thought?: string;

0 commit comments

Comments
 (0)