> ## Documentation Index
> Fetch the complete documentation index at: https://secndai.manicule.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://secndai.manicule.dev/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://secndai.manicule.dev/api/mcp.
> Every agent surface: https://secndai.manicule.dev/.well-known/llms-manifest.json

# Batching and concurrency (/patterns/batching)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 355 · updated: 2026-11-12 -->
Related: [Confidence routing](/patterns/confidence-routing.md), [Escalate to a human](/patterns/escalate-to-human.md), [Companion true/false check](/patterns/companion-check.md), [Support triage](/cookbooks/support-triage.md)

> 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.

```python
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.
