Batching and concurrency
Fan out independent decisions without inventing a batch endpoint.
The API accepts one typed decision per request. To process a collection, use bounded client-side concurrency. Each request has its own usage and routing action; there is no atomic batch response.
import asyncio
import os
from secnd import AsyncSecnd
async def classify_many(situations):
client = AsyncSecnd(api_key=os.environ["SECND_API_KEY"])
semaphore = asyncio.Semaphore(4)
async def classify(situation):
async with semaphore:
return await client.decide({
"model": "ren-zero-2026-11-12",
"type": "noul",
"situation": situation,
"question": "Is a cancellation explicitly requested?",
"threshold": 0.9,
})
return await asyncio.gather(
*(classify(situation) for situation in situations),
return_exceptions=True,
)The concurrency value is illustrative, not a throughput recommendation. Start small and stay within both key and account limits. return_exceptions=True preserves one output position per input; explicitly handle exceptions as failed items, not false answers.
For large collections, use a bounded producer queue rather than creating one coroutine per row. Retry failed items within a fixed budget, preserve your own case IDs, and deduplicate downstream side effects.