forked from thomasaabo/chatkta
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-claude.js
More file actions
27 lines (26 loc) · 716 Bytes
/
Copy pathtest-claude.js
File metadata and controls
27 lines (26 loc) · 716 Bytes
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
const axios = require('axios');
// Make a request to Anthropic's API
axios.post(
'https://api.anthropic.com/v1/messages',
{
model: "claude-3-haiku-20240307",
max_tokens: 1000,
messages: [
{
role: "user",
content: "Hello, Claude. How are you today?"
}
]
},
{
headers: {
'Content-Type': 'application/json',
'x-api-key': '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',
'anthropic-version': '2023-06-01'
}
}
).then(response => {
console.log('Success:', response.data);
}).catch(error => {
console.error('Error:', error.response ? error.response.data : error.message);
});