> ## 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_2026-07.oas.yaml GET /queries/{id}/trace
openapi: 3.0.3
info:
  title: Nexus API
  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
  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 (curate is explicit — there is no auto-curate), and
    then query the context. The manifest (a single validated JSON document)
    defines how the context indexes, retrieves, and answers.


    Conventions:


      * The `{slug}` path parameter accepts the URL-safe context slug **or**
        its UUID.

      * Contexts return a `ContextResponse` (derived flags), not the raw
        persisted model. Tasks return a `TaskResponse`.

      * Querying is the unified KnowQL Query API: `POST /api/query` runs one
        turn (`ask` in, answer out); multi-turn conversations are **sessions**
        (`GET/DELETE /api/sessions`, `GET /api/queries/{id}`). Read the
        answer from `output[].content[].text`.

      * Tasks are a top-level, project-owned resource at `/api/tasks` —
        they are no longer nested under contexts. Active workflow types are
        `optimize`, `curate`, `search`, `search_cc`, `search_rag`, `explore`,
        `profile`, `import`, `pack`, `restore`.
servers:
  - url: https://{host}/api
    description: Your Nexus deployment host
    variables:
      host:
        default: api.example.com
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:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - $ref: '#/components/parameters/ApiVersionHeader'
    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
      responses:
        '200':
          description: The trace document
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Trace'
        '404':
          description: Query or trace not found
components:
  parameters:
    ApiVersionHeader:
      in: header
      name: X-Pinecone-Api-Version
      description: >-
        Date-based contract version. Omit to resolve to the Nexus default
        version (`2026-07`, the oldest served version); send `unstable` for the
        in-development surface. The resolved version is echoed back on the same
        header. A present-but-unrecognized value is rejected with `400
        unsupported_api_version`.
      required: false
      style: simple
      schema:
        type: string
        default: 2026-07
        x-enum:
          - 2026-07
          - unstable
  schemas:
    Trace:
      type: object
      description: A turn's full-fidelity debug trace.
      properties:
        steps:
          type: array
          items:
            $ref: '#/components/schemas/TraceStep'
        rollup:
          type: object
          nullable: true
          required:
            - n_steps
            - n_tool_calls
            - total_hits
            - duration_ms
          description: >-
            End-of-turn aggregate counters. The cache fields are present only on
            the search-as-code path.
          properties:
            n_steps:
              type: integer
              format: int64
            n_tool_calls:
              type: integer
              format: int64
            by_category:
              type: object
              additionalProperties:
                type: integer
                format: int64
            total_hits:
              type: integer
              format: int64
            duration_ms:
              type: integer
              format: int64
            cache_read_tokens:
              type: integer
              format: int64
            cache_write_tokens:
              type: integer
              format: int64
    TraceStep:
      type: object
      required:
        - step_id
        - commentary
        - code
        - strategy
      description: One reasoning step — its generated code, tool calls, strategy, and cost.
      properties:
        step_id:
          type: string
        commentary:
          type: string
        code:
          type: string
        calls:
          type: array
          items:
            $ref: '#/components/schemas/TraceCall'
        strategy:
          type: object
          required:
            - kind
            - fns
            - label
            - scope
          properties:
            kind:
              type: string
            fns:
              type: array
              items:
                type: string
            label:
              type: string
            scope:
              type: array
              items:
                type: string
        cost:
          type: object
          required:
            - tokens_in
            - tokens_out
            - decide_ms
            - execute_ms
          description: >-
            The step's incremental cost (deltas against the running turn
            cursor).
          properties:
            tokens_in:
              type: integer
              format: int64
            tokens_out:
              type: integer
              format: int64
            decide_ms:
              type: integer
              format: int64
            execute_ms:
              type: integer
              format: int64
            tokens_in_cached:
              type: integer
              format: int64
            tokens_in_cache_write:
              type: integer
              format: int64
            tokens_in_fresh:
              type: integer
              format: int64
    TraceCall:
      type: object
      required:
        - fn
        - category
        - args
        - result
        - duration_ms
        - ok
      description: One tool call within a step.
      properties:
        fn:
          type: string
        category:
          type: string
        args:
          type: object
          additionalProperties: true
          description: >-
            Compact, redacted summary of the call's arguments. The key set is
            tool-specific and deliberately open.
        result:
          description: >-
            Compact summary of the call's result (never the payload). The shape
            varies by category and is runtime-extensible.
        duration_ms:
          type: integer
          format: int64
        ok:
          type: boolean
        score_space:
          type: string
        error:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Session token from POST /auth/login. Pass as `Authorization: Bearer
        <token>`. The alternative `X-Pinecone-Api-Key` header is also accepted
        for direct-key auth (used by the Nexus CLI on first contact).
    apiKey:
      type: apiKey
      in: header
      name: X-Pinecone-Api-Key
      description: Pinecone API key, accepted as an alternative to the bearer JWT.

````