Debian Codegraph @

examples/bedrock/main.go

raw
1 package main
2
3 import (
4 "context"
5
6 "github.com/anthropics/anthropic-sdk-go"
7 "github.com/anthropics/anthropic-sdk-go/bedrock"
8 )
9
10 func main() {
11 client := anthropic.NewClient(
12 bedrock.WithLoadDefaultConfig(context.Background()),
13 )
14
15 content := "Write me a function to call the Anthropic message API in Node.js using the Anthropic Typescript SDK."
16
17 println("[user]: " + content)
18
19 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
20 MaxTokens: 1024,
21 Messages: []anthropic.MessageParam{
22 anthropic.NewUserMessage(anthropic.NewTextBlock(content)),
23 },
24 Model: "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
25 StopSequences: []string{"```\n"},
26 })
27 if err != nil {
28 panic(err)
29 }
30
31 println("[assistant]: " + message.Content[0].Text + message.StopSequence)
32 }