Client for Leap
Project description
leap-python-sdk
The Official Leap API
Requirements
Python >=3.7
Installing
pip install leap-python-sdk==1.1.0
Getting Started
from pprint import pprint
from leap import Leap, ApiException
leap = Leap(
# Defining the host is optional and defaults to https://api.tryleap.ai
# See configuration.py for a list of all supported configuration parameters.
host="https://api.tryleap.ai",
# Configure Bearer authorization (JWT): bearer
access_token="YOUR_BEARER_TOKEN",
)
try:
# Generate an Image
create_response = leap.generate_images.create(
prompt="A photo of an astronaut riding a horse", # required
model_id="26a1a203-3a46-42cb-8cfa-f4de075907d8", # required
negative_prompt="asymmetric, bad hands, bad hair", # optional
steps=50, # optional
width=1024, # optional
height=1024, # optional
number_of_images=1, # optional
prompt_strength=7, # optional
seed=4523184, # optional
webhook_url="string_example", # optional
)
pprint(create_response.body)
pprint(create_response.body["id"])
pprint(create_response.body["created_at"])
pprint(create_response.body["prompt"])
pprint(create_response.body["negative_prompt"])
pprint(create_response.body["seed"])
pprint(create_response.body["width"])
pprint(create_response.body["height"])
pprint(create_response.body["prompt_strength"])
pprint(create_response.body["number_of_images"])
pprint(create_response.body["state"])
pprint(create_response.body["status"])
pprint(create_response.body["steps"])
pprint(create_response.body["images"])
pprint(create_response.body["model_id"])
pprint(create_response.body["upscaling_option"])
pprint(create_response.headers)
pprint(create_response.status)
pprint(create_response.round_trip_time)
except ApiException as e:
print("Exception when calling GenerateImagesApi.create: %s\n" % e)
pprint(e.body)
pprint(e.headers)
pprint(e.status)
pprint(e.reason)
pprint(e.round_trip_time)
Async
async
support is available by prepending a
to any method.
import asyncio
from pprint import pprint
from leap import Leap, ApiException
leap = Leap(
# Defining the host is optional and defaults to https://api.tryleap.ai
# See configuration.py for a list of all supported configuration parameters.
host="https://api.tryleap.ai",
# Configure Bearer authorization (JWT): bearer
access_token="YOUR_BEARER_TOKEN",
)
async def main():
try:
# Generate an Image
create_response = await leap.generate_images.acreate(
prompt="A photo of an astronaut riding a horse", # required
model_id="26a1a203-3a46-42cb-8cfa-f4de075907d8", # required
negative_prompt="asymmetric, bad hands, bad hair", # optional
steps=50, # optional
width=1024, # optional
height=1024, # optional
number_of_images=1, # optional
prompt_strength=7, # optional
seed=4523184, # optional
webhook_url="string_example", # optional
)
pprint(create_response.body)
pprint(create_response.body["id"])
pprint(create_response.body["created_at"])
pprint(create_response.body["prompt"])
pprint(create_response.body["negative_prompt"])
pprint(create_response.body["seed"])
pprint(create_response.body["width"])
pprint(create_response.body["height"])
pprint(create_response.body["prompt_strength"])
pprint(create_response.body["number_of_images"])
pprint(create_response.body["state"])
pprint(create_response.body["status"])
pprint(create_response.body["steps"])
pprint(create_response.body["images"])
pprint(create_response.body["model_id"])
pprint(create_response.body["upscaling_option"])
pprint(create_response.headers)
pprint(create_response.status)
pprint(create_response.round_trip_time)
except ApiException as e:
print("Exception when calling GenerateImagesApi.create: %s\n" % e)
pprint(e.body)
pprint(e.headers)
pprint(e.status)
pprint(e.reason)
pprint(e.round_trip_time)
asyncio.run(main())
Documentation for API Endpoints
All URIs are relative to https://api.tryleap.ai
Tag | Method | HTTP request | Description |
---|---|---|---|
Generate Images | create | POST /api/v1/images/models/{modelId}/inferences | Generate an Image |
Generate Images | find_all | GET /api/v1/images/models/{modelId}/inferences | List All Image Jobs |
Generate Images | find_one | GET /api/v1/images/models/{modelId}/inferences/{inferenceId} | Get Single Image Job |
Generate Images | remove | DELETE /api/v1/images/models/{modelId}/inferences/{inferenceId} | Delete Image Job |
Generate Music | create_audio | POST /api/v1/music | Generate Music |
Generate Music | find_all_audio | GET /api/v1/music | List Music Generation Jobs |
Generate Music | find_one_audio | GET /api/v1/music/{inferenceId} | Get a Music Generation Job |
Train Image Models | delete_model | DELETE /api/v2/images/models/{modelId} | Delete a Model |
Train Image Models | get_model | GET /api/v2/images/models/{modelId} | Get a Single Model |
Train Image Models | list_all_models | GET /api/v2/images/models | List All Models |
Train Image Models | train_model | POST /api/v2/images/models/new | Train Model |
Documentation For Models
- CreateAndTrainModelDto
- CreateAndTrainModelDtoImageSampleFiles
- CreateAndTrainModelDtoImageSampleUrls
- CreateInferenceDto
- CreateMusicgenInferenceDto
- InferenceEntity
- InferenceEntityModelId
- InferenceImageEntity
- InferencesControllerFindAllResponse
- ListModelsV2Response
- ModelV2Entity
- ModelV2EntityImageSamples
- MusicControllerFindAllAudioResponse
- MusicgenInferenceEntity
Author
This Python package is automatically generated by Konfig
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
leap_python_sdk-1.1.0.tar.gz
(65.9 kB
view hashes)
Built Distribution
Close
Hashes for leap_python_sdk-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cc203ea95badc08aaa6b9cc06d57e64fab1c94a8fd1dca9ad7177b5dec21ead |
|
MD5 | 25c71eb740138789a6faaf6685f4993b |
|
BLAKE2b-256 | f0ebdac180a418d43e7b9f63733491aac32e03d8be987c3a4a021ed7ea1d603b |