groq-go is a Go client library for interacting with the Groq API. This library provides a simple and efficient way to integrate Groq's powerful language models into your Go applications.
- Easy-to-use client for Groq API
- Support for chat completions
- Customizable API requests
Here's an example of how to use the ChatCompletion function to get chat completions:
package main
import (
"fmt"
groq "github.com/hasitpbhatt/groq-go"
)
func main() {
// Automatically read API key from GROQ_API_KEY environment variable
client := groq.NewClient()
resp, err := client.ChatCompletion([]groq.Message{
{
Content: "You're a seasoned developer",
Role: "system",
},
{
Content: "What is groq cloud?",
Role: "user",
},
})
if err != nil {
fmt.Println("Error occurred")
}
for _, c := range resp.Choices {
fmt.Println(c.Message.Content)
}
}To install the package, use go get github.com/hasitpbhatt/groq-go: