-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththinkingtest.js
More file actions
59 lines (48 loc) · 2.08 KB
/
thinkingtest.js
File metadata and controls
59 lines (48 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Anthropic from '@anthropic-ai/sdk';
// Test the thinking action directly
async function testThinkingAction() {
try {
console.log('Testing Anthropic Thinking Action...');
// TEMPORARILY hardcode your API key here for testing
const apiKey = ''; // Replace with your actual sk-... key
if (!apiKey || apiKey === 'YOUR_API_KEY_HERE') {
throw new Error('Please replace YOUR_API_KEY_HERE with your actual Anthropic API key');
}
console.log('API Key found:', apiKey.substring(0, 10) + '...');
// Create client without custom baseURL - let SDK handle it
const client = new Anthropic({
apiKey,
timeout: 60000
});
console.log('Created Anthropic client, making test request...');
// Test with thinking - no beta header needed for Claude 3.7
const response = await client.messages.create({
model: "claude-3-7-sonnet-20250219",
max_tokens: 21000,
temperature: 1,
thinking: {
type: "enabled",
budget_tokens: 16000
},
messages: [{
role: "user",
content: "What is 2+2? Think through this step by step."
}]
});
console.log('✅ SUCCESS! Thinking action works correctly');
console.log('Response:', JSON.stringify(response, null, 2));
} catch (error) {
console.error('❌ ERROR in thinking action:');
console.error('Status:', error.status);
console.error('Error:', error.error || error.message);
console.error('Headers:', error.headers);
if (error.status === 404) {
console.log('\n🔍 Debugging 404 error:');
console.log('- Check if API key has access to Claude 3.7 models');
console.log('- Verify anthropic-version header is correct');
console.log('- Confirm model name: claude-3-7-sonnet-20250219');
}
}
}
// Run the test
testThinkingAction();