Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/instal
rmdir samples || true
mkdir samples


python -m pip install --upgrade pip
pip install -e .

Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
**/__pycache__/
**/.speakeasy/temp/
**/.speakeasy/logs/
.env
.env.local
.speakeasy/reports
.venv/
pyrightconfig.json
Expand Down
2,455 changes: 2,050 additions & 405 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
speakeasyVersion: 1.488.0
speakeasyVersion: 1.688.0
sources:
my-source:
sourceNamespace: my-source
sourceRevisionDigest: sha256:c0003dac49c5ef097a7add6c026d46352de355736400b4ac337b907e99f30fde
sourceBlobDigest: sha256:4ead44bcaac5b14a8184f8fcc7512d53a00a5a029b3085c55d7eb331256f1dcc
sourceRevisionDigest: sha256:8935b5fb6c514e645b8521764b8993fc41bae71073b7f0f45d1be51ec1e70ac7
sourceBlobDigest: sha256:a4d8d754f7c313c5ebb51c99f70fff61aae7295a5d270a4289d9602fad16600c
tags:
- latest
- speakeasy-sdk-regen-1739240004
- speakeasy-sdk-regen-1758759959
- v1.0.0
targets:
leonardo-python-sdk:
source: my-source
sourceNamespace: my-source
sourceRevisionDigest: sha256:c0003dac49c5ef097a7add6c026d46352de355736400b4ac337b907e99f30fde
sourceBlobDigest: sha256:4ead44bcaac5b14a8184f8fcc7512d53a00a5a029b3085c55d7eb331256f1dcc
sourceRevisionDigest: sha256:8935b5fb6c514e645b8521764b8993fc41bae71073b7f0f45d1be51ec1e70ac7
sourceBlobDigest: sha256:a4d8d754f7c313c5ebb51c99f70fff61aae7295a5d270a4289d9602fad16600c
codeSamplesNamespace: my-source-python-code-samples
codeSamplesRevisionDigest: sha256:ecf688a971e1f9e4a34ebef8f973e8d86442a51b1d811e50fad073c10498043e
codeSamplesRevisionDigest: sha256:988078b45a11f6099c9acbc857c3039d80905ad87ee0a99aa3843744ab754e76
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
122 changes: 80 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ Rest Endpoints: Leonardo.Ai API OpenAPI specification.
>
> Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.

The SDK can be installed with either *pip* or *poetry* package managers.
The SDK can be installed with *uv*, *pip*, or *poetry* package managers.

### uv

*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.

```bash
uv add Leonardo-Ai-SDK
```

### PIP

Expand Down Expand Up @@ -103,6 +111,7 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
# Synchronous Example
from leonardo_ai_sdk import LeonardoAiSDK


with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand All @@ -117,13 +126,15 @@ with LeonardoAiSDK(

</br>

The same SDK client can also be used to make asychronous requests by importing asyncio.
The same SDK client can also be used to make asynchronous requests by importing asyncio.

```python
# Asynchronous Example
import asyncio
from leonardo_ai_sdk import LeonardoAiSDK

async def main():

async with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand All @@ -145,89 +156,92 @@ asyncio.run(main())
<details open>
<summary>Available methods</summary>

### [dataset](docs/sdks/dataset/README.md)
### [ThreeDModelAssets](docs/sdks/threedmodelassets/README.md)

* [delete3_d_model_by_id](docs/sdks/threedmodelassets/README.md#delete3_d_model_by_id) - Delete 3D Model by ID
* [get3_d_model_by_id](docs/sdks/threedmodelassets/README.md#get3_d_model_by_id) - Get 3D Model by ID
* [get3_d_models_by_user_id](docs/sdks/threedmodelassets/README.md#get3_d_models_by_user_id) - Get 3D models by user ID
* [upload_model_asset](docs/sdks/threedmodelassets/README.md#upload_model_asset) - Upload 3D Model

### [Dataset](docs/sdks/dataset/README.md)

* [create_dataset](docs/sdks/dataset/README.md#create_dataset) - Create a Dataset
* [delete_dataset_by_id](docs/sdks/dataset/README.md#delete_dataset_by_id) - Delete a Single Dataset by ID
* [get_dataset_by_id](docs/sdks/dataset/README.md#get_dataset_by_id) - Get a Single Dataset by ID
* [upload_dataset_image](docs/sdks/dataset/README.md#upload_dataset_image) - Upload dataset image
* [upload_dataset_image_from_gen](docs/sdks/dataset/README.md#upload_dataset_image_from_gen) - Upload a Single Generated Image to a Dataset

### [elements](docs/sdks/elements/README.md)
### [Elements](docs/sdks/elements/README.md)

* [create_element](docs/sdks/elements/README.md#create_element) - Train a Custom Element
* [delete_element_by_id](docs/sdks/elements/README.md#delete_element_by_id) - Delete a Single Custom Element by ID
* [get_custom_elements_by_user_id](docs/sdks/elements/README.md#get_custom_elements_by_user_id) - Get a list of Custom Elements by User ID
* [get_element_by_id](docs/sdks/elements/README.md#get_element_by_id) - Get a Single Custom Element by ID
* [list_elements](docs/sdks/elements/README.md#list_elements) - List Elements

### [image](docs/sdks/image/README.md)
### [Image](docs/sdks/image/README.md)

* [create_generation](docs/sdks/image/README.md#create_generation) - Create a Generation of Images
* [delete_generation_by_id](docs/sdks/image/README.md#delete_generation_by_id) - Delete a Single Generation
* [get_generation_by_id](docs/sdks/image/README.md#get_generation_by_id) - Get a Single Generation
* [get_generations_by_user_id](docs/sdks/image/README.md#get_generations_by_user_id) - Get generations by user ID

### [init_images](docs/sdks/initimages/README.md)
### [InitImages](docs/sdks/initimages/README.md)

* [delete_init_image_by_id](docs/sdks/initimages/README.md#delete_init_image_by_id) - Delete init image
* [get_init_image_by_id](docs/sdks/initimages/README.md#get_init_image_by_id) - Get single init image
* [upload_canvas_init_image](docs/sdks/initimages/README.md#upload_canvas_init_image) - Upload Canvas Editor init and mask image
* [upload_init_image](docs/sdks/initimages/README.md#upload_init_image) - Upload init image


### [models](docs/sdks/models/README.md)
### [Models](docs/sdks/models/README.md)

* [create_model](docs/sdks/models/README.md#create_model) - Train a Custom Model
* [delete_model_by_id](docs/sdks/models/README.md#delete_model_by_id) - Delete a Single Custom Model by ID
* [get_custom_models_by_user_id](docs/sdks/models/README.md#get_custom_models_by_user_id) - Get a list of Custom Models by User ID
* [get_model_by_id](docs/sdks/models/README.md#get_model_by_id) - Get a Single Custom Model by ID
* [list_platform_models](docs/sdks/models/README.md#list_platform_models) - List Platform Models

### [motion](docs/sdks/motion/README.md)
### [Motion](docs/sdks/motion/README.md)

* [create_image_to_video_generation](docs/sdks/motion/README.md#create_image_to_video_generation) - Create a video generation from an image
* [create_svd_motion_generation](docs/sdks/motion/README.md#create_svd_motion_generation) - Create SVD Motion Generation
* [create_text_to_video_generation](docs/sdks/motion/README.md#create_text_to_video_generation) - Create a video generation from a text prompt
* [create_video_upscale](docs/sdks/motion/README.md#create_video_upscale) - Upscale a generated video

### [pricing_calculator](docs/sdks/pricingcalculator/README.md)
### [PricingCalculator](docs/sdks/pricingcalculator/README.md)

* [pricing_calculator](docs/sdks/pricingcalculator/README.md#pricing_calculator) - Calculating API Cost

### [prompt](docs/sdks/prompt/README.md)
### [Prompt](docs/sdks/prompt/README.md)

* [prompt_improve](docs/sdks/prompt/README.md#prompt_improve) - Improve a Prompt
* [prompt_random](docs/sdks/prompt/README.md#prompt_random) - Generate a Random prompt

### [realtime_canvas](docs/sdks/realtimecanvas/README.md)
### [RealtimeCanvas](docs/sdks/realtimecanvas/README.md)

* [create_lcm_generation](docs/sdks/realtimecanvas/README.md#create_lcm_generation) - Create LCM Generation
* [perform_alchemy_upscale_lcm](docs/sdks/realtimecanvas/README.md#perform_alchemy_upscale_lcm) - Perform Alchemy Upscale on a LCM image
* [perform_inpainting_lcm](docs/sdks/realtimecanvas/README.md#perform_inpainting_lcm) - Perform inpainting on a LCM image
* [perform_instant_refine](docs/sdks/realtimecanvas/README.md#perform_instant_refine) - Perform instant refine on a LCM image

### [texture](docs/sdks/texture/README.md)
### [Texture](docs/sdks/texture/README.md)

* [create_texture_generation](docs/sdks/texture/README.md#create_texture_generation) - Create Texture Generation
* [delete_texture_generation_by_id](docs/sdks/texture/README.md#delete_texture_generation_by_id) - Delete Texture Generation by ID
* [get_texture_generation_by_id](docs/sdks/texture/README.md#get_texture_generation_by_id) - Get Texture Generation by ID
* [get_texture_generations_by_model_id](docs/sdks/texture/README.md#get_texture_generations_by_model_id) - Get texture generations by 3D Model ID

### [three_d_model_assets](docs/sdks/threedmodelassets/README.md)

* [delete3_d_model_by_id](docs/sdks/threedmodelassets/README.md#delete3_d_model_by_id) - Delete 3D Model by ID
* [get3_d_model_by_id](docs/sdks/threedmodelassets/README.md#get3_d_model_by_id) - Get 3D Model by ID
* [get3_d_models_by_user_id](docs/sdks/threedmodelassets/README.md#get3_d_models_by_user_id) - Get 3D models by user ID
* [upload_model_asset](docs/sdks/threedmodelassets/README.md#upload_model_asset) - Upload 3D Model

### [user](docs/sdks/user/README.md)
### [User](docs/sdks/user/README.md)

* [get_user_self](docs/sdks/user/README.md#get_user_self) - Get user information

### [variation](docs/sdks/variation/README.md)
### [Variation](docs/sdks/variation/README.md)

* [create_universal_upscaler_job](docs/sdks/variation/README.md#create_universal_upscaler_job) - Create using Universal Upscaler
* [create_variation_no_bg](docs/sdks/variation/README.md#create_variation_no_bg) - Create no background
* [create_variation_unzoom](docs/sdks/variation/README.md#create_variation_unzoom) - Create unzoom
* [create_variation_upscale](docs/sdks/variation/README.md#create_variation_upscale) - Create upscale
* [get_motion_variation_by_id](docs/sdks/variation/README.md#get_motion_variation_by_id) - Get motion variation by ID
* [get_variation_by_id](docs/sdks/variation/README.md#get_variation_by_id) - Get variation by ID

</details>
Expand All @@ -249,6 +263,7 @@ To change the default retry strategy for a single API call, simply provide a `Re
from leonardo_ai_sdk import LeonardoAiSDK
from leonardo_ai_sdk.utils import BackoffStrategy, RetryConfig


with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand All @@ -268,6 +283,7 @@ If you'd like to override the default retry strategy for all operations that sup
from leonardo_ai_sdk import LeonardoAiSDK
from leonardo_ai_sdk.utils import BackoffStrategy, RetryConfig


with LeonardoAiSDK(
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
Expand All @@ -286,29 +302,22 @@ with LeonardoAiSDK(
<!-- Start Error Handling [errors] -->
## Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.

By default, an API error will raise a errors.SDKError exception, which has the following properties:
[`LeonardoAiSDKError`](./src/leonardo_ai_sdk/models/errors/leonardoaisdkerror.py) is the base class for all HTTP error responses. It has the following properties:

| Property | Type | Description |
|-----------------|------------------|-----------------------|
| `.status_code` | *int* | The HTTP status code |
| `.message` | *str* | The error message |
| `.raw_response` | *httpx.Response* | The raw HTTP response |
| `.body` | *str* | The response content |

When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `delete_init_image_by_id_async` method may raise the following exceptions:

| Error Type | Status Code | Content Type |
| --------------- | ----------- | ------------ |
| errors.SDKError | 4XX, 5XX | \*/\* |
| Property | Type | Description |
| ------------------ | ---------------- | ------------------------------------------------------ |
| `err.message` | `str` | Error message |
| `err.status_code` | `int` | HTTP response status code eg `404` |
| `err.headers` | `httpx.Headers` | HTTP response headers |
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
| `err.raw_response` | `httpx.Response` | Raw HTTP response |

### Example

```python
from leonardo_ai_sdk import LeonardoAiSDK
from leonardo_ai_sdk.models import errors


with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand All @@ -322,10 +331,35 @@ with LeonardoAiSDK(
# Handle response
print(res.object)

except errors.SDKError as e:
# handle exception
raise(e)

except errors.LeonardoAiSDKError as e:
# The base class for HTTP error responses
print(e.message)
print(e.status_code)
print(e.body)
print(e.headers)
print(e.raw_response)

```

### Error Classes
**Primary error:**
* [`LeonardoAiSDKError`](./src/leonardo_ai_sdk/models/errors/leonardoaisdkerror.py): The base class for HTTP error responses.

<details><summary>Less common errors (5)</summary>

<br />

**Network errors:**
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.


**Inherit from [`LeonardoAiSDKError`](./src/leonardo_ai_sdk/models/errors/leonardoaisdkerror.py)**:
* [`ResponseValidationError`](./src/leonardo_ai_sdk/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.

</details>
<!-- End Error Handling [errors] -->


Expand Down Expand Up @@ -418,10 +452,11 @@ s = LeonardoAiSDK(async_client=CustomClient(httpx.AsyncClient()))

### Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
```python
from leonardo_ai_sdk import LeonardoAiSDK


with LeonardoAiSDK(
server_url="https://cloud.leonardo.ai/api/rest/v1",
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
Expand Down Expand Up @@ -454,6 +489,7 @@ To authenticate with the API the `bearer_auth` parameter must be set when initia
```python
from leonardo_ai_sdk import LeonardoAiSDK


with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand All @@ -478,6 +514,7 @@ The `LeonardoAiSDK` class implements the context manager protocol and registers
```python
from leonardo_ai_sdk import LeonardoAiSDK
def main():

with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand All @@ -486,6 +523,7 @@ def main():

# Or when using async:
async def amain():

async with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1326,4 +1326,14 @@ Based on:
### Generated
- [python v6.5.1] .
### Releases
- [PyPI v6.5.1] https://pypi.org/project/Leonardo-Ai-SDK/6.5.1 - .
- [PyPI v6.5.1] https://pypi.org/project/Leonardo-Ai-SDK/6.5.1 - .

## 2026-01-19 00:32:27
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.688.0 (2.796.4) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v6.6.0] .
### Releases
- [PyPI v6.6.0] https://pypi.org/project/Leonardo-Ai-SDK/6.6.0 - .
5 changes: 4 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Synchronous Example
from leonardo_ai_sdk import LeonardoAiSDK


with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand All @@ -17,13 +18,15 @@ with LeonardoAiSDK(

</br>

The same SDK client can also be used to make asychronous requests by importing asyncio.
The same SDK client can also be used to make asynchronous requests by importing asyncio.

```python
# Asynchronous Example
import asyncio
from leonardo_ai_sdk import LeonardoAiSDK

async def main():

async with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as las_client:
Expand Down
4 changes: 2 additions & 2 deletions docs/models/operations/createdatasetrequestbody.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Query parameters to be provided in the request body as a JSON object

| Field | Type | Required | Description |
| ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ |
| `name` | *str* | :heavy_check_mark: | The name of the dataset. |
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | A description for the dataset. |
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | A description for the dataset. |
| `name` | *str* | :heavy_check_mark: | The name of the dataset. |
Loading
Loading