Analytics

How the agent is being used and where it fails.

Base URL https://futuresmart.ai/database-agent/api · every request sends X-API-Key. Samples read the key from DATABASE_AGENT_API_KEY. All endpoints

Get usage statistics

GET/v1/agents/{agent_id}/statistics

Get statistics for a specific agent

Credential Database Agent API key for this agent (X-API-Key)

Path parameters

NameTypeDescription
agent_idrequiredstring

Query parameters

NameTypeDescription
start_timestring | nullStart time for statistics (ISO format)
end_timestring | nullEnd time for statistics (ISO format)

Other responses

  • 422 Validation Error
import os
import requests

API_ROOT = "https://futuresmart.ai/database-agent/api"
API_KEY = os.environ["DATABASE_AGENT_API_KEY"]

r = requests.get(
    f"{API_ROOT}/v1/agents/YOUR_AGENT_ID/statistics",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
r.raise_for_status()
print(r.json())

Analytics Scorecard

GET/v1/agents/{agent_id}/analytics/scorecard

Everything for one agent in one response: usage, quality (answered/failed), routing (SQL vs cross-DB vs pandas, and per-database), performance (latency incl. time inside the customer database), cost, tokens. Pass start_date+end_date for a custom range, else period. bucket sets the usage.per_day granularity (use hour for intraday time-of-day activity).

Credential Database Agent API key for this agent (X-API-Key)

Path parameters

NameTypeDescription
agent_idrequiredstringAgent ID

Query parameters

NameTypeDescription
periodstringDefault: week
bucketstringusage.per_day granularity: hour | day | week | monthDefault: day
start_datestring (date-time) | nullCustom range start (ISO-8601); with end_date overrides period
end_datestring (date-time) | nullCustom range end, exclusive (ISO-8601)
top_nintegerDefault: 10

Other responses

  • 422 Validation Error
import os
import requests

API_ROOT = "https://futuresmart.ai/database-agent/api"
API_KEY = os.environ["DATABASE_AGENT_API_KEY"]

r = requests.get(
    f"{API_ROOT}/v1/agents/YOUR_AGENT_ID/analytics/scorecard",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
r.raise_for_status()
print(r.json())

Analytics Failures

GET/v1/agents/{agent_id}/analytics/failures

Failure category/stage/database breakdown + the most-repeated failed queries.

Credential Database Agent API key for this agent (X-API-Key)

Path parameters

NameTypeDescription
agent_idrequiredstringAgent ID

Query parameters

NameTypeDescription
periodstringDefault: week
start_datestring (date-time) | nullCustom range start (ISO-8601); with end_date overrides period
end_datestring (date-time) | nullCustom range end, exclusive (ISO-8601)
categorystring | nullsql_error | db_connection | no_rows | sql_generation | out_of_scope | unanswered | exception
failed_stagestring | nullNode the failure is attributed to: router | db_router | sql_gen | sql_exec | final_answer | chat_api
limitintegerDefault: 50
offsetintegerDefault: 0

Other responses

  • 422 Validation Error
import os
import requests

API_ROOT = "https://futuresmart.ai/database-agent/api"
API_KEY = os.environ["DATABASE_AGENT_API_KEY"]

r = requests.get(
    f"{API_ROOT}/v1/agents/YOUR_AGENT_ID/analytics/failures",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
r.raise_for_status()
print(r.json())

Analytics Queries

GET/v1/agents/{agent_id}/analytics/queries

Per-query drill-down — slowest / most-expensive / failure investigation, each row carrying the SQL it ran, the database it used and its per-node spend. Pass start_date+end_date for a custom range, else period (both ignored when chat_id is set).

Credential Database Agent API key for this agent (X-API-Key)

Path parameters

NameTypeDescription
agent_idrequiredstringAgent ID

Query parameters

NameTypeDescription
periodstringDefault: week
sortstringDefault: latency_ms
orderstringDefault: desc
statusstring | nullanswered | unanswered
outcomestring | nullsuccess | failure
failure_categorystring | null
failed_stagestring | null
routestring | nullsql | cross_db | pandas | direct_answer
modelstring | null
db_idstring | nullOnly queries routed to this database
min_tokensinteger | null
min_cost_usdnumber | null
min_latency_msinteger | null
chat_idstring | null
feedbackstring | nullFilter by user feedback: positive | negative | none (unrated) | any (rated)
include_node_databooleanInclude the per-node breakdown (metrics.node_data) in each row; set false for a lean listDefault: true
start_datestring (date-time) | nullCustom range start (ISO-8601); with end_date overrides period (ignored when chat_id is set)
end_datestring (date-time) | nullCustom range end, exclusive (ISO-8601)
limitintegerDefault: 20
offsetintegerDefault: 0

Other responses

  • 422 Validation Error
import os
import requests

API_ROOT = "https://futuresmart.ai/database-agent/api"
API_KEY = os.environ["DATABASE_AGENT_API_KEY"]

r = requests.get(
    f"{API_ROOT}/v1/agents/YOUR_AGENT_ID/analytics/queries",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
r.raise_for_status()
print(r.json())