Skip to main content
Queries run over the data you have already ingested into a workspace. You describe what you want in natural language, and AiQL returns the matching results. Queries are processed asynchronously through a workflow, so you poll for completion to get the result.

Prerequisites

  • An AiQL API key in the AIQL_API_KEY environment variable
  • A workspace ID with a finished ingestion (see Run a full ingestion)

Create a query

Send your request as content and pass the workspace ID in the AiQL-Workspace header. The query is created with status PENDING and begins processing immediately.
The response includes a status field that starts at PENDING:

Poll for completion

Queries are processed asynchronously. Poll the query by ID to check its status and retrieve the result when ready.
The query moves through these statuses:
  • PENDING → waiting to start
  • PROCESSING → workflow is running
  • PROCESSED → completed, result in output field
  • FAILED → workflow failed
See Query status lifecycle for the full state diagram and transitions.

List saved queries

Retrieve the queries you have run in a workspace. Results are returned a page at a time — see Pagination for how to page through them.

Delete a query

Remove a saved query when you no longer need it. This also cancels the workflow if it’s still running.
Keep prompts focused and constrain the result set. Word counts include both your query input and the matched content returned, so a tighter query costs fewer credits.
Queries are billed at 10 credits per 1,000 words, with a minimum of 1 credit per query. Listing, retrieving, and deleting saved queries is free. See Pricing for details.