SwarmLM docs

Reference for SwarmLM's HTTP JSON endpoints (Pages Functions). Check /api/status first to see whether this deployment is in stub, local, or paid mode before assuming live billing or provider access.

Safety + scope
  • Don’t submit secrets, credentials, or sensitive personal information in task.
  • API responses are marked noindex and are not intended for indexing.
  • Browser requests from other origins are blocked; use same-origin or server-to-server calls.
  • Pilot deployments may expose sandbox checkout links while billing and provider rollout are still being finalized.

Need the pricing and rollout overview? See pilot access.

Base URL

https://swarmlm.net

Quickstart

Check runtime configuration

See whether demo/full runs are stub/local/paid on this deployment.

curl -s https://swarmlm.net/api/status
Run the public demo

Public endpoint (no auth). Use it to inspect the workflow shape before you buy or configure anything.

curl -X POST https://swarmlm.net/api/swarm-demo \
  -H 'Content-Type: application/json' \
  -d '{"task":"Design a 7-day onboarding flow for a SaaS product."}'
Escalate to a real run

Use an entitlement token for /api/swarm-run or configure a local model for your deployment.

curl -X POST https://swarmlm.net/api/swarm-run \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"task":"Draft an API spec with error cases."}'

Deployment modes

stub

Returns simulated output. Use this mode to inspect workflow shape, not to judge model quality.

local

Calls a self-hosted model endpoint when the deployment is configured for local-first runs.

paid

Requires an entitlement token for /api/swarm-run and may use provider routing configured for that deployment.

Local-first quickstart

If you want real runs without sending tasks to a third-party provider, configure a local model endpoint for the deployment. SwarmLM supports local-first runs when the deployment is configured with the variables below.

SWARMLM_DEMO_MODE=local
SWARMLM_LOCAL_LLM_URL=https://your-ollama-host
SWARMLM_LOCAL_LLM_MODEL=llama3.1:8b-instruct-q4_K_M
SWARMLM_LOCAL_LLM_CF_ACCESS_CLIENT_ID=...
SWARMLM_LOCAL_LLM_CF_ACCESS_CLIENT_SECRET=...
  • Best practice is to expose the local model over https and protect it with authentication.
  • For demo and full runs, check /api/status after deployment to verify the active mode.
  • If you need server-side model routing by plan, use the plan-specific local model variables documented in the project README.

Common deployment questions

Does Swarm AI work only online?
No. SwarmLM can expose a public stub demo, a local-first deployment, or a paid provider-backed run. The workflow pattern is not cloud-only.
Can I test SwarmLM before pilot checkout?
Yes. Check /api/status first, then run /api/swarm-demo. You can inspect the workflow shape before you buy or configure anything.
What is the difference between stub, local, and paid mode?
Stub mode returns simulated output, local mode calls a self-hosted model endpoint, and paid mode requires an entitlement token for /api/swarm-run and may use configured provider routing.

Client examples

JavaScript (fetch)
const res = await fetch('https://swarmlm.net/api/swarm-demo', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ task: 'Write a launch checklist.' }),
});
const data = await res.json();
console.log(data.mode, data.final);
Python (stdlib only)
import json
from urllib import request

payload = json.dumps({"task": "Write a launch checklist."}).encode()
req = request.Request(
    "https://swarmlm.net/api/swarm-demo",
    data=payload,
    headers={"Content-Type": "application/json"},
    method="POST",
)
with request.urlopen(req) as res:
    data = json.loads(res.read().decode())
print(data["mode"], data["final"])

Authentication

  • /api/swarm-demo, /api/status, and /api/waitlist do not require auth.
  • /api/swarm-run requires Authorization: Bearer <entitlement_token>.
  • Admin endpoints require an admin key (disabled unless configured).

Endpoints

GET /api/status

Returns safe booleans/modes only (no secrets, no internal URLs).

curl -s https://swarmlm.net/api/status

POST /api/swarm-demo

Content-Type: application/json

Request body

{ "task": "..." }

Max length: 2000 characters.

Rate limit

Default: 3 requests/minute per IP. On 429 responses, respect the Retry-After header.

curl -X POST https://swarmlm.net/api/swarm-demo \
  -H 'Content-Type: application/json' \
  -d '{"task":"Write a launch checklist for a new product page."}'

Response fields include plan, draft, review, and final, plus metadata like mode, provider, and model.

POST /api/swarm-run

Content-Type: application/json • Authorization: Bearer <entitlement_token>

Request body

{ "task": "...", "provider": "openai|anthropic|xai" }

Max length: 4000 characters. provider is optional and only used in paid mode.

Default rate limits (by plan)

basic: 2/min, 50/day
pro: 6/min, 250/day
enterprise: 20/min, 2000/day

curl -X POST https://swarmlm.net/api/swarm-run \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"task":"Draft an API spec with endpoints + error cases."}'

Returns the same staged fields as the demo endpoint, plus an entitlement object (plan + expiration).

POST /api/waitlist

Content-Type: application/json

Request body

{ "name": "...", "email": "...", "use_case": "..." }

Rate limit

Default: 5 requests/hour per IP.

curl -X POST https://swarmlm.net/api/waitlist \
  -H 'Content-Type: application/json' \
  -d '{"name":"Ada Lovelace","email":"ada@example.com","use_case":"Turn product requirements into launch plans."}'

POST /api/checkout

Content-Type: application/json

Creates a payment link (card or crypto). This endpoint is only available when checkout is enabled and KV is configured.

On beta deployments, card checkout may open Square sandbox rather than live billing. Confirm the current deployment mode via GET /api/status before treating checkout as production-ready.

The current public plans mint 30-day entitlements: basic ($19), pro ($79), and enterprise ($249). Default /api/swarm-run limits are basic 2/min + 50/day, pro 6/min + 250/day, and enterprise 20/min + 2000/day.

Request body

{ "email": "...", "plan": "basic|pro|enterprise", "payment_method": "card|crypto" }

Response

{ "success": true, "order_id": "...", "payment_url": "https://..." }

curl -X POST https://swarmlm.net/api/checkout \
  -H 'Content-Type: application/json' \
  -d '{"email":"you@example.com","plan":"pro","payment_method":"card"}'

After payment, the provider redirects back with order and claim query parameters. Use those values with /api/claim to retrieve your entitlement token.

POST /api/claim

Content-Type: application/json

Request body

{ "order_id": "...", "claim_code": "..." }

Response (paid)

{ "success": true, "status": "paid", "token": "...", "expires_at": "...", "plan": "..." }

curl -X POST https://swarmlm.net/api/claim \
  -H 'Content-Type: application/json' \
  -d '{"order_id":"swarm_...","claim_code":"..."}'

Errors and status codes

  • 400: invalid input (missing/too-long task, invalid email, etc.)
  • 401/403: missing or invalid auth token
  • 415: missing Content-Type: application/json
  • 429: rate limit exceeded (check Retry-After)
  • 503: feature not enabled on this deployment (KV, providers, checkout, etc.)

Notes

  • Tasks are rejected when they look like secrets/keys (private keys, API tokens, JWTs, etc.).
  • API responses include Cache-Control: no-store and X-Robots-Tag: noindex, nofollow.
  • For data handling and provider behavior, see Privacy and Terms.