Skip to main content
Swarm Type: BatchedGridWorkflow
Premium Tier Required: The /v1/batched-grid-workflow/completions endpoint is restricted to Pro, Ultra, and Premium plan subscribers. Free tier users will receive a 403 error. Upgrade your account to access batched grid workflow capabilities.

Overview

The BatchedGridWorkflow swarm type executes multiple tasks across multiple agents in a grid-like pattern, where each agent processes every task independently. This creates a comprehensive matrix of results, allowing you to compare how different agents approach the same set of tasks. The workflow supports iterative refinement through the max_loops parameter, enabling agents to improve their outputs over multiple iterations. Key features:
  • Grid Execution Pattern: Each agent processes every task, creating a complete task-agent matrix
  • Parallel Batch Processing: All agent-task combinations run in parallel for maximum efficiency
  • Iterative Refinement: Support for multiple loops to refine and improve outputs
  • Comparative Analysis: Easy comparison of different agent approaches to the same tasks
  • Structured Output Mapping: Results organized by agent name for each task

Use Cases

  • A/B testing different agent configurations on the same tasks
  • Multi-perspective analysis where each expert reviews all aspects
  • Quality assurance with multiple reviewers checking all items
  • Comparative research across different methodological approaches
  • Content generation with multiple styles or tones for the same topics

API Usage

Basic BatchedGridWorkflow Example

Example Response:

Advanced Example: Multi-Loop Refinement

Request Schema

BatchedGridWorkflowInput

AgentSpec

Response Schema

BatchedGridWorkflowOutput

Usage Object

Pricing

BatchedGridWorkflow uses unified pricing with agent costs. For detailed pricing information, see the Pricing page.

Grid Execution Pattern

The BatchedGridWorkflow creates a matrix where:
  • Rows: Represent tasks
  • Columns: Represent agents
  • Cells: Contain each agent’s response to each task
The output structure groups results by task:

Best Practices

When to Use BatchedGridWorkflow

  • Comparative Analysis: Need multiple perspectives on the same set of tasks
  • A/B Testing: Testing different agent configurations on identical inputs
  • Multi-Expert Review: Multiple specialists reviewing the same items
  • Style Variations: Generating content in different styles or tones
  • Quality Assurance: Multiple reviewers checking all aspects

When to Use Other Workflows

Design Recommendations

  1. Agent Diversity: Design agents with distinct specializations for meaningful comparisons
  2. Task Granularity: Break complex topics into specific tasks for better analysis
  3. Temperature Settings: Use lower temperatures (0.3-0.5) for analytical tasks, higher (0.6-0.8) for creative tasks
  4. Iterative Refinement: Use max_loops > 1 when quality improvement is worth the added cost
  5. Result Processing: Implement post-processing to compare and synthesize agent outputs

Cost Optimization

  • Start with fewer agents and tasks to test your workflow
  • Use appropriate models (claude-sonnet-4-20250514 or gpt-4.1 for quality, gpt-4.1-mini for cost)
  • Monitor token usage and adjust prompt verbosity
  • Cache common results when possible
  • Batch multiple related workflows in a single session

Error Handling

The API returns standard HTTP status codes:
  • 200: Success
  • 400: Bad request (invalid configuration)
  • 401: Unauthorized (invalid API key)
  • 402: Payment required (insufficient credits)
  • 500: Server error
Example error response:

Limitations

  • Maximum recommended: 10 agents × 10 tasks (100 total executions per workflow)
  • Each agent-task combination counts toward rate limits
  • Large grids may experience longer processing times
  • Token limits apply per agent execution