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
- Content-Type:
application/json - Schema:
ModelResponse
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
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:
| Parameter | Type | Required | Description |
|---|---|---|---|
page_limit | Any | ✗ | - |
page_after | Any | ✗ | - |
Responses
200 - Successful Response
- Content-Type:
application/json - Schema:
PaginatedResponse_ModelResponse_
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
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:
| Parameter | Type | Required | Description |
|---|---|---|---|
model_id | str | ✓ | - |
Responses
200 - Successful Response
- Content-Type:
application/json - Schema:
ModelResponse
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
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:
| Parameter | Type | Required | Description |
|---|---|---|---|
model_id | str | ✓ | - |
Request Body: ModelUpdate
Responses
200 - Successful Response
- Content-Type:
application/json - Schema:
ModelResponse
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
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:
| Parameter | Type | Required | Description |
|---|---|---|---|
model_id | str | ✓ | - |
Responses
204 - Successful Response
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
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 dataAPIError- Server-side errorsAuthenticationError- Invalid or missing API keyNotFoundError- 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}")