https://github.com/novitalabs/golang-sdk
Golang SDK for Stable Diffusion API (Txt2Img/Img2Img/LoRA/ControlNet/VAE).
https://github.com/novitalabs/golang-sdk
controlnet lora stable-diffusion vae
Last synced: 2 months ago
JSON representation
Golang SDK for Stable Diffusion API (Txt2Img/Img2Img/LoRA/ControlNet/VAE).
- Host: GitHub
- URL: https://github.com/novitalabs/golang-sdk
- Owner: novitalabs
- License: mit
- Created: 2023-09-26T14:11:28.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-21T04:10:37.000Z (almost 2 years ago)
- Last Synced: 2024-01-05T04:46:57.667Z (almost 2 years ago)
- Topics: controlnet, lora, stable-diffusion, vae
- Language: Go
- Homepage: https://novita.ai
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Novita AI Golang SDK
This SDK is based on the official [API documentation](https://docs.novita.ai/).
**Join our discord server for help**
[](https://discord.gg/Mqx7nWYzDF)
## Installation
```bash
go get -u github.com/novitalabs/golang-sdk
```## Quick Start
**Get api key refer to [https://novita.ai/get-started/](https://novita.ai/get-started/)**
```golang
package mainimport (
"context"
"fmt"
"time""github.com/novitalabs/golang-sdk/request"
"github.com/novitalabs/golang-sdk/types"
)func main() {
// Get your API key refer to https://novita.ai/get-started/ .
const apiKey = "Your-API-Key"
client, err := request.NewClient(apiKey)
if err != nil {
fmt.Printf("new client failed, %v\n", err)
return
}
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3)
defer cancel()
txt2ImgReq := types.NewTxt2ImgRequest("a dog flying in the sky", "", "AnythingV5_v5PrtRE.safetensors")
res, err := client.SyncTxt2img(ctx, txt2ImgReq,
request.WithSaveImage("out", 0777, func(taskId string, fileIndex int, fileName string) string {
return "test_txt2img_sync.png"
}))
if err != nil {
fmt.Printf("generate image failed, %v\n", err)
return
}
for _, s3Url := range res.Data.Imgs {
fmt.Printf("generate image url: %v\n", s3Url)
}
}
```## Examples
### Txt2Img with LoRA
Refer to [./example/lora/main.go](./example/lora/main.go)
### Model Search
Refer to [./example/model_search/main.go](./example/model_search/main.go)
### ControlNet QRCode
Refer to [./example/qrcode/main.go](./example/qrcode/main.go)
## Testing
```
API_KEY= go test ./...
```