Skip to main content

Overview

Use the Agent Completions endpoint (/v1/agent/completions) to run a single, well‑configured agent for a specific task.
This example shows a Research Analyst agent that uses the new agent_config shape and returns a structured JSON response.
This example is a companion to the main reference at /docs/documentation/capabilities/agent.
It focuses on a minimal, production‑ready Python script using plain requests.

Prerequisites

  • Python 3.9+
  • A valid Swarms API key
Create a .env file in your project root:
Install dependencies:

Run a Single Agent Completion

What This Example Shows

  • New agent_config format matching the Agent Completions reference
  • A single, stateless request to /v1/agent/completions
  • How to inspect the full JSON response, including outputs and usage

Next Steps

  • Add history or tools_enabled (e.g. ["auto_search"]) for more advanced behaviors
  • Use max_loops="auto" with the higher‑level Agent class for fully autonomous workflows
    → See “Autonomous Agents with max_loops="auto" in the examples section.