Debian Codegraph @

examples/vertex/main.go

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