Aura Analyst API
On this page
Note
This is a Preview feature.
Aura Analyst is a managed, AI-powered data analyst built natively for SingleStore.
SingleStore Aura Analyst API ("the API") enables you to embed Aura Analyst capabilities in your applications, workflows, and user experiences via a REST interface to provide conversational access to data and analytics.
Why Use the Analyst API
The Analyst API provides a streamlined model to integrate Aura Analyst in your applications, which allows you to:
-
Send natural language queries and receive generated SQL, results, and visualizations.
-
Build interactive analytics experiences using a streaming chat endpoint that delivers real-time events over Server-Sent Events (SSE).
-
Maintain multi-turn analytic sessions enabling follow-up questions to reuse prior context and results.
Analyst API Endpoint Reference
Analyst API currently supports the following endpoints:
|
Endpoint |
HTTP Method |
Request Body |
Description |
|---|---|---|---|
|
|
|
Required |
Structured Query Endpoint Runs a natural language analytics query and returns a single, structured JSON response containing generated SQL, optional result data, charts, and explanatory text. |
|
|
|
Required |
Streaming Chat Endpoint Runs a natural language analytics query and streams back Server-Sent Events (SSE) for use in interactive chat-style UIs. |
|
|
|
Conversation Starter Endpoint Returns a list of generated starter prompts tailored to the current domain and agent context. |
Use the /query endpoint for most integrations./chat endpoint for a streaming, interactive chat experience over Server-Sent Events (SSE), such as real-time typing indicators or incremental responses in a UI.
Refer to Aura Analyst API Reference for more information.
Authentication
Analyst API authenticates to the server using Bearer authentication standard, which must be used in conjunction with SSL (HTTPS) for secure communication over the network.
Generate an API Key
To generate an API key for Analyst API:
-
On the Cloud Portal, select AI > Analyst on the left navigation pane.
-
On the Analyst page, enable Creator Mode.
-
From the Domain list, select a domain.
-
Under Governance, select API Keys in the left pane.
-
On the API Keys page, select Create API Key.
-
In the Create API key dialog, enter a name for the API key and select an expiration window.
-
Select Create API Key.
-
Copy and securely store the API key.
Alternatively, select Save As Secret to store the API key as a secret; enter a name for the secret in the New Secret dialog, and select Create Secret. Note
The API key is displayed only once.
-
Select Close.
Use this key in the API call to authorize access to the API.
Revoke an API Key
To revoke an existing API key:
-
Select AI > Analyst, enable Creator Mode, and select a domain.
-
Navigate to the API Keys section in the left pane.
-
Under the Actions column for the API key, select the delete icon.
-
On the Revoke API Key dialog, acknowledge the warning, and select Revoke.
The API key is now successfully revoked.
Access the Analyst API
Copy the endpoint URL from the Cloud Portal:
-
Select AI > Analyst, enable Creator Mode, and select a domain.
-
Navigate to the API Keys section in the left pane.
-
Select Copy Endpoint to copy the URL of the
/chatendpoint.Replace chatwith the endpoint to access in the URL.
The base URL of the Analyst API conforms to the following format:
https://apps.{region}.cloud.singlestore.com/v1/organizations/{orgID}/projects/{projectID}/analyst/<endpoint>
Note
The Analyst API endpoints use a domain-scoped API key for authentication.{orgID} and {projectID} in the request path must match the key’s claims; otherwise, the request is rejected with 403 INVALID_.
To access the Analyst API, specify the API key in the Authorization header of the API request.
curl -X 'POST' \'<api_endpoint_url>' \-H 'accept: application/json' \-H 'Content-Type: application/json' \-H 'Authorization: Bearer <API_key>'
Getting Started with Aura Analyst API
To get started with the API:
-
Create a domain on the Cloud Portal, or select an existing domain.
-
Generate an API key for the Analyst API.
-
Use the API endpoint to access Aura Analyst via the API.
Start a New Chat Session
Use the POST /chat endpoint to start an interactive Aura Analyst conversation over Server-Sent Events (SSE).session_ from the request body.null or an empty string and the gateway will create a new session automatically.
curl -X POST "https://apps.${REGION}.cloud.singlestore.com/v1/organizations/${ORG_ID}/projects/${PROJECT_ID}/analyst/chat" \-H "Authorization: Bearer ${API_KEY}" \-H "Content-Type: application/json" \-H "Accept: text/event-stream" \-d '{"message": "Show me sales data for Q4."}'
The first stream includes a response. event containing the generated session_.
Continue an Existing Chat Session
Use the same POST /chat endpoint (used to start a new chat) to continue a prior Aura Analyst conversation.session_ in the request body so the Analyst can reuse the earlier context and interpret follow-up questions correctly.
curl -X POST "https://apps.${REGION}.cloud.singlestore.com/v1/organizations/${ORG_ID}/projects/${PROJECT_ID}/analyst/chat" \-H "Authorization: Bearer ${API_KEY}" \-H "Content-Type: application/json" \-H "Accept: text/event-stream" \-d '{"message": "Break that down by region","session_id": "${SESSION_ID}"}'
The session_ must be a valid UUID.
Get the Generated SQL from a Chat
Streaming Chat Endpoint
To retrieve generated SQL from the streaming chat endpoint, send the request to POST /chat endpoint and set included_ to ["sql"], which is the event type used for generated SQL queries.included_ field controls which event types are returned for chat responses.included_ or pass an empty array, the API returns all chat events.
curl -X POST "https://apps.${REGION}.cloud.singlestore.com/v1/organizations/${ORG_ID}/projects/${PROJECT_ID}/analyst/chat" \-H "Authorization: Bearer ${API_KEY}" \-H "Content-Type: application/json" \-H "Accept: text/event-stream" \-d '{"message": "What were the top 10 products by revenue last month?","included_events": ["sql"]}'
To query the results in addition to the SQL, use ["sql", "data"] instead.
Structured Query Endpoint
To retrieve the generated SQL for a back-end integration, use the POST /query endpoint instead of the streaming chat endpoint.output_ to ["sql"] to return only the generated SQL or ["sql", "data"] to return both the generated SQL and the executed results.
curl -X POST "https://apps.${REGION}.cloud.singlestore.com/v1/organizations/${ORG_ID}/projects/${PROJECT_ID}/analyst/query" \-H "Authorization: Bearer ${API_KEY}" \-H "Content-Type: application/json" \-d '{"message": "What were the top 10 products by revenue last month?","output_modes": ["sql"]}'
The generated SQL is returned in results[]. in the response.
Related Topics
Last modified: