1// Package main provides a simple example of using the fantasy AI SDK.
 2package main
 3
 4import (
 5	"context"
 6	"fmt"
 7	"os"
 8
 9	"charm.land/fantasy"
10	"charm.land/fantasy/providers/anthropic"
11)
12
13func main() {
14	provider := anthropic.New(anthropic.WithAPIKey(os.Getenv("ANTHROPIC_API_KEY")))
15	model, err := provider.LanguageModel("claude-sonnet-4-20250514")
16	if err != nil {
17		fmt.Println(err)
18		os.Exit(1)
19	}
20
21	response, err := model.Generate(context.Background(), fantasy.Call{
22		Prompt: fantasy.Prompt{
23			fantasy.NewUserMessage("Hello"),
24		},
25		Temperature: fantasy.Opt(0.7),
26	})
27	if err != nil {
28		fmt.Println(err)
29		os.Exit(1)
30	}
31
32	fmt.Println("Assistant: ", response.Content.Text())
33	fmt.Println("Usage:", response.Usage)
34}