Skip to main content
POST
/
search
/
ai
Python
import os
from datagrid_ai import Datagrid

client = Datagrid(
    api_key=os.environ.get("DATAGRID_API_KEY"),  # This is the default and can be omitted
)
search_ai_result = client.search.search_ai(
    query="query",
)
print(search_ai_result.answer)
{
  "object": "search_ai_result",
  "answer": "<string>",
  "sources": [
    {
      "index": 123,
      "node_id": "<string>",
      "type": "file",
      "title": "<string>",
      "dataset_name": "<string>",
      "table_name": "<string>",
      "emoji": "<string>",
      "url": "<string>",
      "thumbnail_uri": "<string>",
      "page_numbers": [
        123
      ]
    }
  ],
  "search_results": {
    "object": "search_tree",
    "query": "<string>",
    "data": [
      {}
    ],
    "nav_items": [
      {}
    ],
    "has_more": true,
    "credits": {
      "consumed": 123
    },
    "next": "<string>"
  },
  "credits": {
    "consumed": 123
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request body for AI-powered search.

query
string
required

The natural language search query. The AI will search your indexed knowledge and generate an answer.

record_types
enum<string>[] | null

Optional filter to restrict search to specific record types (rows, tables, files, pages, cells).

The record type in the vector database.

Available options:
rows,
tables,
files,
pages,
cells
limit
integer | null
default:10

Maximum number of search results to consider when generating the answer.

Response

An AI-generated answer with source citations and the underlying search tree results.

AI-generated answer with source citations and the underlying search results.

object
enum<string>
required

The object type, always search_ai_result.

Available options:
search_ai_result
answer
string
required

AI-generated natural language answer based on the search results. Contains numbered citations like [1], [2] that reference entries in the sources array.

sources
object[]
required

Sources cited in the answer, ordered by citation index. Each source links back to the original data in your teamspace.

search_results
object
required

The full search tree results used to generate the answer. Useful for displaying raw results alongside the AI summary.

credits
object
required

Credit consumption for this search. When present, consumed reflects the actual variable cost of the retrieval work performed for this request. null when the billing write fails or the request is aborted before billing completes.