Skip to content

Runware/sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Runware SDK

The SDK is used to run image inference with the Runware API, powered by the RunWare inference platform. It can be used to generate imaged with text-to-image and image-to-image. It also allows the use of an existing gallery of models or selecting any model or LoRA from the CivitAI gallery.

Get API access

For an API Key and trial credits, Create a free account with Runware

NB: Please keep your API key private

Usage

go get github.com/Runware/sdk-go

Basic image task

import (
    runware "github.com/Runware/sdk-go"
)


func main() {
    sdk, err := runware.NewSDK(picfinder.SDKConfig{
        APIKey:    os.Getenv("RUNWARE_API"),
        KeepAlive: true,
    })
    if err != nil {
        panic(err)
    }

    imagesRes, err := sdk.NewImage(ctx, runware.NewTaskReq{
        PromptText:    "Prompt text",
        NumberResults: 12,
    })
    if err != nil {
        panic(err)
    }
    
    prettyJSON, _ := json.MarshalIndent(imagesRes, "", "  ")
    log.Println(string(prettyJSON), "Count", len(imagesRes.Images))
}

For advanced requests refer to types.go file

Sample

req := runware.NewTaskReq{
    TaskUUID:           "",
    ImageInitiatorUUID: "",
    PromptText:         "",
    NumberResults:      0,
    ModelId:            "",
    SizeId:             0,
    TaskType:           0,
    PromptLanguageId:   nil,
    Offset:             0,
    Lora:               nil,
    ControlNet:         nil,
}

Advanced settings

Context adjustments

By default, all tasks have a 30-second timeout, but sometimes you might want a fast expiry. This can be passed via context

ctx := context.Background()
ctx, cancel := context.WithTimeout(context.Background(), 5000*time.Millisecond)
defer cancel()

imagesRes, err := sdk.NewImage(ctx, picfinder.NewTaskReq{
    PromptText:    "Some prompt text",
    NumberResults: 1,
})

to close this request after 5 seconds.

Custom UUID for Requests

If at some point you need to group your execution your self and you need to do something with them based on your business needs you can pass your own UUID v4 to any sdk request via TaskUUID

Roadmap

  • Add custom handler support for API events

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages