import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
baseURL: 'https://api.naga.ac',
apiKey: 'YOUR_API_KEY',
});
const message = await client.messages.create({
model: 'claude-sonnet-4.5',
max_tokens: 256,
messages: [
{ role: 'user', content: 'Check the weather in Prague and tell me if I need a coat.' },
],
tools: [
{
name: 'lookup_weather',
description: 'Look up current weather for a city.',
input_schema: {
type: 'object',
properties: {
city: { type: 'string' },
},
required: ['city'],
},
},
],
});
if (message.stop_reason === 'tool_use') {
const toolUse = message.content.find((block) => block.type === 'tool_use');
console.log(toolUse?.name);
console.log(toolUse?.input);
}