Developer Guide
Pricing & Economics — Developers
Swarmient’s pricing is transparent and pay-per-use. Miners set their own rates based on their hardware and capabilities. You always see estimated costs before your job executes.
How You Pay
You purchase credits upfront, then submit jobs. Each completed task consumes credits based on execution time and the miner’s rate.
When a task completes, credits are deducted immediately. No delay, no escrow, no disputes.
Miner Rates
Every miner advertises their own rate. When you submit a job, you see:
- Estimated cost — Before execution
- Actual cost — After the miner finishes
Rates vary depending on:
- Hardware capabilities (CPU cores, memory, GPU)
- Network conditions and uptime
- Task complexity and resource requirements
You choose which miner to accept your job based on rate and reputation. Swarmient automatically assigns jobs to available miners.
Failed Tasks Don’t Cost Extra
If a task fails:
- You pay for the work that happened — If a miner worked for 3 seconds before failing, you pay for 3 seconds
- You don’t pay if we cancel it — If we cancel a task due to insufficient resources or miner disconnect, you’re refunded
Example:
- Task timeout is 60 seconds
- Miner accepts but crashes after 10 seconds
- You pay for 10 seconds only
- Task is retried on another miner (if enabled)
Retries & Cost
If you enable retries (max_retries: 2), you might pay for multiple attempts:
{
"id": "risky-task",
"prompt": "...",
"timeout_ms": 30000,
"max_retries": 2
}
Best case: First miner succeeds, you pay once.
Worst case: First miner fails, second miner fails, third miner succeeds. You pay for 3 attempts.
When to use retries:
- Task might be flaky (network-dependent)
- You’re unsure if task will pass
- Cost of retry is worth the reliability
When not to use retries:
- Task is guaranteed to pass or fail (deterministic)
- You’re budget-conscious
Resource Costs
Different resources have different costs:
- CPU-only — Standard rate
- GPU — Higher rate (varies by GPU type and miner)
- High memory — Higher rate depending on amount
- Specialized hardware — Costs vary significantly
Tasks requesting specialized hardware will generally cost more than CPU-only work.
When to request GPU:
- ML model inference/training
- Image/video processing
- Complex numerical computation
When to request CPU-only:
- Code generation
- Text processing
- Data transformation
Batch Cost Calculation
Here’s a realistic workflow with cost information:
{
"name": "build-service",
"tasks": [
{
"id": "schema",
"prompt": "Design a PostgreSQL schema",
"timeout_ms": 30000
},
{
"id": "api",
"prompt": "Write a REST API",
"timeout_ms": 60000
},
{
"id": "tests",
"prompt": "Write tests",
"timeout_ms": 45000
}
]
}
Execution timeline:
- schema: ~15 seconds
- api: ~25 seconds
- tests: ~20 seconds
You’ll see:
{
"estimated_cost": 120,
"total_cost": 118,
"cost_unit": "tokens"
}
Actual costs depend on which miners accept your job and their hardware capabilities.
Credit Management
Purchasing credits:
Visit your dashboard and click “Add Credits”. Purchase tokens in bulk for your account.
Token expiration:
Tokens never expire. Use them whenever.
Refunds:
If you’re unhappy, we offer refunds within 30 days of purchase.
Budget Alerts
Set spending limits to avoid surprise costs:
curl -X PUT https://api.swarmient.com/v1/account/budget \
-H "Authorization: Bearer $SWARMIENT_API_KEY" \
-d '{
"monthly_limit": 100,
"alert_threshold": 80
}'
monthly_limit: Stop accepting jobs when you hit this spend in a calendar month.
alert_threshold: Email you when spending reaches 80% of limit.
You’ll get a warning before expensive jobs execute.
Transparent Pricing Examples
Example 1: Simple Code Generation
Job: Generate a Python quicksort function
curl -X POST https://api.swarmient.com/v1/jobs/submit \
-H "Authorization: Bearer $SWARMIENT_API_KEY" \
-d '{
"name": "quicksort",
"tasks": [{
"id": "task-1",
"prompt": "Write Python quicksort with type hints",
"timeout_ms": 30000
}]
}'
Response:
{
"job_id": "job_abc123",
"estimated_cost": 25,
"cost_unit": "tokens",
"status": "PENDING"
}
After completion:
{
"job_id": "job_abc123",
"status": "COMPLETED",
"total_cost": 23,
"cost_unit": "tokens",
"tasks": [{
"execution_time_ms": 1854,
"cost": 23
}]
}
Simple tasks consume a small amount of tokens.
Example 2: Multi-Task Workflow
Job: Build a full microservice (schema, API, tests, docs)
{
"name": "microservice",
"tasks": [
{ "id": "schema", "prompt": "...", "timeout_ms": 30000 },
{ "id": "api", "prompt": "...", "timeout_ms": 60000, "depends_on": ["schema"] },
{ "id": "tests", "prompt": "...", "timeout_ms": 45000, "depends_on": ["api"] },
{ "id": "docs", "prompt": "...", "timeout_ms": 30000, "depends_on": ["api"] }
]
}
Estimated cost: ~350 tokens
Actual cost after execution: ~345 tokens
Costs vary based on which miners accept your job and how long each task takes to execute.
Example 3: ML Model Inference
Job: Run inference on a model (GPU-required)
{
"name": "inference",
"tasks": [{
"id": "inference",
"prompt": "Run inference on this model...",
"timeout_ms": 300000,
"resources": {
"gpu": "required",
"memory_gb": 16
}
}]
}
Estimated cost: ~800 tokens (GPU work costs more than CPU)
Actual cost after execution: ~780 tokens
GPU work will consume more tokens than equivalent CPU-only tasks. The exact cost depends on which miners have available GPUs and their rates.
You always see estimated and actual costs clearly.
Cost Optimization Tips
1. Start Small
Don’t build a complex 10-task workflow on your first try. Start with single tasks to understand execution times and costs:
{
"tasks": [{
"id": "test",
"prompt": "Write hello world in Go",
"timeout_ms": 30000
}]
}
Simple tasks consume minimal tokens. Use this to calibrate your workflow.
2. Profile Execution Times
Run the same task a few times to understand average execution time:
# Submit same task 3 times
for i in {1..3}; do
curl -X POST .../submit -d '{"tasks": [...]}'
done
# Check actual execution times
curl https://api.swarmient.com/v1/jobs?status=COMPLETED | jq '.jobs[].tasks[].execution_time_ms'
Now set realistic timeouts instead of guessing.
3. Reduce Retries
Don’t set max_retries: 5 for every task. Use retries only for tasks that are actually flaky:
{
"id": "api-generation",
"prompt": "...",
"timeout_ms": 60000,
"max_retries": 0
}
No retries = no wasted money on retried failures.
4. Use CPU-Only When Possible
Only request GPU if you truly need it:
{
"resources": {
"gpu": "optional"
}
}
Mark GPU as optional so Swarmient can use cheaper CPU miners if available.
5. Parallelize Tasks
A 3-task workflow where all tasks depend on each other costs 3x as much as parallelizable tasks.
Sequential (expensive):
{
"tasks": [
{ "id": "a", "prompt": "..." },
{ "id": "b", "prompt": "...", "depends_on": ["a"] },
{ "id": "c", "prompt": "...", "depends_on": ["b"] }
]
}
Parallelizable (cheaper):
{
"tasks": [
{ "id": "a", "prompt": "..." },
{ "id": "b", "prompt": "..." },
{ "id": "c", "prompt": "...", "depends_on": ["a", "b"] }
]
}
The second version has a and b run in parallel, reducing total time and cost.
FAQ
Q: Do I pay if a job is still PENDING?
A: No. You only pay when a miner starts executing. Pending time is free.
Q: What if I cancel a running job?
A: You’ll be charged for the work the miner completed before cancellation.
Q: Can I negotiate rates with miners?
A: Not directly, but you can use budget settings to accept only cheaper miners. High-reputation miners sometimes offer lower rates.
Q: Are there volume discounts?
A: Contact sales for high-volume usage (100+ jobs/month). Enterprise pricing available.
Q: What happens if I run out of credits mid-job?
A: In-progress jobs complete. New jobs are rejected until you add more credits.
Next Steps
- Examples — Real-world cost patterns
- Monitor & Debug — Track costs in real-time
- FAQ — More questions answered