Client for Leap
Project description
leap-python-sdk
The Official Leap API
Requirements
Python >=3.7
Installing
pip install leap-python-sdk==1.1.4
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
generate_response = leap.images.generate(
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(generate_response.body)
pprint(generate_response.body["id"])
pprint(generate_response.body["created_at"])
pprint(generate_response.body["prompt"])
pprint(generate_response.body["negative_prompt"])
pprint(generate_response.body["seed"])
pprint(generate_response.body["width"])
pprint(generate_response.body["height"])
pprint(generate_response.body["prompt_strength"])
pprint(generate_response.body["number_of_images"])
pprint(generate_response.body["state"])
pprint(generate_response.body["status"])
pprint(generate_response.body["steps"])
pprint(generate_response.body["images"])
pprint(generate_response.body["model_id"])
pprint(generate_response.body["upscaling_option"])
pprint(generate_response.headers)
pprint(generate_response.status)
pprint(generate_response.round_trip_time)
except ApiException as e:
print("Exception when calling ImagesApi.generate: %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
generate_response = await leap.images.agenerate(
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(generate_response.body)
pprint(generate_response.body["id"])
pprint(generate_response.body["created_at"])
pprint(generate_response.body["prompt"])
pprint(generate_response.body["negative_prompt"])
pprint(generate_response.body["seed"])
pprint(generate_response.body["width"])
pprint(generate_response.body["height"])
pprint(generate_response.body["prompt_strength"])
pprint(generate_response.body["number_of_images"])
pprint(generate_response.body["state"])
pprint(generate_response.body["status"])
pprint(generate_response.body["steps"])
pprint(generate_response.body["images"])
pprint(generate_response.body["model_id"])
pprint(generate_response.body["upscaling_option"])
pprint(generate_response.headers)
pprint(generate_response.status)
pprint(generate_response.round_trip_time)
except ApiException as e:
print("Exception when calling ImagesApi.generate: %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 |
---|---|---|---|
Images | generate | POST /api/v1/images/models/{modelId}/inferences | Generate an Image |
Images | delete | DELETE /api/v1/images/models/{modelId}/inferences/{inferenceId} | Delete Image Job |
Images | find_one | GET /api/v1/images/models/{modelId}/inferences/{inferenceId} | Get Single Image Job |
Images | list_all | GET /api/v1/images/models/{modelId}/inferences | List All Image Jobs |
Image Models | delete_model | DELETE /api/v2/images/models/{modelId} | Delete a Model |
Image Models | get_model | GET /api/v2/images/models/{modelId} | Get a Single Model |
Image Models | list_all_models | GET /api/v2/images/models | List All Models |
Image Models | train_model | POST /api/v2/images/models/new | Train Model |
Music | find_one | GET /api/v1/music/{inferenceId} | Get a Music Generation Job |
Music | generate | POST /api/v1/music | Generate Music |
Music | list_all | GET /api/v1/music | List Music Generation Jobs |
Documentation For Models
- CreateAndTrainModelDto
- CreateAndTrainModelDtoImageSampleFiles
- CreateAndTrainModelDtoImageSampleUrls
- CreateInferenceDto
- CreateMusicgenInferenceDto
- InferenceEntity
- 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.4.tar.gz
(64.9 kB
view details)
Built Distribution
File details
Details for the file leap_python_sdk-1.1.4.tar.gz
.
File metadata
- Download URL: leap_python_sdk-1.1.4.tar.gz
- Upload date:
- Size: 64.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1e4e0894f616e3589553a7e3fa7e0577e64ea53e1ae94124816d2bd5ce31e19 |
|
MD5 | fe600f90d0e73057d1f1abb8dbe97ef3 |
|
BLAKE2b-256 | 02f56a4907514ca9826717a1eeab0279df4e582f9bb3cebc3d758072125f90d8 |
File details
Details for the file leap_python_sdk-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: leap_python_sdk-1.1.4-py3-none-any.whl
- Upload date:
- Size: 148.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 785b5b96e45fad33f05f24010827f227ebce81a5ab51d7ac25ea4973951a1b64 |
|
MD5 | e254f22af70971d4713f218cd5e2de59 |
|
BLAKE2b-256 | 66e7f025aeaa5120cabe6d71766adec7016925867f87a9caef787be5f77a7a91 |