Pagination and filters
Fetch one page or walk through results while preserving resource-specific filters.
Each list call fetches one page. Most management lists return items and nextCursor; evaluation results use numbered pages. The SDK does not fetch subsequent pages automatically.
Fetch one page
Pass filters and pagination settings together in the query object. For example, fetch up to 25 chat models with configured organization credentials:
const page = await nirmos.models.list({
capability: "chat",
availability: "true", // This query field takes a string, not a boolean.
limit: 25, // Maximum items to request for this page.
});
for (const model of page.items) {
console.log(model.id, model.slug);
}
// Save this value if your UI has a "Load more" button. Null means no next page.
console.log("Next cursor:", page.nextCursor);Model availability means the organization has an active credential for the provider. Provider access and quota still determine whether a model request succeeds.
Walk through cursor pages
Pass nextCursor back as cursor, keeping the same filters. Process the items from each page and stop when the server returns no next cursor:
import type { Queries } from "@nirmos/sdk";
// Keep the filters unchanged while traversing this result set.
const filters = {
capability: "chat",
availability: "true",
limit: 50,
} satisfies Queries["listModels"];
let cursor: string | undefined;
do {
const page = await nirmos.models.list({ ...filters, cursor });
// Process each page before fetching the next one.
for (const model of page.items) console.log(model.id, model.slug);
cursor = page.nextCursor ?? undefined;
} while (cursor);Treat cursors as opaque strings. Do not parse or increment them, and start again without a cursor when filters or sorting change. Lists are not snapshots, so concurrent changes can affect traversal.
Page-size defaults and limits belong to each endpoint. Check the resource's method reference rather than assuming every list uses the same limit.
Filter and sort results
Filters and sort options depend on the resource. For example, prompts support text search and sorting by update time:
const page = await nirmos.prompts.list({
search: "support", // Search prompt records using this resource's search field.
status: "published",
sort: "updated", // Use a sort value supported by prompts.list.
limit: 25,
});
console.log(page.items);| Resource | Example filters | Sorting |
|---|---|---|
| Models | capability, providerId, availability | No query sort option |
| Prompts | search, status | updated, newest, oldest, name |
| Endpoints | promptId, status, search | updated, created, name, version |
| Logs | providerId, modelId, success, from, to | No query sort option |
| Memory items | memorySpaceId, type, status, activeOnly | No query sort option |
Management boolean query fields such as availability, success and activeOnly take the strings "true" and "false". Runtime Memory search filters use booleans:
// Management list query: use the string "true".
await nirmos.memory.items.list({ memorySpaceId: "space-id", activeOnly: "true", limit: 25 });
// Runtime search body: use the boolean true.
await nirmos.memory.search({
memorySpaceId: "space-id", // Replace with your Memory space ID.
query: "Preferences",
filters: { activeOnly: true },
});Fields set to undefined are omitted. Array query values use repeated field[] parameters. There is no universal filter or sort option; use the query type for the method you are calling.
Walk through numbered pages
Evaluation run results and cases accept page and pageSize. They return data with a pagination object containing page, pageSize, total and hasMore.
const runId = "run-id"; // Replace with an existing evaluation run ID.
let pageNumber = 1;
while (true) {
const result = await nirmos.evaluations.runs.results(runId, {
page: pageNumber,
pageSize: 25,
status: "completed", // Keep the same filter on every page.
});
for (const trial of result.data) console.log(trial.id, trial.metrics);
if (!result.pagination.hasMore) break; // Stop after the last page.
pageNumber = result.pagination.page + 1;
}Human reviews also use numbered pages, but their response shape differs. Use the reviews reference before sharing pagination code between resources.