Developer docs

Code examples

Working examples across every major use case. Click any example to expand the full code. All examples use real production endpoints.

Route inference to best model Inference
+ expand

Send a task to the ForceDream router and let it select the optimal model. Returns the result, cost, latency, and what you saved versus using GPT-4o.

curl
curl -X POST https://api.forcedream.ai/v1/inference/route \ -H "Authorization: Bearer sk_fd_..." \ -H "Content-Type: application/json" \ -d '{"task": "research", "priority": "balanced"}'
Python
import requests response = requests.post( "https://api.forcedream.ai/v1/inference/route", headers={"Authorization": "Bearer sk_fd_..."}, json={"task": "research", "priority": "balanced"} ) data = response.json() print(data["selected_model"], data["cost_pence"])
TypeScript
const res = await fetch('https://api.forcedream.ai/v1/inference/route', { method: 'POST', headers: { 'Authorization': 'Bearer sk_fd_...', 'Content-Type': 'application/json' }, body: JSON.stringify({ task: 'research', priority: 'balanced' }) }) const { selected_model, cost_pence, savings_vs_gpt4_pence } = await res.json()
Store and retrieve agent memory Memory
+ expand

Give your agent persistent context that survives across sessions. Sealed on write, retrievable by agent ID and key.

Python
import requests KEY = "sk_fd_..." BASE = "https://api.forcedream.ai" # Store a memory requests.post(f"{BASE}/v1/memory/store", headers={"Authorization": f"Bearer {KEY}"}, json={"agent_id": "my_agent", "key": "user_language", "value": "French"} ) # Retrieve later r = requests.get(f"{BASE}/v1/memory/retrieve", headers={"Authorization": f"Bearer {KEY}"}, params={"agent_id": "my_agent", "key": "user_language"} ) print(r.json()["value"]) # "French"
Fraud detection check Security
+ expand

Run an 8-signal fraud check on any action. Returns a risk score, verdict (allow/review/block), and WORM-sealed evidence record.

curl -X POST https://api.forcedream.ai/v1/fraud/check \ -H "Content-Type: application/json" \ -d '{ "user_id": "usr_abc123", "action": "withdrawal", "amount_pence": 500, "ip": "1.2.3.4" }' # Response: { "verdict": "allow", "risk_score": 12, "worm_seal": "abc..." }
Publish an agent to the marketplace Marketplace
+ expand

Deploy your agent publicly. Users pay per call. You earn 78% automatically. Pending review, live within 24 hours.

curl -X POST https://api.forcedream.ai/v1/marketplace/publish \ -H "Authorization: Bearer sk_fd_..." \ -H "Content-Type: application/json" \ -d '{ "name": "Invoice Extractor", "desc": "Extract line items from any invoice PDF", "category": "Finance", "price_pence": 10, "markets": ["GB", "US", "EU"] }'
Check your earnings and withdraw Payments
+ expand

Check your balance and initiate a withdrawal via Stripe Connect, M-Pesa, or Airwallex.

import requests KEY = "sk_fd_..." H = {"Authorization": f"Bearer {KEY}"} # Check balance balance = requests.get("https://api.forcedream.ai/v1/account/balance", headers=H).json() print(f"Balance: {balance['balance_gbp']}") # Request withdrawal (min £5.00) if balance['balance_pence'] >= 500: w = requests.post("https://api.forcedream.ai/v1/withdraw/request", headers=H, json={"amount_pence": balance['balance_pence'], "method": "stripe_connect"} ).json() print(f"Withdrawal {w['withdrawal_id']}: {w['amount_gbp']}")
More examples coming

Africa payments corridor routing, FCA compliance reporting, multi-agent orchestration, and enterprise SSO integration examples are being added weekly.

View on GitHub ↗