Skip to main content

Platform Intelligence API

Public endpoint that aggregates real-time platform statistics for the AINative Intelligence Dashboard at ainative.studio/intelligence. No authentication required.


Table of Contents


Endpoints

GET /api/v1/public/platform/intelligence

Full platform intelligence response with stats, agent events, data lake analytics, and ads performance.

Auth: None (public endpoint)

Route registration: Mounted via the public router at prefix /platform, defined in app.api.routers.public.

Example request:

curl https://api.ainative.studio/api/v1/public/platform/intelligence

Example response:

{
"stats": {
"uptime_pct": 99.97,
"requests_total": 642000,
"agents_active": 14,
"models_served": 8,
"memory_queries_today": 312,
"tasks_completed_today": 47,
"tokens_processed_today": 1580000,
"improvement_loops": 89,
"last_updated": "2026-06-01T14:30:00+00:00",
"latency_p99_ms": 245.50
},
"agent_events": [
{
"id": "machine-dev-mac",
"agent": "Dev Mac",
"role": "Machine",
"action": "12 agents online",
"target": "45 improvement loops",
"timestamp": "2m ago",
"status": "running"
},
{
"id": "agent-sage",
"agent": "Sage",
"role": "Backend",
"action": "merged PR #3450",
"target": "",
"timestamp": "15m ago",
"status": "completed"
}
],
"lake": {
"agent_runs_30d": 1240,
"agent_success_rate_pct": 94.2,
"api_requests_30d": 580000,
"total_credits_30d": 12450.75,
"loop_quality": {
"overall_success_rate_pct": 91.5,
"improving": true,
"trend": [
{"date": "2026-05-25", "success_rate": 89.0, "total_runs": 42}
],
"source": "lake"
},
"packages": {
"total_downloads": 52000,
"top_packages": [
{"name": "zerodb-mcp", "ecosystem": "pypi", "downloads": 18500}
],
"source": "lake"
},
"business": {
"mrr_trend_7d": [
{"date": "2026-05-31", "amount_usd": 125.00}
],
"stripe_events_7d": 34,
"emails_delivered_7d": 210,
"open_pipeline_value": 15000.00,
"open_deals_count": 3,
"commerce_revenue_7d": 450.00,
"source": "lake"
},
"rlhf_quality_score_7d": 0.8234,
"regional_economy": {
"unemployment_rate": 4.2,
"fred_series_count": 6,
"federal_awards_ytd": 125000.00,
"federal_awards_count": 8,
"edd_total_employment": 132000.0,
"source": "lake"
},
"source": "lake"
},
"ads": {
"total_spend": 0,
"total_clicks": 1420,
"total_impressions": 0,
"total_conversions": 3,
"avg_cpc": 0,
"ctr": 0,
"campaigns_active": 4,
"top_keyword": "platform activity",
"top_keyword_conversions": 3,
"source": "db_proxy"
},
"ok": true
}

GET /api/v1/public/platform/intelligence/summary

Lightweight aggregate summary optimized for fast polling.

Auth: None

curl https://api.ainative.studio/api/v1/public/platform/intelligence/summary

Response fields:

FieldTypeDescription
agent_runs_todayintAgent tasks completed today (from lake)
agent_runs_weekintAgent tasks completed this week
api_calls_todayintAPI requests today
billing_revenue_weekfloatCredits consumed this week
top_packages_downloadsintTotal package downloads (30d)
generated_atstringISO timestamp
sourcestring"lake", "lake_empty", or "unavailable"

GET /api/v1/public/platform/intelligence/packages

npm and PyPI download statistics from the data lake.

Auth: None

Query parameters:

ParameterTypeDefaultDescription
daysint30Days to aggregate (1-90)
curl "https://api.ainative.studio/api/v1/public/platform/intelligence/packages?days=30"

Response fields:

FieldTypeDescription
total_downloadsintSum of all package downloads
packageslistSorted by downloads desc: {name, ecosystem, downloads}
daysintAggregation window
generated_atstringISO timestamp
sourcestring"lake", "lake_empty", or "unavailable"

Response Schema

PlatformIntelligenceResponse (top level)

FieldTypeDescription
statsPlatformIntelligenceStatsCore platform metrics
agent_eventslist[AgentEvent]Recent agent activity feed (up to 20 events)
lakeLakeAnalytics or nullHistorical analytics from MinIO data lake
adsAdsStats or nullGoogle Ads campaign performance proxy
okboolAlways true on success

PlatformIntelligenceStats

FieldTypeSourceDescription
uptime_pctfloatmcp_request_logs (primary), kong_usage_metrics (secondary)7-day uptime derived from 5xx error rate. Fallback: 99.97
requests_totalintmcp_request_logsTotal API requests (all time)
agents_activeintagent_heartbeat_executions + agent_deployments + peer_swarm_heartbeatCount of active agents across all sources
models_servedint/api/v1/models endpointNumber of AI models available
memory_queries_todayintmcp_request_logs (endpoint LIKE %/memory/%)ZeroMemory API calls today
tasks_completed_todayintagent_run_log + swarm_tasks + peer_swarm_heartbeatCompleted agent tasks today
tokens_processed_todayintplatform/llm_token_usage lake partition (primary), credits x 1000 (fallback)LLM tokens processed today
improvement_loopsintagent_run_log + agent_traces + peer_swarm_heartbeat + mcp_request_logsMemory consolidation, reflection, and decay operations
last_updatedstringcomputedISO timestamp of when stats were generated
latency_p99_msfloat or nullmcp_request_logs (7-day p99 percentile)p99 API latency in milliseconds

AgentEvent

FieldTypeDescription
idstringUnique event identifier (prefixed: agent-, machine-, cloud-, hb-)
agentstringFriendly agent name (e.g., "Cody", "Sage", "Aurora")
rolestringAgent role (e.g., "Orchestrator", "Backend", "QA")
actionstringWhat the agent did
targetstringTarget of the action (may be empty)
timestampstringHuman-readable relative time (e.g., "5m ago", "2h ago")
statusstring"completed", "running", or "queued"

LakeAnalytics

FieldTypeDescription
agent_runs_30dintTotal agent runs in the last 30 days
agent_success_rate_pctfloatAgent success rate over 30 days
api_requests_30dintTotal API requests over 30 days
total_credits_30dfloatTotal credits consumed over 30 days
loop_qualityLoopQualityTrendRecursive improvement loop quality trend (14d)
packagesPackageStatsnpm + PyPI download stats (30d)
businessBusinessSignals or nullRevenue, pipeline, and email delivery signals
rlhf_quality_score_7dfloat or nullAverage RLHF reward score (7d)
regional_economyRegionalEconomicSignals or nullSanta Cruz County open-data signals
sourcestring"lake", "lake_empty", or "unavailable"

BusinessSignals

FieldTypeDescription
mrr_trend_7dlistDaily revenue trend: {date, amount_usd}
stripe_events_7dintTotal Stripe webhook events in 7 days
emails_delivered_7dintEmails successfully delivered
open_pipeline_valuefloatSum of open deal values (ZeroPipeline)
open_deals_countintNumber of open deals
commerce_revenue_7dfloatZeroCommerce order revenue
sourcestring"lake" or "unavailable"

RegionalEconomicSignals

FieldTypeDescription
unemployment_ratefloat or nullLatest FRED CACRUZ0URN series value
fred_series_countintDistinct FRED economic series in the lake
federal_awards_ytdfloatUSAspending total federal award amount YTD
federal_awards_countintNumber of federal awards
edd_total_employmentfloat or nullLatest QCEW all-industry employment
sourcestring"lake" or "unavailable"

AdsStats

FieldTypeDescription
total_spendfloatAd spend (0 when Google Ads API unavailable)
total_clicksintProxied from today's API request count
total_impressionsint0 when unavailable
total_conversionsintNew user signups today (excluding test/trial accounts)
avg_cpcfloatAverage cost per click
ctrfloatClick-through rate
campaigns_activeintActive campaign count
top_keywordstringTop performing keyword
top_keyword_conversionsintConversions for top keyword
sourcestring"db_proxy", "ads_report", or "unavailable"

Data Sources

The intelligence endpoint aggregates data from multiple database tables and external services. Each data source is queried independently with its own error handling, so a failure in one source does not block the others.

Database Tables

TableData PulledUsed For
mcp_request_logsTotal request count, credits consumed, memory query count, uptime (5xx rate), p99 latency, improvement loop endpointsrequests_total, memory_queries_today, uptime_pct, latency_p99_ms, improvement_loops
agent_run_logPer-agent latest activity, task completion count, improvement summariestasks_completed_today, agent_events, improvement_loops
peer_swarm_heartbeatActive agent count and improvement loops from peer machines (10-min staleness window)agents_active, improvement_loops, machine-level events
agent_heartbeat_executionsDistinct agents with successful runs in last 2 hoursagents_active, heartbeat events
agent_deploymentsRunning Agent Cloud deploymentsagents_active (cloud)
agent_tracesRecent Agent Cloud operations, memory/reflect/consolidate tracesCloud agent events, improvement_loops
swarm_tasksCompleted swarm tasks todaytasks_completed_today
kong_usage_metricsError rate, p99 latency (secondary source, rarely populated)uptime_pct fallback
usersNew signups todayads.total_conversions

MinIO Data Lake (Parquet partitions)

PartitionDataUsed For
agent_run_log30-day agent run historylake.agent_runs_30d, lake.agent_success_rate_pct
mcp_request_logs30-day API request historylake.api_requests_30d, lake.total_credits_30d
package_statsnpm + PyPI download countslake.packages
rlhf_signalsRLHF reward scoreslake.rlhf_quality_score_7d
stripe_eventsStripe webhook eventslake.business.mrr_trend_7d, lake.business.stripe_events_7d
external/emailEmail delivery eventslake.business.emails_delivered_7d
business/crm/dealsZeroPipeline deal datalake.business.open_pipeline_value
business/commerce/ordersZeroCommerce orderslake.business.commerce_revenue_7d
external/scc/fred_indicatorsFRED economic indicatorslake.regional_economy.unemployment_rate
external/scc/federal_awardsUSAspending awardslake.regional_economy.federal_awards_ytd
external/scc/edd_laborEDD QCEW labor datalake.regional_economy.edd_total_employment
platform/llm_token_usageDaily LLM token countsstats.tokens_processed_today

External HTTP Calls

ServicePurpose
GET /api/v1/models (self)Count available AI models for stats.models_served
GitHub API (api.github.com)Fallback agent events from recent PRs across AINative-Studio repos (used when all DB event sources are empty)

How the Dashboard Consumes This

The Intelligence Dashboard at ainative.studio/intelligence is a Next.js page in the frontend application.

Polling behavior

The page fetches GET /api/v1/public/platform/intelligence on load and refreshes on a regular interval. No authentication is needed since the endpoint is mounted under the public router.

Agent roster

The endpoint maintains a known agent roster that maps agent IDs to friendly names and roles:

Agent IDDisplay NameRole
mainCodyOrchestrator
sageSageBackend
auroraAuroraQA
novaNovaSecurity
atlasAtlasInfra
lyraLyraFrontend
lumaLumaDocumentation
heliosHeliosPerformance
vegaVegaAnalytics
pr-review-botPR BotCode Review
sales-agentSalesSales
vp-marketingMarketingMarketing
scoutScoutIntelligence

Agents that have no recent agent_run_log entries are shown with status "queued" and action "idle -- awaiting task".

Event priority

Agent events are assembled from multiple sources in priority order:

  1. Heartbeat executions (agent_heartbeat_executions) -- real cron execution results with success/fail status
  2. Peer swarm events (peer_swarm_heartbeat + agent_run_log) -- per-agent activity cards plus machine-level summaries
  3. Run log events (agent_run_log) -- individual task completions
  4. Agent Cloud events (agent_traces) -- cloud-deployed agent operations
  5. GitHub PR fallback -- recent pull requests across AINative-Studio repos, used when all DB sources are empty

The combined list is truncated to 20 events.

Staleness handling

  • peer_swarm_heartbeat entries older than 600 seconds (configurable via PEER_HEARTBEAT_MAX_AGE_SECS) are ignored.
  • agent_heartbeat_executions uses a 2-hour window.
  • agent_run_log and agent_traces use 6-12 hour windows depending on the query.
  • When no heartbeat data is available, agents_active falls back to the count of configured agents (currently 11).

Uptime calculation

Uptime is derived from mcp_request_logs over a 7-day window:

uptime_pct = 100.0 - (100.0 * count(status_code >= 500) / count(*))

Values outside the range [90, 100] are discarded and the system falls back to kong_usage_metrics or a static fallback of 99.97%.

Lake data availability

The lake field is null when the MinIO data lake has no exported data. Each sub-section (loop_quality, packages, business, regional_economy) has its own source field indicating whether real lake data was available or not. The top-level lake.source is "lake" if any sub-source has data, "lake_empty" if all partitions are empty, and the entire field is omitted if the lake query module fails to import.