(generate)
Generate images from text prompts.
from livepeer_ai import Livepeer
with Livepeer(
http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:
res = livepeer.generate.text_to_image(request={
"prompt": "<value>",
"model_id": "",
"loras": "",
"height": 576,
"width": 1024,
"guidance_scale": 7.5,
"negative_prompt": "",
"safety_check": True,
"num_inference_steps": 50,
"num_images_per_prompt": 1,
})
assert res.image_response is not None
# Handle response
print(res.image_response)
operations.GenTextToImageResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Apply image transformations to a provided image.
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"),
},
"model_id": "",
"loras": "",
"strength": 0.8,
"guidance_scale": 7.5,
"image_guidance_scale": 1.5,
"negative_prompt": "",
"safety_check": True,
"num_inference_steps": 100,
"num_images_per_prompt": 1,
})
assert res.image_response is not None
# Handle response
print(res.image_response)
operations.GenImageToImageResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Generate a video from a provided image.
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"),
},
"model_id": "",
"height": 576,
"width": 1024,
"fps": 6,
"motion_bucket_id": 127,
"noise_aug_strength": 0.02,
"safety_check": True,
"num_inference_steps": 25,
})
assert res.video_response is not None
# Handle response
print(res.video_response)
operations.GenImageToVideoResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Upscale an image by increasing its resolution.
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"),
},
"model_id": "",
"safety_check": True,
"num_inference_steps": 75,
})
assert res.image_response is not None
# Handle response
print(res.image_response)
operations.GenUpscaleResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Transcribe audio files to text.
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"),
},
"model_id": "",
"return_timestamps": "true",
})
assert res.text_response is not None
# Handle response
print(res.text_response)
operations.GenAudioToTextResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401, 413, 415 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Segment objects in an image.
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"),
},
"model_id": "",
"multimask_output": True,
"return_logits": True,
"normalize_coords": True,
})
assert res.masks_response is not None
# Handle response
print(res.masks_response)
operations.GenSegmentAnything2Response
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Generate text using a language model.
from livepeer_ai import Livepeer
with Livepeer(
http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:
res = livepeer.generate.llm(request={
"messages": [
],
"model": "",
"temperature": 0.7,
"max_tokens": 256,
"top_p": 1,
"top_k": -1,
"stream": False,
})
assert res.llm_response is not None
# Handle response
print(res.llm_response)
operations.GenLLMResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Transform image files to text.
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"),
},
"prompt": "",
"model_id": "",
})
assert res.image_to_text_response is not None
# Handle response
print(res.image_to_text_response)
operations.GenImageToTextResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401, 413 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Apply transformations to a live video streamed to the returned endpoints.
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",
"control_url": "",
"events_url": "",
"model_id": "",
})
assert res.live_video_to_video_response is not None
# Handle response
print(res.live_video_to_video_response)
operations.GenLiveVideoToVideoResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |
Generate a text-to-speech audio file based on the provided text input and speaker description.
from livepeer_ai import Livepeer
with Livepeer(
http_bearer="<YOUR_BEARER_TOKEN_HERE>",
) as livepeer:
res = livepeer.generate.text_to_speech(request={
"model_id": "",
"text": "",
"description": "A male speaker delivers a slightly expressive and animated speech with a moderate speed and pitch.",
})
assert res.audio_response is not None
# Handle response
print(res.audio_response)
operations.GenTextToSpeechResponse
Error Type |
Status Code |
Content Type |
errors.HTTPError |
400, 401 |
application/json |
errors.HTTPValidationError |
422 |
application/json |
errors.HTTPError |
500 |
application/json |
errors.SDKError |
4XX, 5XX |
*/* |