Flock LLM workloads are network-bound: API latency, token volume, and batch configuration dominate cost and response time. This guide summarizes the knobs that matter most. For full parameter reference, see Models Management.

Start small

Before running LLM functions over a full table:
  1. Use LIMIT on a representative sample.
  2. Reset metrics, run the sample, then inspect results:
See LLM Metrics for parsing token counts and latency.

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.
You can override inline per query:

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.
Prefer tuning 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.
Use synchronous mode when provider rate limits or connection stability are a concern.

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_size for vision or transcription queries.
  • Prefer URLs or file paths over large inline base64 when possible.
  • Audio requires type: 'audio' and a transcription_model — see Voice on llm_complete and related function pages.
Adjust 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.