Chat

Ask questions and follow-ups. Every call is scoped to one agent.

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

Ask a question

POST/v1/agents/{agent_id}/chat

Send a chat message to an agent

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

Path parameters

NameTypeDescription
agent_idrequiredstringAgent ID

Query parameters

NameTypeDescription
streambooleanEnable streaming responseDefault: false

Request body · application/json (optional)

NameTypeDescription
user_idstring | nullEnd-user ID; honored only for master-key (server-to-server) callers
queryrequiredstringNatural language query
session_idstring | nullSession ID (creates new if not provided)
debug_infoboolean | nullInclude debug information in response. Omit to use the agent's saved setting.
chart_outputboolean | nullInclude chart output in response. Omit to use the agent's saved setting.
allowed_chartsarray<string> | nullList of allowed chart types. Omit to use the agent's saved setting.
follow_upboolean | nullIf true, also generate exactly two short follow-up questions for this turn. Omit to use the agent's saved setting.

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.post(
    f"{API_ROOT}/v1/agents/YOUR_AGENT_ID/chat",
    headers={"X-API-Key": API_KEY},
    json={
        "query": "How many orders were placed last month?",
    },
    timeout=120,
)
r.raise_for_status()
print(r.json())

Example request body

JSON
{
  "query": "How many orders were placed last month?"
}

Get a conversation's messages

GET/v1/agents/{agent_id}/sessions/{session_id}/messages

Get message history for a session

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

Path parameters

NameTypeDescription
agent_idrequiredstringAgent ID
session_idrequiredstringSession ID

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/sessions/YOUR_SESSION_ID/messages",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
r.raise_for_status()
print(r.json())

Ask a follow-up in a conversation

POST/v1/agents/{agent_id}/sessions/{session_id}/messages

Send a message to an existing session

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

Path parameters

NameTypeDescription
agent_idrequiredstringAgent ID
session_idrequiredstringSession ID

Query parameters

NameTypeDescription
streambooleanEnable streaming responseDefault: false

Request body · application/json (optional)

NameTypeDescription
user_idstring | nullEnd-user ID; honored only for master-key (server-to-server) callers
queryrequiredstringNatural language query
debug_infoboolean | nullInclude debug information in response. Omit to use the agent's saved setting.
chart_outputboolean | nullInclude chart output in response. Omit to use the agent's saved setting.
allowed_chartsarray<string> | nullList of allowed chart types. Omit to use the agent's saved setting.
follow_upboolean | nullIf true, also generate exactly two short follow-up questions for this turn. Omit to use the agent's saved setting.

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.post(
    f"{API_ROOT}/v1/agents/YOUR_AGENT_ID/sessions/YOUR_SESSION_ID/messages",
    headers={"X-API-Key": API_KEY},
    json={
        "query": "How many orders were placed last month?",
    },
    timeout=120,
)
r.raise_for_status()
print(r.json())

Example request body

JSON
{
  "query": "How many orders were placed last month?"
}

Rate an answer

POST/v1/agents/{agent_id}/feedback

Submit feedback on agent responses

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

Path parameters

NameTypeDescription
agent_idrequiredstringAgent ID

Request body · application/json (optional)

NameTypeDescription
user_idstring | nullUser ID (optional)
session_idrequiredstringSession ID
chat_idrequiredstringChat message ID
user_queryrequiredstringOriginal user query
generated_queryrequiredstringGenerated SQL query
labelrequiredstringFeedback label: 'correct' or 'incorrect'
corrected_querystring | nullCorrected SQL query (optional, for incorrect feedback)

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.post(
    f"{API_ROOT}/v1/agents/YOUR_AGENT_ID/feedback",
    headers={"X-API-Key": API_KEY},
    json={
        "session_id": "<session_id>",
        "chat_id": "<chat_id>",
        "user_query": "<user_query>",
        "generated_query": "<generated_query>",
        "label": "<label>",
    },
    timeout=120,
)
r.raise_for_status()
print(r.json())

Example request body

JSON
{
  "session_id": "<session_id>",
  "chat_id": "<chat_id>",
  "user_query": "<user_query>",
  "generated_query": "<generated_query>",
  "label": "<label>"
}