---
title: "Retrieve context from an assistant"
method: POST
path: "/chat/{assistant_name}/context"
tags: ["Manage Assistants"]
---

# Retrieve context from an assistant

`POST /chat/{assistant_name}/context`

Retrieve context snippets from an assistant to use as part of RAG or any agentic flow.

For guidance and examples, see [Retrieve context snippets](https://docs.pinecone.io/guides/assistant/retrieve-context-snippets).

## Path parameters

- `assistant_name` string, required

## Headers

- `X-Pinecone-Api-Version` string, required

## Request body

- AssistantDataContextRequest — Parameters to retrieve context from an assistant.
  - `query` string — The query that is used to generate the context. Exactly one of query or messages should be provided.
  - `filter` object — Optionally filter which documents can be retrieved using the following metadata fields.
  - `messages` AssistantDataMessageModel[] — The list of messages to use for generating the context. Exactly one of query or messages should be provided.
    - `role` string — The role of the message author, it can be `user`, `assistant`, or `system`.
    - `content` string — The textual content of this partial message.
  - `top_k` integer — The maximum number of context snippets to return. Default is 16. Maximum is 64.
  - `snippet_size` integer — The maximum context snippet size. Default is 2048 tokens. Minimum is 512 tokens. Maximum is 8192 tokens.
  - `multimodal` boolean — Whether or not to retrieve image-related context snippets. If `false`, only text snippets are returned.
  - `include_binary_content` boolean — If image-related context snippets are returned, this field determines whether or not they should include base64 image data. If `false`, only the image captions are returned. Only available when `multimodal=true`.

## Response `200`

Context retrieval process successful.

- AssistantDataContextModel — Describes the context returned by an assistant in response to a query.
  - `id` string — A unique identifier for this context response.
  - `snippets` AssistantDataSnippetModel[], required — A list of context snippets relevant to the user's query.
    - union — Represents a part of a document that is relevant to the user query.
      - object — Represents a text context snippet.
        - `type` string, required — The type of context snippet. Always `text`.
        - `content` string, required — The textual content of the snippet.
        - `score` number, float, required — A numerical score indicating the relevance of this snippet to the query.
        - `reference` union, required — Represents a reference for the information provided.
          - object — Represents a reference to a part of a text document.
            - `type` string, required — The type of reference. Always `text`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
          - object — Represents a reference to a JSON document.
            - `type` string, required — The type of reference. Always `json`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
          - object — Represents a reference to a part of a markdown document.
            - `type` string, required — The type of reference. Always `markdown`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
          - object — Represents a reference to a part of a PDF document.
            - `type` string, required — The type of reference. Always `pdf`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
            - `pages` integer[], required — A list of page numbers in the PDF document that are relevant to the query.
          - object — Represents a reference to a part of a DOCX document.
            - `type` string, required — The type of reference. Always `doc_x`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
            - `pages` integer[], required — A list of page numbers in the DOCX document that are relevant to the query.
      - object — Represents a multimodal context snippet.
        - `type` string, required — The type of context snippet. Always `multimodal`.
        - `content` AssistantDataMultiModalContentBlocksModel[], required — A list of multimodal content blocks (text, images, etc.) included in this snippet.
          - union — Represents a block in the multimodal content of a context snippet.
            - object — Represents a text block in a multimodal context snippet.
              - …
            - object — Represents an image block in a multimodal context snippet.
              - …
        - `score` number, float, required — A numerical score indicating the relevance of this snippet to the user's query.
        - `reference` union, required — Represents a reference for the information provided.
          - object — Represents a reference to a part of a text document.
            - `type` string, required — The type of reference. Always `text`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
          - object — Represents a reference to a JSON document.
            - `type` string, required — The type of reference. Always `json`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
          - object — Represents a reference to a part of a markdown document.
            - `type` string, required — The type of reference. Always `markdown`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
          - object — Represents a reference to a part of a PDF document.
            - `type` string, required — The type of reference. Always `pdf`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
            - `pages` integer[], required — A list of page numbers in the PDF document that are relevant to the query.
          - object — Represents a reference to a part of a DOCX document.
            - `type` string, required — The type of reference. Always `doc_x`.
            - `file` AssistantDataAssistantFileModel, required — The response format for a successful file upload request.
              - …
            - `pages` integer[], required — A list of page numbers in the DOCX document that are relevant to the query.
  - `usage` AssistantDataUsageModel, required — Describes the token usage associated with interactions with an assistant.
    - `prompt_tokens` integer — For chat interactions, the number of tokens in the LLM request (message, context snippets, and system prompt). For context retrieval, the number of tokens in the LLM request used to generate search queries from the messages, plus the tokens in the retrieved context snippets.
    - `completion_tokens` integer — For chat interactions, the number of tokens in the assistant's response. For context retrieval, this is always 0.
    - `total_tokens` integer — The total number of tokens used, equal to the sum of `prompt_tokens` and `completion_tokens`.

## Other responses

- `400` — Bad request. The request body included invalid request parameters.
- `401` — Unauthorized. Possible causes: Invalid API key.
- `404` — Assistant not found.
- `500` — Internal server error.

---

[API](https://skmtc.net/pinecone/apis/pinecone-api.md) · [All operations](https://skmtc.net/pinecone/apis/pinecone-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pinecone/pinecone-api/versions/35876583485d/schema)
