Documentation Index
Fetch the complete documentation index at: https://docs.modelslab.com/llms.txt
Use this file to discover all available pages before exploring further.
ModelsLab Go SDK
Official Go SDK for ModelsLab API - Generate AI content including images, videos, audio, 3D models, and more.
Features
Text-to-Image & Image-to-Image generation
Text-to-Speech & Music generation
Interior Design & 3D modeling
Image Editing (upscaling, background removal, etc.)
Realtime generation APIs
Enterprise features support
Quick Start
1. Installation
go mod init your-project
go get github.com/modelslab/modelslab-go
2. Get Your API Key
- Sign up at ModelsLab.com
- Go to your dashboard
- get your API key
import (
"context"
"encoding/json"
"fmt"
"github.com/modelslab/modelslab-go/pkg/apis/community"
"github.com/modelslab/modelslab-go/pkg/client"
communitySchema "github.com/modelslab/modelslab-go/pkg/schemas/community"
)
func main() {
c := client.New("your-api-key")
api := community.New(c, false)
model := "midjourney"
req := &communitySchema.Text2ImageRequest{
Prompt: "a cat",
ModelID: &model,
}
resp, err := api.TextToImage(context.Background(), &req)
if err != nil {
fmt.Println("Error:", err)
return
}
out, _ := json.MarshalIndent(resp, "", " ")
fmt.Println(string(out))
}
4. Run Your Code
API Examples
Text-to-Speech
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/modelslab/modelslab-go/pkg/apis/audio"
"github.com/modelslab/modelslab-go/pkg/client"
audioSchema "github.com/modelslab/modelslab-go/pkg/schemas/audio"
)
func main() {
c := client.New("your-api-key")
api := audio.New(c, false)
voice_id := "madison"
language := "english"
req := audioSchema.Text2SpeechRequest{
Prompt: "a cat sitting on a mat",
VoiceID: &voice_id,
Language: &language,
}
resp, err := api.TextToSpeech(context.Background(), &req)
if err != nil {
fmt.Println("Error:", err)
return
}
out, _ := json.MarshalIndent(resp, "", " ")
fmt.Println(string(out))
}
Text-to-Video
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/modelslab/modelslab-go/pkg/apis/video"
"github.com/modelslab/modelslab-go/pkg/client"
videoSchema "github.com/modelslab/modelslab-go/pkg/schemas/video"
)
func main() {
c := client.New("your-api-key")
videoAPI := video.New(c, false)
req := videoSchema.Text2VideoRequest{
Prompt: "A cat playing with a ball in a sunny garden",
ModelID: "cogvideox",
}
resp, err := videoAPI.TextToVideo(context.Background(), &req)
if err != nil {
panic(err)
}
prettyJSON, _ := json.MarshalIndent(resp, "", " ")
fmt.Println(string(prettyJSON))
}
Available APIs
| API | Description | Package |
|---|
| Community | Text-to-Image, Image-to-Image, Inpainting, ControlNet | github.com/modelslab/modelslab-go/pkg/apis/community |
| Audio | Text-to-Speech, Music Generation, Voice Cloning | github.com/modelslab/modelslab-go/pkg/apis/audio |
| Video | Text-to-Video, Image-to-Video | github.com/modelslab/modelslab-go/pkg/apis/video |
| Image Editing | Super Resolution, Background Removal, Outpainting | github.com/modelslab/modelslab-go/pkg/apis/image_editing |
| Interior | Interior Design, Room Decoration | github.com/modelslab/modelslab-go/pkg/apis/interior |
| 3D | Text-to-3D, Image-to-3D | github.com/modelslab/modelslab-go/pkg/apis/threed |
| Realtime | Real-time Image Generation | github.com/modelslab/modelslab-go/pkg/apis/realtime |
Configuration
Basic Client
import "github.com/modelslab/modelslab-go/pkg/client"
// Simple client
c := client.New("your-api-key")
Custom Configuration
import (
"time"
"github.com/modelslab/modelslab-go/pkg/client"
)
config := &client.Config{
APIKey: "your-api-key",
BaseURL: "https://modelslab.com/api/",
FetchRetry: 10,
FetchTimeout: 2 * time.Second,
HTTPTimeout: 30 * time.Second,
}
c := client.NewWithConfig(config)
Enterprise Mode
// For enterprise users
communityAPI := community.New(c, true) // true = enterprise mode
The SDK returns complete raw API responses as map[string]interface{} to preserve all fields:
{
"status": "success",
"message": "Image generated successfully",
"output": ["https://example.com/generated-image.jpg"],
"id": 12345,
"meta": {
"prompt": "A beautiful sunset",
"model": "stable-diffusion",
"steps": 20,
"seed": 12345
},
"generationTime": 5.2,
"proxy_links": ["https://cdn.example.com/image.jpg"]
}
You get ALL fields returned by the API, including metadata, generation time, proxy links, and any future fields.
The SDK supports multiple ways to provide images/audio:
import "github.com/modelslab/modelslab-go/pkg/schemas/base"
// URL input
imageURL := "https://example.com/image.jpg"
fileInput := base.FileInput{
URL: &imageURL,
}
// Base64 input
base64Data := "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ..."
fileInput := base.FileInput{
Base64: &base64Data,
}
// File path (for local files)
filePath := "/path/to/image.jpg"
fileInput := base.FileInput{
FilePath: &filePath,
}
Repository: