What This Example Shows
- How to call
POST /v1/agents/auto-generatewith just a task string - The shape of the returned
agent_configand how to feed it directly into/v1/agent/completions - A two-step prototype loop: generate config → run task — no manual prompt engineering
- The distinction between
/v1/agents/auto-generate(single agent) and/v1/auto-swarm-builder/completions(full multi-agent swarm)
/v1/agents/auto-generate is the fastest way to bootstrap a single agent from a task description. You hand it a goal in English, and it returns the agent_name, description, system_prompt, and recommended model_name — everything you need to call /v1/agent/completions.Why This Matters
The slowest part of building an agent isn’t writing code — it’s writing the system prompt. A good system prompt is two to four paragraphs of role, expertise, output format, and constraints, and getting it right is the difference between a useful agent and a generic one./v1/agents/auto-generate collapses that authoring step into a single API call so you can prototype in minutes: type the task you want done, get a tuned config back, run it, iterate. It exists for exploration and scaffolding — once a config performs the way you want, you copy it into version control and stop calling the endpoint at runtime.
Step 1: Setup
Step 2: Generate an Agent Config from a Task Description
The endpoint takes a single field:task. Describe what you want the agent to do, and the service returns a full agent specification.
agent_config with the system prompt, name, description, and model already populated:
The exact field set in the response may evolve over time. Always inspect what the endpoint returns before piping it forward — at minimum you’ll get
agent_name, description, system_prompt, and model_name.Step 3: Pipe the Generated Config Straight into /v1/agent/completions
The point of the endpoint is that its output is the input shape /v1/agent/completions already expects. No translation needed.
Step 4: Iterate by Re-Generating with a Sharper Task
If the first config isn’t quite right, the fastest fix is usually to make the task description more specific and re-generate, rather than hand-editing the system prompt.system_prompt.
/v1/agents/auto-generate vs. /v1/auto-swarm-builder/completions
These two endpoints sound similar — they are not. Pick by how many agents you need.
/v1/agents/auto-generate | /v1/auto-swarm-builder/completions | |
|---|---|---|
| Returns | A single agent_config | A full multi-agent swarm + (optionally) executes it |
| Use when | You need one specialist for one task | The task needs a team — multiple roles, a workflow, a coordinator |
| Output shape | One agent spec — paste into /v1/agent/completions | A list of agent specs plus a swarm_type and flow — runs via /v1/swarm/completions |
| Execution | Authoring only — you run it yourself | Can author and execute in one call |
| Cost profile | One small LLM call to generate the config | Generates N agents and (typically) runs them, so the call is heavier |
| Typical task | ”Build me a contract reviewer." | "Build me a due-diligence team that covers legal, financial, and technical risk.” |
/v1/agents/auto-generate. If you’d describe it as “a team,” “a pipeline,” or “a workflow,” use /v1/auto-swarm-builder/completions.
Can I override the model the endpoint chose?
Can I override the model the endpoint chose?
Yes. The returned
agent_config is just a dict — mutate model_name, max_tokens, or any other field before calling /v1/agent/completions. Common pattern: auto-generate with the default, then swap model_name to anthropic/claude-opus-4-8 for production.Is this endpoint deterministic?
Is this endpoint deterministic?
No — the same task will return slightly different configs across calls. For production, generate once, review the prompt, commit it to your repo, and load it from there. The endpoint is for authoring, not for runtime config lookup.
Why doesn't the generated agent always include tools?
Why doesn't the generated agent always include tools?
/v1/agents/auto-generate produces a vanilla single-agent config. If you need tool use, MCP servers, or vision, add those fields yourself after generation, or describe them explicitly in the task (“…the agent should call a web search tool…”).Next Steps
- Single Agent Overview — the full
agent_configsurface you can override after generation - Auto Swarm Builder Tutorial — the multi-agent counterpart for whole-team generation
- Multi-Turn Conversations with Agent History — turn the generated agent into a chatbot by threading
history