Search#

Search operations

Query documents in a table#

POST/query

Perform a query against an AntflyDB table. Table is specified in the request body.

IMPORTANT: The final line of data must end with a newline character \n when using application/x-ndjson. Each newline character may be preceded by a carriage return \r.

Security#

Provide your bearer token in the Authorization header when making requests to protected resources.

Example: Authorization: Bearer YOUR_API_KEY

Request Body#

Example:

{
    "table": "products"
}

Code Examples#

curl -X POST "https://searchaf.antfly.io/api/v1/query" \\
    -H "Authorization: Bearer YOUR_API_KEY" \\
    -H "Content-Type: application/json" \\
    -d '{
    "table": "products"
}'

Responses#

{
  "results": [
    {
      "id": "string",
      "score": 0,
      "document": {}
    }
  ],
  "total": 0,
  "took_ms": 0
}

RAG (Retrieval-Augmented Generation) query#

POST/rag

Perform a RAG query that searches documents and generates an LLM-powered answer. Returns Server-Sent Events (SSE) stream with streaming summary, citations, and hits.

The backend attaches ModelConfig from global configuration (LLM provider, model, API keys). Widget authentication uses ApiKey header. Table(s) are specified in the queries array in the request body.

SSE Event Types:

  • summary: Streamed answer chunks (concatenate for full answer)
  • citations: Array of cited documents
  • hits: Array of search results used for context
  • done: Final event indicating stream completion

IMPORTANT: The final line of data must end with a newline character \n when using application/x-ndjson. Each newline character may be preceded by a carriage return \r.

Security#

Provide your bearer token in the Authorization header when making requests to protected resources.

Example: Authorization: Bearer YOUR_API_KEY

Request Body#

Example:

{}

Code Examples#

curl -X POST "https://searchaf.antfly.io/api/v1/rag" \\
    -H "Authorization: Bearer YOUR_API_KEY" \\
    -H "Content-Type: application/json" \\
    -d '{}'

Responses#

No response body

AnswerAgent query with classification and reasoning#

POST/agents/answer

Advanced agentic RAG that classifies queries, transforms them, and provides structured answers with reasoning and follow-up questions.

Similar to /rag but provides:

  • Query classification (question vs search)
  • Improved/semantic query transformation
  • Reasoning about the answer
  • Follow-up question suggestions

Returns Server-Sent Events (SSE) stream with classification, reasoning, answer, query results, and follow-up questions.

The backend attaches ModelConfig from global configuration (LLM provider, model, API keys). Table is specified in the request body.

SSE Event Types:

  • classification: Query classification and transformation
  • reasoning: Streamed reasoning chunks (concatenate for full reasoning)
  • answer: Streamed answer chunks (concatenate for full answer)
  • query_results: Search results used for context
  • followup_questions: Array of suggested follow-up questions
  • done: Final event indicating stream completion

Security#

Provide your bearer token in the Authorization header when making requests to protected resources.

Example: Authorization: Bearer YOUR_API_KEY

Request Body#

Example:

{}

Code Examples#

curl -X POST "https://searchaf.antfly.io/api/v1/agents/answer" \\
    -H "Authorization: Bearer YOUR_API_KEY" \\
    -H "Content-Type: application/json" \\
    -d '{}'

Responses#

No response body