# AGENTS.md: Swarms

> How AI agents should use the Swarms API and Swarms Cloud. Swarms runs single agents and multi-agent swarms (concurrent, sequential, hierarchical, graph workflows and more) on hosted models. The API is at https://api.swarms.world; https://cloud.swarms.world is the console for keys, billing, logs and a playground.

## Get an API key

1. The person you are acting for signs in at https://cloud.swarms.world (new accounts get $5 in free credits).
2. They create a key at https://cloud.swarms.world/api-keys. The full key is shown once.
3. Read it from the `SWARMS_API_KEY` environment variable. Never hard-code it, print it, or commit it.

## Connect over MCP (recommended for agents)

- Endpoint: https://api.swarms.world/mcp
- Transport: Streamable HTTP (no session id needed).
- Auth: send your Swarms API key in the `x-api-key` header. Requests without a key get 401.
- Tools: every Swarms API endpoint (agent and swarm completions, batch runs, reasoning agents, models, account) as an MCP tool.
- Setup guide: https://cloud.swarms.world/mcp and https://docs.swarms.ai/docs/documentation/clients/swarms-api-mcp
- Docs search servers (no key needed): https://docs.swarms.ai/mcp for the API, https://docs.swarms.world/mcp for the Swarms framework.

Client config:

```json
{
  "mcpServers": {
    "swarms": {
      "url": "https://api.swarms.world/mcp",
      "headers": { "x-api-key": "YOUR_SWARMS_API_KEY" }
    }
  }
}
```

Claude Code:

```bash
claude mcp add --transport http swarms https://api.swarms.world/mcp --header "x-api-key: $SWARMS_API_KEY"
```

## Call the REST API

- Base URL: https://api.swarms.world
- Auth: `x-api-key: $SWARMS_API_KEY` on every request.
- OpenAPI spec: https://api.swarms.world/openapi.json

```bash
curl -X POST https://api.swarms.world/v1/agent/completions \
  -H "x-api-key: $SWARMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agent_config": {"agent_name": "Researcher", "model_name": "gpt-5.4", "max_loops": 1}, "task": "Summarize the key risks in this plan."}'
```

## Endpoints

Each has a copyable template in cURL, Python, TypeScript, Go and Rust at https://cloud.swarms.world/examples.

### Agents

- `POST /v1/agent/completions`: Single agent completion

### Swarms

- `POST /v1/swarm/completions`: Concurrent swarm
- `GET /v1/swarms/available`: List swarm types

### Workflows

- `POST /v1/graph-workflow/completions`: Graph workflow (Premium)
- `POST /v1/batched-grid-workflow/completions`: Batched grid workflow (Premium)
- `POST /v1/auto-agent-builder/completions`: Auto agent builder

### Reasoning and decisions

- `POST /v1/reasoning-agent/completions`: Reasoning agent (Premium)
- `GET /v1/reasoning-agent/types`: List reasoning agent types
- `POST /v1/decision/completions`: Decision model completion
- `POST /v1/systemone`: Decision model, TypeSafe format
- `GET /v1/decision/models`: List decision models

### Batch

- `POST /v1/agent/batch/completions`: Batch agent completions (Premium)
- `POST /v1/swarm/batch/completions`: Batch swarm completions (Premium)

### Chat formats

- `POST /v1/chat/completions`: Chat completions
- `POST /v1/messages`: Messages
- `POST /v1/responses`: Responses

### Models and tools

- `GET /v1/models/available`: List available models
- `GET /v1/models`: List models for SDK discovery
- `GET /v1/models/pricing`: Get a model price
- `GET /v1/tools/available`: List available tools

### Account

- `GET /v1/rate/limits`: Check your rate limits
- `GET /v1/account/credits`: Check your credit balance
- `GET /v1/account/logs`: Get your request logs
- `GET /v1/job/JOB_ID`: Get a completion by job ID
- `GET /v1/agents/list`: List your agent configurations
- `GET /v1/account/metrics/summary`: Get your usage summary
- `GET /v1/account/premium-endpoints`: List premium endpoints
- `GET /v1/usage/costs`: Get pricing details

### Status

- `GET /`: API root
- `GET /health`: Health check

## Rules of the road

- Premium endpoints need a Pro or Premium plan and at least $1 in credits; otherwise the API answers 402 before doing any work. Plans are at https://cloud.swarms.world/pricing.
- Runs cost credits. Check the balance (`GET /v1/account/credits`) and model pricing (`GET /v1/models/pricing`) before large batches.
- Respect rate limits (`GET /v1/rate/limits`). On 429, back off and retry; do not hammer the API.
- Pick models from `GET /v1/models/available` rather than guessing names.
- Every run shows up in the person's history at https://cloud.swarms.world/history.

## More

- [Site map for LLMs](https://cloud.swarms.world/llms.txt)
- [Swarms API docs for LLMs](https://docs.swarms.ai/llms.txt)
- [Swarms API documentation](https://docs.swarms.ai)
