Skip to main content

Models Resource

API methods for models operations.

Methods

create

Create Model Create a new model.

This endpoint creates a new model in the Credo AI model registry.

Method: POST Path: /models

# Create Model
from credoai.models import ModelCreate
data = ModelCreate(
# Add required fields here
)

response = client.models.create(
data=data,
)

Parameters

Request Body: ModelCreate

Responses

201 - Successful Response

422 - Validation Error


list

List Models List all models.

This endpoint retrieves all models with optional pagination. Returns a paginated response with items and pagination metadata.

Method: GET Path: /models

# List Models

response = client.models.list(
)

Parameters

Query Parameters:

ParameterTypeRequiredDescription
page_limitAny-
page_afterAny-

Responses

200 - Successful Response

422 - Validation Error


get

Get Model Get a model by ID.

This endpoint retrieves an existing model by its ID.

Method: GET Path: /models/{model_id}

# Get Model
model_id = "example" # Path parameter

response = client.models.get(
model_id=model_id,
)

Parameters

Path Parameters:

ParameterTypeRequiredDescription
model_idstr-

Responses

200 - Successful Response

422 - Validation Error


update

Update Model Update an existing model.

This endpoint updates an existing model with the provided data. Only the fields provided in the request will be updated.

Method: PATCH Path: /models/{model_id}

# Update Model
from credoai.models import ModelUpdate
model_id = "example" # Path parameter
data = ModelUpdate(
# Add required fields here
)

response = client.models.update(
model_id=model_id,
data=data,
)

Parameters

Path Parameters:

ParameterTypeRequiredDescription
model_idstr-

Request Body: ModelUpdate

Responses

200 - Successful Response

422 - Validation Error


delete

Delete Model Delete a model by ID.

This endpoint deletes an existing model by its ID.

Method: DELETE Path: /models/{model_id}

# Delete Model
model_id = "example" # Path parameter

response = client.models.delete(
model_id=model_id,
)

Parameters

Path Parameters:

ParameterTypeRequiredDescription
model_idstr-

Responses

204 - Successful Response

422 - Validation Error


Usage Examples

Here's a complete example using the create method:

import asyncio
from credoai import
from credoai.models import ModelCreate

async def main():
# Initialize client
client = (
base_url="https://api.credo.ai",
api_key="test_password-your-api-key"
)

try:
# Create Model
data = ModelCreate(
# Add required fields here
)

response = await client.models.create(data=data)
print(f"Success: {response}")

except Exception as e:
print(f"Error: {e}")

finally:
await client.close()

# Run the example
asyncio.run(main())

Error Handling

All methods in this resource can raise the following exceptions:

  • ValidationError - Invalid request data
  • APIError - Server-side errors
  • AuthenticationError - Invalid or missing API key
  • NotFoundError - Resource not found (404)
  • RateLimitError - Too many requests
from credoai.errors import APIError, ValidationError

try:
response = client.models.create()
except ValidationError as e:
print(f"Invalid request: {e}")
except APIError as e:
print(f"API error {e.status_code}: {e.message}")