Skip to content
/ hbcgo Public

go sdk for hyperboliclab image, audio and text inference and gpu renting

Notifications You must be signed in to change notification settings

Taiwrash/hbcgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HyperbolicLab Agentic Go SDK

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.

Features

  • Text/Chat Generation API
  • Image Generation API
  • Audio Processing API
  • Simple authentication
  • Rate limiting handling
  • Efficient resource management

Demo

Watch the demo video to see the SDK in action:

HBC Go SDK Demo

Installation

go get github.com/taiwrash/hbcgo

Usage

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)
}

Features

  • Image Generation: Create images from text descriptions
  • Chat Completion: Have conversations with the AI model
  • Text-to-Speech: Convert text to natural-sounding audio

Output Files

The library generates these files in your working directory:

  • result.jpg - Generated images
  • result.mp3 - Generated audio files

Documentation

Detailed documentation available at docs.hyperbolic.xyz

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support or questions, visit Hyperbolic Support

About

go sdk for hyperboliclab image, audio and text inference and gpu renting

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages