Skip to content

shamspias/reve-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

reve-go

Go Reference Go Report Card License: MIT

An unofficial Go SDK for the Reve Image Generation API - a powerful AI platform known for stunning aesthetics, accurate text rendering, and natural-language image edits.

Features

  • 🎨 Create - Generate images from text descriptions
  • ✏️ Edit - Modify images with text instructions
  • πŸ”„ Remix - Combine multiple images with prompts
  • 🌐 Proxy Support - HTTP, HTTPS, SOCKS5 proxies
  • πŸ” Auto Retry - Exponential backoff with jitter
  • πŸ“¦ Batch Processing - Concurrent operations
  • πŸ’° Cost Estimation - Estimate before you spend

Installation

go get github.com/shamspias/reve-go

Requires Go 1.25+

Quick Start

package main

import (
	"context"
	"log"
	"os"

	reve "github.com/shamspias/reve-go"
)

func main() {
	client := reve.NewClient(os.Getenv("REVE_API_KEY"))

	result, err := client.Images.Create(context.Background(), &reve.CreateParams{
		Prompt: "A beautiful mountain landscape at sunset",
	})
	if err != nil {
		log.Fatal(err)
	}

	result.SaveTo("landscape.png")
	log.Printf("Saved! Credits used: %d", result.CreditsUsed)
}

Documentation

Client Configuration

// Basic
client := reve.NewClient(apiKey)

// With options
client := reve.NewClient(apiKey,
reve.WithTimeout(60*time.Second),
reve.WithRetry(5, time.Second, 30*time.Second),
reve.WithDebug(true),
)

Proxy Support

// HTTP Proxy
client := reve.NewClient(apiKey,
reve.WithHTTPProxy("http://proxy:8080"),
)

// SOCKS5 Proxy
client := reve.NewClient(apiKey,
reve.WithSOCKS5Proxy("127.0.0.1:1080", "user", "pass"),
)

// Environment variables (HTTP_PROXY, HTTPS_PROXY)
client := reve.NewClient(apiKey,
reve.WithProxyFromEnvironment(),
)

Create Images

result, err := client.Images.Create(ctx, &reve.CreateParams{
Prompt:          "A cyberpunk cityscape",
AspectRatio:     reve.Ratio16x9,
TestTimeScaling: 2,
Postprocess:     []reve.Postprocess{reve.Upscale(2)},
})

Edit Images

img, _ := reve.NewImageFromFile("photo.jpg")

result, err := client.Images.Edit(ctx, &reve.EditParams{
Instruction:    "Convert to watercolor painting",
ReferenceImage: img.Base64(),
Version:        reve.VersionLatestFast, // 5 credits
})

Remix Images

style, _ := reve.NewImageFromFile("style.png")
content, _ := reve.NewImageFromFile("content.png")

result, err := client.Images.Remix(ctx, &reve.RemixParams{
Prompt: fmt.Sprintf("Apply %s to %s", reve.Ref(0), reve.Ref(1)),
ReferenceImages: []string{style.Base64(), content.Base64()},
})

Batch Operations

requests := []*reve.CreateParams{
{Prompt: "A red apple"},
{Prompt: "A green pear"},
}

results := client.Images.BatchCreate(ctx, requests, &reve.BatchConfig{
Concurrency: 3,
})

fmt.Printf("Success: %d/%d\n", reve.SuccessCount(results), len(results))

Error Handling

result, err := client.Images.Create(ctx, params)
if err != nil {
var apiErr *transport.APIError
if errors.As(err, &apiErr) {
if apiErr.IsRateLimit() {
// Wait and retry
}
if apiErr.IsInsufficientFunds() {
// Need more credits
}
}
}

Cost Estimation

cost := reve.EstimateCreate(1, nil)
fmt.Println(cost) // "18 credits (~$0.0240)"

cost = reve.EstimateEdit(true, 1, nil) // Fast mode
fmt.Println(cost) // "5 credits (~$0.0067)"

Examples

Run examples with:

REVE_API_KEY=your-key go run examples/basic/main.go
REVE_API_KEY=your-key go run examples/create/main.go
REVE_API_KEY=your-key go run examples/edit/main.go
REVE_API_KEY=your-key go run examples/remix/main.go
REVE_API_KEY=your-key go run examples/batch/main.go
REVE_API_KEY=your-key go run examples/proxy/main.go
REVE_API_KEY=your-key go run examples/error-handling/main.go
REVE_API_KEY=your-key go run examples/complete/main.go

Pricing

Endpoint Credits ~USD
Create 18 $0.024
Edit 30 $0.040
Edit Fast 5 $0.007
Remix 30 $0.040
Remix Fast 5 $0.007

Contributing

  1. Fork the repo
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add feature')
  4. Push (git push origin feature/amazing)
  5. Open Pull Request

License

MIT License - see LICENSE

Disclaimer

This is an unofficial SDK, not affiliated with Reve.