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
It focuses on a minimal, production‑ready Python script using plain
/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
.env file in your project root:
Run a Single Agent Completion
- Python (requests)
- TypeScript (fetch)
- Rust (reqwest)
What This Example Shows
- New
agent_configformat matching the Agent Completions reference - A single, stateless request to
/v1/agent/completions - How to inspect the full JSON response, including
outputsandusage
Next Steps
- Add
historyortools_enabled(e.g.["auto_search"]) for more advanced behaviors - Use
max_loops="auto"with the higher‑levelAgentclass for fully autonomous workflows
→ See “Autonomous Agents withmax_loops="auto"” in the examples section.