Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Created May 8, 2025 01:20
Show Gist options
  • Save topherPedersen/fcb351fdd0ee6dd5018aa6fd6578086a to your computer and use it in GitHub Desktop.
Save topherPedersen/fcb351fdd0ee6dd5018aa6fd6578086a to your computer and use it in GitHub Desktop.
Enable the Anthropic APIs Web Search Tool
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: 'YoUR-APi-KeY-GOEs-HeRE', // This is the default and can be omitted
});
async function main() {
const message = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'What bands are playing tonight at Hotel Vegas in Austin, TX?' }],
model: 'claude-3-7-sonnet-20250219',
// Enable Claude Web Search
tools: [{
type: "web_search_20250305",
name: "web_search",
max_uses: 5
}],
});
console.log(message.content);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment