GitHub
github.com › anthropics › anthropic-sdk-go
GitHub - anthropics/anthropic-sdk-go: Access to Anthropic's safety-first language model APIs via Go
p := anthropic.ExampleParams{ ID: "id_xxx", // required property Name: anthropic.String("..."), // optional property Point: anthropic.Point{ X: 0, // required field will serialize as 0 Y: anthropic.Int(1), // optional field will serialize as 1 // ...
Starred by 665 users
Forked by 83 users
Languages Go
Go Packages
pkg.go.dev › github.com › adamchol › go-anthropic-sdk
anthropic package - github.com/adamchol/go-anthropic-sdk - Go Packages
package main import ( "context" "encoding/base64" "fmt" "log" "os" "github.com/adamchol/go-anthropic-sdk" ) func main() { client := anthropic.NewClient("your-token") imageBytes, err := os.ReadFile("ant.jpg") if err != nil { log.Fatalf("Failed to read image file: %v", err) } imgData := base64.StdEncoding.EncodeToString(imageBytes) // Encoding the image into base64 resp, err := client.CreateMessage(context.Background(), anthropic.MessageRequest{ Model: anthropic.Claude35SonnetModel, Messages: []anthropic.InputMessage{ { Role: "user", ContentBlocks: []anthropic.ContentBlock{ // Using ContentBlock
Videos
GitHub
github.com › liushuangls › go-anthropic
GitHub - liushuangls/go-anthropic: Anthropic Claude API wrapper for Go
package main import ( "errors" "fmt" "github.com/liushuangls/go-anthropic/v2" ) func main() { client := anthropic.NewClient("your anthropic api key") resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{ Model: anthropic.ModelClaude3Haiku20240307, Messages: []anthropic.Message{ anthropic.NewUserTextMessage("What is your name?"), }, MaxTokens: 1000, }) if err != nil { var e *anthropic.APIError if errors.As(err, &e) { fmt.Printf("Messages error, type: %s, message: %s", e.Type, e.Message) } else { fmt.Printf("Messages error: %v\n", err) } return } fmt.Println(resp.Content[0].GetText()) }
Starred by 165 users
Forked by 26 users
Languages Go
Go Packages
pkg.go.dev › github.com › staropshq › go-anthropic
go-anthropic module - github.com/staropshq/go-anthropic - Go Packages
completion, err := anthropic.Answer("Why is the sky blue?", 255) if err != nil { panic(err) } fmt.Println(*completion)
Go Packages
pkg.go.dev › github.com › 3JoB › anthropic-sdk-go
anthropic package - github.com/3JoB/anthropic-sdk-go - Go Packages
package main import ( "fmt" "github.com/3JoB/anthropic-sdk-go" "github.com/3JoB/anthropic-sdk-go/data" ) func main() { c, err := anthropic.New("api keys","modules") if err != nil { panic(err) } d, err := c.Send(&anthropic.Opts{ Message: data.MessageModule{ Human: "Do you know Golang, please answer me in the shortest possible way.", }, Sender: anthropic.Sender{MaxToken: 1200}, }) if err != nil { panic(err) } fmt.Println(d.Response.String()) }
Go Packages
pkg.go.dev › github.com › fabiustech › anthropic
anthropic package - github.com/fabiustech/anthropic - Go Packages
Model Model `json:"model,omitempty"` // MaxTokensToSample is the maximum number of tokens to generate before stopping. Required. MaxTokensToSample int `json:"max_tokens_to_sample"` // StopSequences specifies a list of sequences to stop sampling at. Anthropic's models stop on "\n\nHuman:", and // may include additional built-in stop sequences in the future.
Go Packages
pkg.go.dev › github.com › liushuangls › go-anthropic
anthropic package - github.com/liushuangls/go-anthropic - Go Packages
package main import ( "errors" "fmt" "github.com/liushuangls/go-anthropic" ) func main() { client := anthropic.NewClient("your anthropic apikey") resp, err := client.CreateMessages(context.Background(), anthropic.MessagesRequest{ Model: anthropic.ModelClaudeInstant1Dot2, Messages: []anthropic.Message{ anthropic.NewUserTextMessage("What is your name?"), }, MaxTokens: 1000, }) if err != nil { var e *anthropic.APIError if errors.As(err, &e) { fmt.Printf("Messages error, type: %s, message: %s", e.Type, e.Message) } else { fmt.Printf("Messages error: %v\n", err) } return } fmt.Println(resp.Content[0].Text) }
GitHub
github.com › 3JoB › anthropic-sdk-go
GitHub - 3JoB/anthropic-sdk-go: (Need to be maintained) Golang SDK for AnthRopic Claude AI. Provide complete encapsulated interfaces that are easy to quickly get started with.
Context Example: package main import ( "fmt" "github.com/3JoB/anthropic-sdk-go/v2" "github.com/3JoB/anthropic-sdk-go/v2/resp" "github.com/3JoB/anthropic-sdk-go/v2/data" ) func main() { c, err := anthropic.New(&anthropic.Config{Key: "your keys", DefaultModel: data.ModelFullInstant}) if err != nil { panic(err) } d, err := c.Send(&anthropic.Sender{ Message: data.MessageModule{ Human: "Do you know Golang, please answer me in the shortest possible way.", }, Sender: &resp.Sender{MaxToken: 1200}, }) if err != nil { panic(err) } fmt.Println(d.Response.String()) ds, err := c.Send(&anthropic.Sender{ Message: data.MessageModule{ Human: "What is its current version number?", }, SessionID: d.ID, Sender: &resp.Sender{MaxToken: 1200}, }) if err != nil { panic(err) } fmt.Println(ds.Response.String()) } Return: {"detail":null,"completion":"Hello world!
Starred by 38 users
Forked by 6 users
Languages Go
GitHub
github.com › unfunco › anthropic-sdk-go
GitHub - unfunco/anthropic-sdk-go: Go client library for interacting with the Anthropic safety-first language model REST APIs.
Go client library for interacting with the Anthropic safety-first language model REST APIs. - unfunco/anthropic-sdk-go
Author unfunco
Reddit
reddit.com › r/anthropic › golang mcp implementation
r/Anthropic on Reddit: Golang MCP Implementation
November 27, 2024 -
I've scaffolded a basic SDK implementation in Go with the help of the specification docs and Claude Sonnet. Would have taken forever otherwise lol.
I have a basic client implemented with stdio and sse transports. Would love to get this to parity with the JS and Python SDKs. I'm ok with Go but not an expert by any means. Happy to have some help or at least have people check out the lib and note what's missing or can be fixed.
Cheers!
https://github.com/mark3labs/mcp-go
Top answer 1 of 2
1
I've also gone ahead and implemented the filesystem-server in Go using the newly created SDK https://github.com/mark3labs/mcp-filesystem-server
2 of 2
1
Hey, I have made an alternative implementation, that is only intended to be used for servers, but provides somewhat more high level API to register tools, prompts and resources, which allows to colocate related things. It is based on "fx" DI framework to wire everything together. strowk/foxy-contexts: Foxy contexts is a library for building context servers supporting Model Context Protocol I use my own underlying server implementation, it is possible that I might switch to anything that would be an official sdk..
Go Packages
pkg.go.dev › github.com › anthropics › anthropic-sdk-go
anthropic package - github.com/anthropics/anthropic-sdk-go - Go Packages
p := anthropic.ExampleParams{ ID: "id_xxx", // required property Name: anthropic.String("..."), // optional property Point: anthropic.Point{ X: 0, // required field will serialize as 0 Y: anthropic.Int(1), // optional field will serialize as 1 // ...
Go Packages
pkg.go.dev › github.com › modeledge › anthropic-sdk-go › v2
anthropic package - github.com/modeledge/anthropic-sdk-go/v2 - Go Packages
Context Example: package main import ( "fmt" "github.com/modeledge/anthropic-sdk-go/v2" "github.com/modeledge/anthropic-sdk-go/v2/resp" "github.com/modeledge/anthropic-sdk-go/v2/data" ) func main() { c, err := anthropic.New(&anthropic.Config{Key: "your keys", DefaultModel: data.ModelFullInstant}) if err != nil { panic(err) } d, err := c.Send(&anthropic.Sender{ Message: data.MessageModule{ Human: "Do you know Golang, please answer me in the shortest possible way.", }, Sender: &resp.Sender{MaxToken: 1200}, }) if err != nil { panic(err) } fmt.Println(d.Response.String()) ds, err := c.Send(&anthropic.Sender{ Message: data.MessageModule{ Human: "What is its current version number?", }, SessionID: d.ID, Sender: &resp.Sender{MaxToken: 1200}, }) if err != nil { panic(err) } fmt.Println(ds.Response.String()) } Return: {"detail":null,"completion":"Hello world!
Restack
restack.io › p › anthropic-knowledge-answer-golang-sdk-cat-ai
Anthropic SDK Golang Overview | Restackio
In this example, replace YOUR_API_KEY with your actual API key. The request sends a message to the API and prints the response. This setup allows you to authenticate and interact with the Anthropic API using Go. Make sure to handle errors appropriately and secure your API key to prevent ...
Go Packages
pkg.go.dev › github.com › NikitosnikN › go-anthropic-api
go_anthropic_api package - github.com/NikitosnikN/go-anthropic-api - Go Packages
package main import ( "context" "fmt" claude "github.com/NikitosnikN/go-anthropic-api" "io" ) func main() { // Create a new Claude client client := claude.NewClient("your-api-key") // Create a message request instance message := claude.MessagesRequest{ Model: "claude-3-haiku-20240307", MaxTokens: 1024, } message.AddTextMessage("user", "hello world") // Send request stream, err := client.CreateMessageRequestStream(context.Background(), message) if err != nil { panic(err) } // Read response for { part, err := stream.ReadMessage(false) if err == io.EOF { break } if err != nil { panic(err) } fmt.Println(part) // Hello // !
Go Packages
pkg.go.dev › github.com › anthropics › anthropic-sdk-go › option
option package - github.com/anthropics/anthropic-sdk-go/option - Go Packages
RequestOption is an option for the requests made by the anthropic API Client which can be supplied to clients, services, and methods.
Go Packages
pkg.go.dev › github.com › mengdcz › anthropic-go › v2 › pkg › anthropic
anthropic package - github.com/mengdcz/anthropic-go/v2/pkg/anthropic - Go Packages
NewClient initializes a new Anthropic API client with the required headers.
Go Packages
pkg.go.dev › github.com › 3dsinteractive › langchaingo › examples › anthropic-tool-call-example
anthropic-tool-call-example command - github.com/3dsinteractive/langchaingo/examples/anthropic-tool-call-example - Go Packages
Welcome to the Anthropic Tool Call Example! This fun little Go program demonstrates how to use the Anthropic API to create an AI assistant that can answer questions about the weather using function calling.