Start small
Before running LLM functions over a full table:- Use
LIMITon a representative sample. - Reset metrics, run the sample, then inspect results:
Batching with max_batch_size
max_batch_size controls how many input tuples Flock groups into a single provider request (default: 16).
- Higher values: fewer API calls, lower overhead, but larger payloads and higher risk of context-window errors.
- Lower values: more API calls, but safer for long prompts or multimodal inputs.
Automatic retries on context overflow
If a batch exceeds the model context window, Flock retries with smaller batches instead of failing the entire query:- Scalar functions (
llm_complete,llm_filter,llm_embedding): halve batch size on failure (64 → 32 → 16 → …). - Aggregate functions (
llm_reduce,llm_rerank,llm_first,llm_last): shrink by 10% per retry.
max_batch_size upfront for multimodal workloads rather than relying on retries.
batch_size is a deprecated alias for max_batch_size. Use max_batch_size in new models and queries.Concurrency with is_async
For llm_complete and llm_filter, is_async defaults to true: batches are queued in parallel and responses collected together.
Throttling with rate_limit and usage_limit
rate_limit
Caps provider requests per minute for a Flock model name:
max_batch_size and rate_limit are independent: batch size controls tuples per request; rate limit throttles how many requests are sent per minute.
usage_limit
Enforces cumulative token quotas per model. When exceeded, Flock raises an error immediately (unlike context-window retries):
Multimodal workloads
Images and audio increase payload size and processing time:- Use smaller
max_batch_sizefor vision or transcription queries. - Prefer URLs or file paths over large inline base64 when possible.
- Audio requires
type: 'audio'and atranscription_model— see Voice onllm_completeand related function pages.
Recommended workflow
max_batch_size, is_async, and rate_limit based on metrics, then scale to the full dataset.
When to tune what
For provider-specific generation settings, see Model Parameters.

