(models)
- create_model - Train a Custom Model
- delete_model_by_id - Delete a Single Custom Model by ID
- get_model_by_id - Get a Single Custom Model by ID
- list_platform_models - List Platform Models
This endpoint will train a new custom model
from leonardo_ai_sdk import LeonardoAiSDK
with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as leonardo_ai_sdk:
res = leonardo_ai_sdk.models.create_model(request={
"dataset_id": "<value>",
"instance_prompt": "<value>",
"name": "<value>",
})
assert res.object is not None
# Handle response
print(res.object)
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.CreateModelRequestBody | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
operations.CreateModelResponse
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
This endpoint will delete a specific custom model
from leonardo_ai_sdk import LeonardoAiSDK
with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as leonardo_ai_sdk:
res = leonardo_ai_sdk.models.delete_model_by_id(id="<id>")
assert res.object is not None
# Handle response
print(res.object)
Parameter | Type | Required | Description |
---|---|---|---|
id |
str | ✔️ | The ID of the model to delete. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
operations.DeleteModelByIDResponse
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
This endpoint gets the specific custom model
from leonardo_ai_sdk import LeonardoAiSDK
with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as leonardo_ai_sdk:
res = leonardo_ai_sdk.models.get_model_by_id(id="<id>")
assert res.object is not None
# Handle response
print(res.object)
Parameter | Type | Required | Description |
---|---|---|---|
id |
str | ✔️ | The ID of the custom model to return. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
operations.GetModelByIDResponse
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
Get a list of public Platform Models available for use with generations.
from leonardo_ai_sdk import LeonardoAiSDK
with LeonardoAiSDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as leonardo_ai_sdk:
res = leonardo_ai_sdk.models.list_platform_models()
assert res.object is not None
# Handle response
print(res.object)
Parameter | Type | Required | Description |
---|---|---|---|
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
operations.ListPlatformModelsResponse
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |