Skip to content

Latest commit

 

History

History
404 lines (312 loc) · 22.8 KB

README.md

File metadata and controls

404 lines (312 loc) · 22.8 KB

Generate

(Generate)

Overview

Operations related to AI generate api

Available Operations

TextToImage

Generate images from text prompts.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GenTextToImageResponse, error

Errors

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 /

ImageToImage

Apply image transformations to a provided image.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GenImageToImageResponse, error

Errors

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 /

ImageToVideo

Generate a video from a provided image.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GenImageToVideoResponse, error

Errors

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

Upscale an image by increasing its resolution.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GenUpscaleResponse, error

Errors

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 /

AudioToText

Transcribe audio files to text.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GenAudioToTextResponse, error

Errors

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 /

SegmentAnything2

Segment objects in an image.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GenSegmentAnything2Response, error

Errors

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 /