https://github.com/akadotsh/groq-go-sdk
Go client library for interacting with the Groq API.
https://github.com/akadotsh/groq-go-sdk
groq-ai llm sdk-go
Last synced: 2 months ago
JSON representation
Go client library for interacting with the Groq API.
- Host: GitHub
- URL: https://github.com/akadotsh/groq-go-sdk
- Owner: akadotsh
- License: mit
- Created: 2024-08-11T18:21:10.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-01T21:33:38.000Z (about 1 year ago)
- Last Synced: 2025-01-23T04:25:00.725Z (9 months ago)
- Topics: groq-ai, llm, sdk-go
- Language: Go
- Homepage: https://github.com/akadotsh/groq-go-sdk
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> ### IMPORTANT: This is an unofficial, community-developed Groq client library for Go. It is not affiliated with, officially maintained, or endorsed by Groq Inc.
# Groq Go SDK
### Go client library for interacting with the Groq API.
## Requirements
- Go 1.22.4 or higher
- [godotenv package](https://github.com/joho/godotenv) (optional, for loading environment variables from a `.env` file)## Installation
```bash
go get github.com/akadotsh/groq-go-sdk
```## Usage
1. Get an API key from [https://console.groq.com/keys](https://console.groq.com/keys)
2. Set the API key as an environment variable named `groq_api_key`.```go
package mainimport (
"fmt"
"log"
"os""github.com/akadotsh/groq-go-sdk"
"github.com/joho/godotenv"
)func main() {
// Load environment variables from .env file
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}// Get the API key from environment variables
groqAPIKey := os.Getenv("GROQ_API_KEY")
if groqAPIKey == "" {
log.Fatal("GROQ_API_KEY not set in environment variables")
}// Initialize the Groq client
client := groq.New(groqAPIKey)
if client == nil {
log.Fatal("Failed to create Groq client")
}// Prepare the chat request
chat := groq.Chat{
Messages: []groq.Message{
{
Role: groq.User,
Content: "Explain the importance of fast language models",
},
},
Model: groq.Mixtral_8x7b_32768,
}// Send a chat request
response, err := client.Chat(chat)
if err != nil {
log.Fatalf("Error calling Chat: %v", err)
}// Print the response
fmt.Println(response)
}
```# License
This project is licensed under the MIT License - [see the LICENSE file for details](https://github.com/akadotsh/groq-go-sdk?tab=MIT-1-ov-file)