Best practices
Patterns and anti-patterns for building on Lumify — credit budgeting with /v1/estimate, polling, MCP, and agent hygiene.
Patterns (do)
- Estimate before you spend. POST /v1/estimate (MCP estimate_cost) is always free and returns min/max credit ranges.
- Compound when you need the full picture. GET /v1/events/{id}?include_odds=true&include_intelligence=true is cheaper than three separate calls.
- Default to Pinnacle for a single book. Use bookmaker=all only when you need cross-book comparison (2 credits).
- Treat available: false as success-with-no-data. It is free — do not retry-storm; back off until the next ingest cycle (~30 min for odds/intel).
- Prefer MCP tools when the client supports them. Hosted at https://lumify.ai/mcp — no npx for remote clients; _meta.credits_used mirrors REST.
- Read rate-limit and credit headers every call. X-RateLimit-*, X-Credits-Used, X-Credits-Remaining.
- Use webhooks or SSE instead of tight polling for score/status/line_move/intelligence changes.
- Cursor-paginate with after_id and stop when next_after_id is null. Max limit=100.
- Branch intelligence on shape. Presence of probability → MLS probability model; confidence_score → points model.
- Filter with has_recommend=true when you only want events with actionable intelligence.
- Keep keys server-side. Never expose lmfy-... in browsers or public repos.
- Provision keys/credits via /api/agent/* for agent-autonomous loops after the first human-issued key.
Anti-patterns (don't)
- Don't put the API key in the query string except for SSE (?api_key= is required there because EventSource cannot set headers). Prefer the Authorization header everywhere else.
- Don't invent endpoints, fields, or credit costs. Read llms.txt / OpenAPI; ask the user to paste docs if you cannot fetch them.
- Don't poll odds faster than the ingest cadence (~30 minutes). You will burn credits for identical payloads.
- Don't assume every sport has intelligence or splits. Check coverage (intelligence: MLB/NFL/NCAAF/tennis/FIFA WC/MLS; splits: MLB/NBA/NHL/NFL).
- Don't combine sort=status with after_id. It returns 400 — fetch in one page or use sort=time.
- Don't treat MLS edges_by_book / best.edge as EV. It is a line-shopping gap vs sharp consensus, not expected value.
- Don't call Lumify from the end-user's browser with a real key — proxy through your backend.
- Don't ignore 429 retry_after. Back off; rate-limited calls cost 0 credits but still waste wall time.
- Don't expect ChatGPT/Claude.ai web connectors to work yet — OAuth is not shipped; use desktop/IDE MCP clients.
- Don't document footguns as features. If an API behavior surprises you, open an issue — we fix APIs rather than warn forever.
Credit budgeting with /v1/estimate
Unlike vendors that force hand-calculation, Lumify exposes a free estimation endpoint. Use it before agent loops:
curl -s -X POST "https://lumify.ai/v1/estimate" \
-H "Authorization: Bearer lmfy-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"calls": [
{"tool": "list_events", "arguments": {"sport": "mlb", "status": "scheduled", "limit": 25}},
{"tool": "get_event", "arguments": {"event_id": 12345, "include_odds": true, "include_intelligence": true}}
]
}'
Costs are ranges because add-ons only bill when data is actually available. Budget formula for a monitoring agent:
daily_credits ≈ (events_tracked × polls_per_day × cost_per_poll)
+ webhook_or_sse_opens
+ intelligence_refreshes
# Prefer webhooks/SSE for scores → polls_per_day collapses to ~ingest cadence for odds only.
# Always cap loops with estimate_cost before a burst.
Adaptive polling
- Live scores: ~1 minute freshness — or open SSE / register a webhook and skip polling.
- Odds / splits / intelligence: ~30 minute ingest — polling faster than that usually returns identical data.
- Respect updated_at / intelligence_updated_at / computed_at — an older timestamp often means "unchanged", not "stale".
- On 429: sleep retry_after seconds (or exponential backoff starting at 1s).
Full limits: Rate limits & pagination.
Agent hygiene
- Start from the AI Context block — anti-hallucination directives included.
- Disambiguate the name: Lumify (lumify.ai) ≠ LUMIFY eye drops ≠ Philips Lumify ultrasound.
- Poll /changelog.json for breaking changes; we give ≥90 days notice within a major version.
- Keep structural advantages visible in your agent's system prompt: hosted MCP, no-signup trial, free estimates, metered transparency.