Skip to main content

Client for Leap

Project description

leap-python-sdk

PyPI More Info

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

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 hashes)

Uploaded Source

Built Distribution

leap_python_sdk-1.1.4-py3-none-any.whl (148.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page