(Generate)
Operations related to AI generate api
- TextToImage - Text To Image
- ImageToImage - Image To Image
- ImageToVideo - Image To Video
- Upscale - Upscale
- AudioToText - Audio To Text
- SegmentAnything2 - Segment Anything 2
Generate images from text prompts.
package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"context"
"github.com/livepeer/livepeer-go/models/components"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Generate.TextToImage(ctx, components.TextToImageParams{
Prompt: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res.ImageResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.TextToImageParams | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GenTextToImageResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.GenTextToImageResponseBody | 400 | application/json |
sdkerrors.GenTextToImageGenerateResponseBody | 401 | application/json |
sdkerrors.GenTextToImageGenerateResponseResponseBody | 422 | application/json |
sdkerrors.GenTextToImageGenerateResponse500ResponseBody | 500 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Apply image transformations to a provided image.
package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"os"
"context"
"github.com/livepeer/livepeer-go/models/components"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
content, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
ctx := context.Background()
res, err := s.Generate.ImageToImage(ctx, components.BodyGenImageToImage{
Prompt: "<value>",
Image: components.Image{
FileName: "example.file",
Content: content,
},
})
if err != nil {
log.Fatal(err)
}
if res.ImageResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.BodyGenImageToImage | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GenImageToImageResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.GenImageToImageResponseBody | 400 | application/json |
sdkerrors.GenImageToImageGenerateResponseBody | 401 | application/json |
sdkerrors.GenImageToImageGenerateResponseResponseBody | 422 | application/json |
sdkerrors.GenImageToImageGenerateResponse500ResponseBody | 500 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Generate a video from a provided image.
package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"os"
"context"
"github.com/livepeer/livepeer-go/models/components"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
content, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
ctx := context.Background()
res, err := s.Generate.ImageToVideo(ctx, components.BodyGenImageToVideo{
Image: components.BodyGenImageToVideoImage{
FileName: "example.file",
Content: content,
},
})
if err != nil {
log.Fatal(err)
}
if res.VideoResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.BodyGenImageToVideo | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GenImageToVideoResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.GenImageToVideoResponseBody | 400 | application/json |
sdkerrors.GenImageToVideoGenerateResponseBody | 401 | application/json |
sdkerrors.GenImageToVideoGenerateResponseResponseBody | 422 | application/json |
sdkerrors.GenImageToVideoGenerateResponse500ResponseBody | 500 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Upscale an image by increasing its resolution.
package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"os"
"context"
"github.com/livepeer/livepeer-go/models/components"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
content, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
ctx := context.Background()
res, err := s.Generate.Upscale(ctx, components.BodyGenUpscale{
Prompt: "<value>",
Image: components.BodyGenUpscaleImage{
FileName: "example.file",
Content: content,
},
})
if err != nil {
log.Fatal(err)
}
if res.ImageResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.BodyGenUpscale | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GenUpscaleResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.GenUpscaleResponseBody | 400 | application/json |
sdkerrors.GenUpscaleGenerateResponseBody | 401 | application/json |
sdkerrors.GenUpscaleGenerateResponseResponseBody | 422 | application/json |
sdkerrors.GenUpscaleGenerateResponse500ResponseBody | 500 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Transcribe audio files to text.
package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"os"
"context"
"github.com/livepeer/livepeer-go/models/components"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
content, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
ctx := context.Background()
res, err := s.Generate.AudioToText(ctx, components.BodyGenAudioToText{
Audio: components.Audio{
FileName: "example.file",
Content: content,
},
})
if err != nil {
log.Fatal(err)
}
if res.TextResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.BodyGenAudioToText | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GenAudioToTextResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.GenAudioToTextResponseBody | 400 | application/json |
sdkerrors.GenAudioToTextGenerateResponseBody | 401 | application/json |
sdkerrors.GenAudioToTextGenerateResponseResponseBody | 413 | application/json |
sdkerrors.GenAudioToTextGenerateResponse422ResponseBody | 422 | application/json |
sdkerrors.GenAudioToTextGenerateResponse500ResponseBody | 500 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Segment objects in an image.
package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"os"
"context"
"github.com/livepeer/livepeer-go/models/components"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
content, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
ctx := context.Background()
res, err := s.Generate.SegmentAnything2(ctx, components.BodyGenSegmentAnything2{
Image: components.BodyGenSegmentAnything2Image{
FileName: "example.file",
Content: content,
},
})
if err != nil {
log.Fatal(err)
}
if res.MasksResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.BodyGenSegmentAnything2 | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GenSegmentAnything2Response, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.GenSegmentAnything2ResponseBody | 400 | application/json |
sdkerrors.GenSegmentAnything2GenerateResponseBody | 401 | application/json |
sdkerrors.GenSegmentAnything2GenerateResponseResponseBody | 422 | application/json |
sdkerrors.GenSegmentAnything2GenerateResponse500ResponseBody | 500 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |