Search K
Appearance
Appearance
Using our SDK, you can return paginated lists or iterate over and collect objects into a single variable.
Lists returned in our API responses are paginated using the cursor attribute.
The cursor attribute is a pointer to the next or previous element in the list. By default, the majority of the lists return only 10 elements per page. You can set a value for the number of elements returned per page, for example:
from calypsoai import CalypsoAI
# Define the URL and token for CalypsoAI
CALYPSOAI_URL="https://www.us1.calypsoai.app"
CALYPSOAI_TOKEN="ADD-YOUR-TOKEN-HERE"
# Initialize the CalypsoAI client
cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)
# Get the list of prompts, 10 prompts per page
prompts = cai.client.prompts.get(limit=10)
# Print the response
print(prompts.model_dump_json())The sample request returns the following response:
{
"next": "eyJyb3ciOjEwLCJsaW1pdCI6MTAsInR5cGUiOiJyb3cifQ==",
"prev": null,
"prompts": [
{
"id": "01975a7e-f050-706e-afa8-1e22f1064f21",
"input": "Hello world",
"result": {
"files": null,
"outcome": "blocked",
"providerResult": null,
"response": null,
"scannerResults": [
{
"outcome": "failed",
"scanDirection": "request",
"scannerId": "019745f2-abad-700e-a805-93993f59e036",
}
]
}
}
(...)
]
}prev is set to null.next is set to null.If you don't want the request to return a paginated list, you can iterate over all list items instead, for example:
from calypsoai import CalypsoAI
# Define the URL and token for CalypsoAI
CALYPSOAI_URL="https://www.us1.calypsoai.app"
CALYPSOAI_TOKEN="ADD-YOUR-TOKEN-HERE"
# Initialize the CalypsoAI client
cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)
# Iterate over all available prompts
prompts = [prompt for prompt in cai.prompts.iterate()]cai.prompts.iterate(): This method iterates over all available prompts.prompt for prompt in: This syntax loops through the data and collects every individual prompt object into the prompts list.