Use_cases Resource
API methods for use_cases operations.
Methods
create
Create Use Case Create a new use case.
This endpoint creates a new use case using the authenticated context provided by the router-level authentication dependency. The context is resolved once at the router level and reused here.
Method: POST
Path: /use_cases
# Create Use Case
from credoai.models import UseCaseCreate
data = UseCaseCreate(
# Add required fields here
)
response = client.use_cases.create(
data=data,
)
Parameters
Request Body: UseCaseCreate
Responses
201 - Successful Response
- Content-Type:
application/json - Schema:
UseCaseResponse
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
list
List Use Cases List all use cases.
This endpoint retrieves all use cases with optional pagination. Returns a paginated response with items and pagination metadata.
Method: GET
Path: /use_cases
# List Use Cases
response = client.use_cases.list(
)
Parameters
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
page_limit | Any | ✗ | - |
page_after | Any | ✗ | - |
Responses
200 - Successful Response
- Content-Type:
application/json - Schema:
PaginatedResponse_UseCaseResponse_
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
get
Get Use Case Get a use case by ID.
This endpoint retrieves an existing use case by its ID.
Method: GET
Path: /use_cases/{use_case_id}
# Get Use Case
use_case_id = "example" # Path parameter
response = client.use_cases.get(
use_case_id=use_case_id,
)
Parameters
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
use_case_id | str | ✓ | - |
Responses
200 - Successful Response
- Content-Type:
application/json - Schema:
UseCaseResponse
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
update
Update Use Case Update an existing use case.
This endpoint updates an existing use case with the provided data. Only the fields provided in the request will be updated.
Method: PATCH
Path: /use_cases/{use_case_id}
# Update Use Case
from credoai.models import UseCaseUpdate
use_case_id = "example" # Path parameter
data = UseCaseUpdate(
# Add required fields here
)
response = client.use_cases.update(
use_case_id=use_case_id,
data=data,
)
Parameters
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
use_case_id | str | ✓ | - |
Request Body: UseCaseUpdate
Responses
200 - Successful Response
- Content-Type:
application/json - Schema:
UseCaseResponse
422 - Validation Error
- Content-Type:
application/json - Schema:
HTTPValidationError
delete
Delete Use Case Delete a use case by ID.
This endpoint deletes an existing use case by its ID.
Method: DELETE
Path: /use_cases/{use_case_id}
# Delete Use Case
use_case_id = "example" # Path parameter
response = client.use_cases.delete(
use_case_id=use_case_id,
)
Parameters
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
use_case_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 UseCaseCreate
async def main():
# Initialize client
client = (
base_url="https://api.credo.ai",
api_key="test_password-your-api-key"
)
try:
# Create Use Case
data = UseCaseCreate(
# Add required fields here
)
response = await client.use_cases.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.use_cases.create()
except ValidationError as e:
print(f"Invalid request: {e}")
except APIError as e:
print(f"API error {e.status_code}: {e.message}")