> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pinecone.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch the recorded trace for a query turn

> The per-turn debug trace (steps, tool calls, strategy, cost, rollup). Trace persistence is unconditional — every turn lands a trace blob — so this is available once the turn is terminal.



## OpenAPI

````yaml https://raw.githubusercontent.com/pinecone-io/pinecone-api/refs/heads/main/2026-07/nexus_data_2026-07.oas.yaml get /queries/{id}/trace
openapi: 3.0.3
info:
  title: Nexus API
  description: >
    Nexus turns a set of sources into a queryable, self-improving knowledge
    base. A context is **sources + a manifest**: upload sources, **curate** them
    into a searchable index, then query it. The manifest, one validated JSON
    document, defines how the context indexes, retrieves and answers.


    Curate is explicit — nothing is queryable until you run it. `{slug}` accepts
    a context's slug or its UUID. Query with `POST /api/query`, one turn per
    call, and read the answer from `output[].content[].text`; multi-turn
    conversations are sessions. Tasks are project-owned at `/api/tasks`, not
    nested under contexts.
  contact:
    name: Pinecone Support
    url: https://support.pinecone.io
    email: support@pinecone.io
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 2026-07
servers:
  - url: https://{host}/api
    description: Your Nexus deployment host
    variables:
      host:
        default: api.example.com
        description: Host of your Nexus deployment.
security:
  - bearerAuth: []
  - apiKey: []
tags:
  - name: Auth
    description: Login and identity.
  - name: Project
    description: The active Pinecone project and its disclosure state.
  - name: Contexts
    description: A context is sources + a manifest. Curate it explicitly before querying.
  - name: Manifest
    description: Manifest templates and the per-context manifest.
  - name: Source Files
    description: >-
      Per-context source imports (upload, connector, public repo) and the source
      file tree.
  - name: Knowledge
    description: Read-only browse of curated knowledge (chunks + artifacts).
  - name: Curation
    description: Curate workflow trigger, curation ledger, and version-pin primitives.
  - name: Connectors
    description: >-
      Project-level links to external source providers (Box, ...). Linked via
      OAuth or an API key, then used to import source documents into a context.
  - name: Query
    description: >-
      The unified KnowQL Query API: run a query turn (`/query`), fetch a turn
      (`/queries/{id}`), inspect its trace, manage feedback, comparison flags,
      and multi-turn sessions (`/sessions`).
  - name: Tasks
    description: >-
      Top-level, project-owned task records for every workflow (optimize,
      curate, search, work, explore, profile, import, pack, restore, groom).
  - name: Task Files
    description: Read, list, and delete files from live or archived task containers.
paths:
  /queries/{id}/trace:
    get:
      tags:
        - Query
      summary: Fetch the recorded trace for a query turn
      description: >-
        The per-turn debug trace (steps, tool calls, strategy, cost, rollup).
        Trace persistence is unconditional — every turn lands a trace blob — so
        this is available once the turn is terminal.
      operationId: get_query_trace
      parameters:
        - in: path
          name: id
          description: Query turn id.
          required: true
          schema:
            type: string
          style: simple
        - in: header
          name: X-Pinecone-Api-Version
          description: >-
            Date-based contract version, echoed back on the same header. Omit
            for the default (`2026-07`); send `unstable` for the in-development
            surface. An unrecognized value is rejected with `400
            unsupported_api_version`.
          schema:
            default: 2026-07
            x-enum:
              - 2026-07
              - unstable
            type: string
          style: simple
      responses:
        '200':
          description: The trace document
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Trace'
        '404':
          description: Query or trace not found
components:
  schemas:
    Trace:
      description: A turn's full-fidelity debug trace. Every turn lands one.
      type: object
      properties:
        steps:
          description: The turn's reasoning steps, in the order they ran.
          type: array
          items:
            $ref: '#/components/schemas/TraceStep'
        rollup:
          nullable: true
          description: >-
            Null on a turn the runtime never closed. The trace's copy omits the
            `type` and `query_id` the event form carries.
          type: object
          allOf:
            - title: Response turn rollup
              description: >-
                A turn's end-of-turn counters. Served both as the stored
                `response.turn_rollup` event, which adds `type` and `query_id`,
                and as the trace blob's copy, which does not.
              x-component-name: TurnRollup
              type: object
              properties:
                type:
                  description: Event form only.
                  x-enum:
                    - response.turn_rollup
                  type: string
                query_id:
                  description: Event form only.
                  type: string
                n_steps:
                  description: Reasoning steps the turn ran.
                  type: integer
                  format: int64
                n_tool_calls:
                  description: How many calls the whole turn made.
                  type: integer
                  format: int64
                by_category:
                  description: Tool calls tallied by category.
                  type: object
                  additionalProperties:
                    description: Calls made in that category.
                    type: integer
                    format: int64
                total_hits:
                  description: Retrieved items across all calls, before dedup.
                  type: integer
                  format: int64
                duration_ms:
                  description: Wall time for the whole turn.
                  type: integer
                  format: int64
                cache_read_tokens:
                  description: Input tokens served from the prompt cache.
                  type: integer
                  format: int64
                cache_write_tokens:
                  description: Input tokens written into the prompt cache.
                  type: integer
                  format: int64
    TraceStep:
      description: >-
        One reasoning step as recorded in the trace — its generated code, tool
        calls, strategy, and cost. Every field is optional; a step carries what
        its stage produced.
      type: object
      properties:
        step_id:
          description: Identifies the step within the turn.
          type: string
        commentary:
          description: The model's own one-line account of what this step is doing.
          type: string
        code:
          $ref: '#/components/schemas/StepCode'
        calls:
          description: The tool calls this step made.
          type: array
          items:
            $ref: '#/components/schemas/TraceCall'
        strategy:
          $ref: '#/components/schemas/StepStrategy'
        cost:
          $ref: '#/components/schemas/StepCost'
    StepCode:
      description: >-
        A step's generated code, capped. Either the source string alone or a
        `{language, source}` document.
      oneOf:
        - title: Source
          description: The source string alone, as later rows store it.
          type: string
        - title: Document
          description: The language-tagged form earlier rows store.
          type: object
          properties:
            language:
              description: Language the code is written in.
              type: string
            source:
              description: The code itself.
              type: string
    TraceCall:
      description: One tool call within a step.
      type: object
      properties:
        fn:
          description: Name of the function this call invoked.
          type: string
        category:
          description: >-
            Which family the tool belongs to, as tallied in the rollup's
            `by_category`.
          type: string
        args:
          description: >-
            Compact, redacted summary of the call's arguments. The key set is
            tool-specific and deliberately open.
          type: object
          additionalProperties: true
        result:
          description: >-
            Compact summary of the call's result (never the payload). The shape
            varies by category and is runtime-extensible.
        duration_ms:
          description: Wall time for this one call.
          type: integer
          format: int64
        ok:
          description: Whether the call succeeded.
          type: boolean
        score_space:
          description: >-
            Which scoring space the returned scores live in, for calls that
            retrieve.
          type: string
        error:
          description: Failure detail. Set when `ok` is false.
          type: string
    StepStrategy:
      description: The retrieval approach the step picked.
      type: object
      properties:
        kind:
          description: Strategy family, e.g. `artifacts_first`.
          type: string
        fns:
          description: Tool functions the strategy calls.
          type: array
          items:
            description: A tool function name.
            type: string
        label:
          description: Display label for the strategy.
          type: string
        scope:
          description: Context ids the strategy searched.
          type: array
          items:
            description: A context id the strategy searched.
            type: string
    StepCost:
      description: >-
        The step's incremental token and latency cost — deltas against the
        running turn cursor, not totals. The cache fields are tracked only on
        the search-as-code path.
      type: object
      properties:
        tokens_in:
          description: The step's input tokens.
          type: integer
          format: int64
        tokens_out:
          description: The step's output tokens.
          type: integer
          format: int64
        decide_ms:
          description: Time spent choosing what to do.
          type: integer
          format: int64
        execute_ms:
          description: Time spent running the tool calls it chose.
          type: integer
          format: int64
        tokens_in_cached:
          description: Input tokens served from the prompt cache.
          type: integer
          format: int64
        tokens_in_cache_write:
          description: Input tokens written into the prompt cache.
          type: integer
          format: int64
        tokens_in_fresh:
          description: Input tokens neither cached nor cache-written.
          type: integer
          format: int64
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Session token from `POST /auth/login`, sent as `Authorization: Bearer
        <token>`.
    apiKey:
      type: apiKey
      in: header
      name: Api-Key
      description: Pinecone API key, accepted as an alternative to the bearer token.

````