Client for Leap
Project description
leap-python-sdk
The Official Leap API
Requirements
Python >=3.7
Installing
pip install leap-python-sdk==1.1.3
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
- 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.3.tar.gz
(66.0 kB
view hashes)
Built Distribution
Close
Hashes for leap_python_sdk-1.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 728b744cb07b82da1e6ded91159586adccd106000a76005949d5bd842f8575c1 |
|
MD5 | 6780ab68524e99bb8e629e2715d87926 |
|
BLAKE2b-256 | 65a0b4869d41c1e0dbc805e62d850592100498bcd11b20fe94edd8365ffc8ca1 |