A Go-based SDK for interacting with Hyperbolic, the Open Access AI Cloud platform. This SDK enables seamless integration with Hyperbolic's AI services for text generation, image creation, and audio processing.
- Text/Chat Generation API
- Image Generation API
- Audio Processing API
- Simple authentication
- Rate limiting handling
- Efficient resource management
Watch the demo video to see the SDK in action:
go get github.com/taiwrash/hbcgo
First, install the packages:
go get github.com/taiwrash/hbcgo
go get github.com/joho/godotenv
Create a .env
file in your project root:
HBC_API_KEY=your_api_key_here
Here's a complete example showing how to use the library:
package main
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/joho/godotenv"
"github.com/taiwrash/hbcgo"
)
func main() {
// Load environment variables
if err := godotenv.Load(); err != nil {
log.Fatal("Error loading .env file")
}
apiKey := os.Getenv("HBC_API_KEY")
if apiKey == "" {
log.Fatal("HBC_API_KEY environment variable is required")
}
// Create client with timeout
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
defer cancel()
client := hbcgo.NewClient(apiKey)
// Generate an image
imagePath, err := client.GenerateImage(ctx, "a photo of an astronaut riding a horse on mars", 1024, 1024)
if err != nil {
log.Fatalf("Failed to generate image: %v", err)
}
fmt.Printf("Image saved to: %s\n", imagePath)
// Chat with the AI
messages := []hbcgo.Message{
{Role: "system", Content: "You are a helpful assistant."},
{Role: "user", Content: "What is Chinese hotpot?"},
}
response, err := client.Chat(ctx, messages)
if err != nil {
log.Fatalf("Failed to chat: %v", err)
}
fmt.Printf("Assistant Response: %s\n", response)
// Generate audio from text
text := "Welcome to Hyperbolic Hackathon!"
audioPath, err := client.GenerateAudio(ctx, text)
if err != nil {
log.Fatalf("Failed to generate audio: %v", err)
}
fmt.Printf("Audio file generated: %s\n", audioPath)
}
- Image Generation: Create images from text descriptions
- Chat Completion: Have conversations with the AI model
- Text-to-Speech: Convert text to natural-sounding audio
The library generates these files in your working directory:
result.jpg
- Generated imagesresult.mp3
- Generated audio files
Detailed documentation available at docs.hyperbolic.xyz
- Fork the repository
- Create your feature branch
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support or questions, visit Hyperbolic Support