Skip to content

Latest commit

 

History

History
471 lines (318 loc) · 23.6 KB

README.md

File metadata and controls

471 lines (318 loc) · 23.6 KB

Generate

(generate)

Overview

Available Operations

text_to_image

Generate images from text prompts.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.text_to_image(request={
        "prompt": "<value>",
    })

    assert res.image_response is not None

    # Handle response
    print(res.image_response)

Parameters

Parameter Type Required Description
request components.TextToImageParams ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenTextToImageResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

image_to_image

Apply image transformations to a provided image.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.image_to_image(request={
        "prompt": "<value>",
        "image": {
            "file_name": "example.file",
            "content": open("example.file", "rb"),
        },
    })

    assert res.image_response is not None

    # Handle response
    print(res.image_response)

Parameters

Parameter Type Required Description
request components.BodyGenImageToImage ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenImageToImageResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

image_to_video

Generate a video from a provided image.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.image_to_video(request={
        "image": {
            "file_name": "example.file",
            "content": open("example.file", "rb"),
        },
    })

    assert res.video_response is not None

    # Handle response
    print(res.video_response)

Parameters

Parameter Type Required Description
request components.BodyGenImageToVideo ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenImageToVideoResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

upscale

Upscale an image by increasing its resolution.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.upscale(request={
        "prompt": "<value>",
        "image": {
            "file_name": "example.file",
            "content": open("example.file", "rb"),
        },
    })

    assert res.image_response is not None

    # Handle response
    print(res.image_response)

Parameters

Parameter Type Required Description
request components.BodyGenUpscale ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenUpscaleResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

audio_to_text

Transcribe audio files to text.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.audio_to_text(request={
        "audio": {
            "file_name": "example.file",
            "content": open("example.file", "rb"),
        },
    })

    assert res.text_response is not None

    # Handle response
    print(res.text_response)

Parameters

Parameter Type Required Description
request components.BodyGenAudioToText ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenAudioToTextResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 413, 415, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

segment_anything2

Segment objects in an image.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.segment_anything2(request={
        "image": {
            "file_name": "example.file",
            "content": open("example.file", "rb"),
        },
    })

    assert res.masks_response is not None

    # Handle response
    print(res.masks_response)

Parameters

Parameter Type Required Description
request components.BodyGenSegmentAnything2 ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenSegmentAnything2Response

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

llm

Generate text using a language model.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.llm(request={
        "messages": [
            {
                "role": "<value>",
                "content": "<value>",
            },
        ],
    })

    assert res.llm_response is not None

    # Handle response
    print(res.llm_response)

Parameters

Parameter Type Required Description
request components.LLMRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenLLMResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

image_to_text

Transform image files to text.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.image_to_text(request={
        "image": {
            "file_name": "example.file",
            "content": open("example.file", "rb"),
        },
    })

    assert res.image_to_text_response is not None

    # Handle response
    print(res.image_to_text_response)

Parameters

Parameter Type Required Description
request components.BodyGenImageToText ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenImageToTextResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 413, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

live_video_to_video

Apply transformations to a live video streamed to the returned endpoints.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.live_video_to_video(request={
        "subscribe_url": "https://soulful-lava.org/",
        "publish_url": "https://vain-tabletop.biz",
    })

    assert res.live_video_to_video_response is not None

    # Handle response
    print(res.live_video_to_video_response)

Parameters

Parameter Type Required Description
request components.LiveVideoToVideoParams ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenLiveVideoToVideoResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

text_to_speech

Generate a text-to-speech audio file based on the provided text input and speaker description.

Example Usage

from livepeer_ai import Livepeer

with Livepeer(
    http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:

    res = livepeer.generate.text_to_speech(request={})

    assert res.audio_response is not None

    # Handle response
    print(res.audio_response)

Parameters

Parameter Type Required Description
request components.TextToSpeechParams ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GenTextToSpeechResponse

Errors

Error Type Status Code Content Type
errors.HTTPError 400, 401, 500 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*