Documentation menu

API · Queries

Get a query

GET /api/v1/documents/{id}/queries/{query_id}

Poll this after an async query, using the poll_url you were given.

Path parameters

  • id string required

    The document's id.

  • query_id string required

    The question's id.

Returns 200

The question and, once completed, its answer.

  • id string

    The query's id.

  • object string

    Always query.

  • answer QueryAnswer

    The answer, once status is completed. See QueryAnswer.

    4 fields
    • answer object

      A string, or an object following the query's schema.

    • citations array of object

      Every page and quote the answer came from.

      2 fields
      • page integer
      • quote string
    • confidence number

      How sure the model is, from 0 to 1.

      at least 0 · at most 1

    • not_found boolean

      true when the document does not answer the question.

  • completed_at string

    When it was answered.

  • cost object

    Held, then charged, in micro-USD.

    2 fields
    • estimated_micro integer
    • settled_micro integer
  • created_at string

    When you asked.

  • document_id string

    The document it was asked of.

  • error object

    Why it failed.

    2 fields
    • message string
    • type insufficient_credits | document_too_large | document_expired | schema_mismatch | query_failed
  • instructions string

    The instructions you sent, if any.

  • model object

    The model you asked for and the one that answered.

    2 fields
    • requested string
    • used string
  • question string

    What you asked.

  • schema object

    The JSON Schema you asked the answer to follow, if any.

  • status queued | processing | completed | failed

    completed means answer is ready; failed means read error.

Errors

  • 401

    Missing, revoked or expired key

  • 402

    Payment required. Either the plan's monthly request quota is spent (quota_exceeded, trial plans only — pay as you go is never capped) or the workspace is out of credit (insufficient_credits).

  • 404

    No document or query with that id for this key (documents are scoped to the key's workspace and live/test mode)

  • 429

    Per-second burst limit for the plan exceeded; retry after Retry-After seconds

Every error has the same shape. See Errors.