---
title: "POST /knowledgebases/{knowledgeBaseId}/retrieve"
method: POST
path: "/knowledgebases/{knowledgeBaseId}/retrieve"
---

# POST /knowledgebases/{knowledgeBaseId}/retrieve

`POST /knowledgebases/{knowledgeBaseId}/retrieve`

Queries a knowledge base and retrieves information from it.

## Path parameters

- `knowledgeBaseId` string, required

## Request body

- object
  - `guardrailConfiguration` object — The configuration details for the guardrail.
    - `guardrailId` string — The unique identifier for the guardrail.
    - `guardrailVersion` string — The version of the guardrail.
  - `nextToken` string — If there are more results than can fit in the response, the response returns a <code>nextToken</code>. Use this token in the <code>nextToken</code> field of another request to retrieve the next batch of results.
  - `retrievalConfiguration` object — <p>Contains configurations for knowledge base query. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html">Query configurations</a>.</p> <p>This data type is used in the following API operations:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html#API_agent-runtime_Retrieve_RequestSyntax">Retrieve request</a> – in the <code>retrievalConfiguration</code> field</p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrieveAndGenerate.html#API_agent-runtime_RetrieveAndGenerate_RequestSyntax">RetrieveAndGenerate request</a> – in the <code>retrievalConfiguration</code> field</p> </li> </ul>
    - `managedSearchConfiguration` object — Contains configurations for managed search. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html">Query configurations</a>.
      - `filter` RetrievalFilter — <p>Specifies the filters to use on the metadata attributes in the knowledge base data sources before returning results. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html">Query configurations</a>. See the examples below to see how to use these filters.</p> <p>This data type is used in the following API operations:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html#API_agent-runtime_Retrieve_RequestSyntax">Retrieve request</a> – in the <code>filter</code> field</p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrieveAndGenerate.html#API_agent-runtime_RetrieveAndGenerate_RequestSyntax">RetrieveAndGenerate request</a> – in the <code>filter</code> field</p> </li> </ul>
        - `andAll` RetrievalFilter[] — Knowledge base data sources are returned if their metadata attributes fulfill all the filter conditions inside this list.
        - `equals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value matches the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>animal</code> attribute whose value is <code>cat</code>:</p> <p> <code>"equals": { "key": "animal", "value": "cat" }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `greaterThan` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is greater than the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is greater than <code>1989</code>:</p> <p> <code>"greaterThan": { "key": "year", "value": 1989 }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `greaterThanOrEquals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is greater than or equal to the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is greater than or equal to <code>1989</code>:</p> <p> <code>"greaterThanOrEquals": { "key": "year", "value": 1989 }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `in` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is in the list specified in the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>animal</code> attribute that is either <code>cat</code> or <code>dog</code>:</p> <p> <code>"in": { "key": "animal", "value": ["cat", "dog"] }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `lessThan` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is less than the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is less than to <code>1989</code>.</p> <p> <code>"lessThan": { "key": "year", "value": 1989 }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `lessThanOrEquals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is less than or equal to the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is less than or equal to <code>1989</code>.</p> <p> <code>"lessThanOrEquals": { "key": "year", "value": 1989 }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `listContains` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is a list that contains the <code>value</code> as one of its members.</p> <p>The following example would return data sources with an <code>animals</code> attribute that is a list containing a <code>cat</code> member (for example <code>["dog", "cat"]</code>).</p> <p> <code>"listContains": { "key": "animals", "value": "cat" }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `notEquals` object — <p>Knowledge base data sources are returned when:</p> <ul> <li> <p>It contains a metadata attribute whose name matches the <code>key</code> and whose value doesn't match the <code>value</code> in this object.</p> </li> <li> <p>The key is not present in the document.</p> </li> </ul> <p>The following example would return data sources that don't contain an <code>animal</code> attribute whose value is <code>cat</code>.</p> <p> <code>"notEquals": { "key": "animal", "value": "cat" }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `notIn` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value isn't in the list specified in the <code>value</code> in this object.</p> <p>The following example would return data sources whose <code>animal</code> attribute is neither <code>cat</code> nor <code>dog</code>.</p> <p> <code>"notIn": { "key": "animal", "value": ["cat", "dog"] }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `orAll` RetrievalFilter[] — Knowledge base data sources are returned if their metadata attributes fulfill at least one of the filter conditions inside this list.
        - `startsWith` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value starts with the <code>value</code> in this object. This filter is currently only supported for Amazon OpenSearch Serverless vector stores.</p> <p>The following example would return data sources with an <code>animal</code> attribute starts with <code>ca</code> (for example, <code>cat</code> or <code>camel</code>).</p> <p> <code>"startsWith": { "key": "animal", "value": "ca" }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `stringContains` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is one of the following:</p> <ul> <li> <p>A string that contains the <code>value</code> as a substring. The following example would return data sources with an <code>animal</code> attribute that contains the substring <code>at</code> (for example <code>cat</code>).</p> <p> <code>"stringContains": { "key": "animal", "value": "at" }</code> </p> </li> <li> <p>A list with a member that contains the <code>value</code> as a substring. The following example would return data sources with an <code>animals</code> attribute that is a list containing a member that contains the substring <code>at</code> (for example <code>["dog", "cat"]</code>).</p> <p> <code>"stringContains": { "key": "animals", "value": "at" }</code> </p> </li> </ul>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
      - `numberOfResults` integer — The number of results to retrieve.
      - `rerankingConfiguration` object — Contains configurations for reranking the results retrieved from the managed search.
        - `bedrockRerankingConfiguration` object — The Bedrock reranking model configuration for managed search.
          - `metadataConfiguration` object — The metadata configuration for reranking.
            - `selectionMode` 'SELECTIVE' | 'ALL', required — Specifies whether to consider all metadata when reranking, or only the metadata that you select. If you specify <code>SELECTIVE</code>, include the <code>selectiveModeConfiguration</code> field.
            - `selectiveModeConfiguration` object — Contains configurations for the metadata fields to include or exclude when considering reranking.
              - …
          - `modelConfiguration` object, required — The model configuration containing the model ARN for reranking.
            - `additionalModelRequestFields` object — Additional request fields to pass to the reranking model.
            - `modelArn` string, required — The ARN of the Bedrock reranking model.
          - `numberOfRerankedResults` integer — The number of results to return after reranking.
        - `type` 'BEDROCK_RERANKING_MODEL', required — The type of reranking configuration.
      - `rerankingModelType` 'CUSTOM' | 'MANAGED' | 'NONE' — The type of reranking model to use when reranking results retrieved from the managed search. Use <code>CUSTOM</code> to specify a model, <code>MANAGED</code> to use the service default, or <code>NONE</code> to disable reranking.
    - `vectorSearchConfiguration` object — Contains details about how the results from the vector search should be returned. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html">Query configurations</a>.
      - `filter` object — Specifies the filters to use on the metadata in the knowledge base data sources before returning results. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html">Query configurations</a>.
        - `andAll` RetrievalFilter[] — Knowledge base data sources are returned if their metadata attributes fulfill all the filter conditions inside this list.
          - `andAll` RetrievalFilter[] — Knowledge base data sources are returned if their metadata attributes fulfill all the filter conditions inside this list.
          - `equals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value matches the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>animal</code> attribute whose value is <code>cat</code>:</p> <p> <code>"equals": { "key": "animal", "value": "cat" }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `greaterThan` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is greater than the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is greater than <code>1989</code>:</p> <p> <code>"greaterThan": { "key": "year", "value": 1989 }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `greaterThanOrEquals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is greater than or equal to the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is greater than or equal to <code>1989</code>:</p> <p> <code>"greaterThanOrEquals": { "key": "year", "value": 1989 }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `in` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is in the list specified in the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>animal</code> attribute that is either <code>cat</code> or <code>dog</code>:</p> <p> <code>"in": { "key": "animal", "value": ["cat", "dog"] }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `lessThan` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is less than the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is less than to <code>1989</code>.</p> <p> <code>"lessThan": { "key": "year", "value": 1989 }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `lessThanOrEquals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is less than or equal to the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is less than or equal to <code>1989</code>.</p> <p> <code>"lessThanOrEquals": { "key": "year", "value": 1989 }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `listContains` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is a list that contains the <code>value</code> as one of its members.</p> <p>The following example would return data sources with an <code>animals</code> attribute that is a list containing a <code>cat</code> member (for example <code>["dog", "cat"]</code>).</p> <p> <code>"listContains": { "key": "animals", "value": "cat" }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `notEquals` object — <p>Knowledge base data sources are returned when:</p> <ul> <li> <p>It contains a metadata attribute whose name matches the <code>key</code> and whose value doesn't match the <code>value</code> in this object.</p> </li> <li> <p>The key is not present in the document.</p> </li> </ul> <p>The following example would return data sources that don't contain an <code>animal</code> attribute whose value is <code>cat</code>.</p> <p> <code>"notEquals": { "key": "animal", "value": "cat" }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `notIn` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value isn't in the list specified in the <code>value</code> in this object.</p> <p>The following example would return data sources whose <code>animal</code> attribute is neither <code>cat</code> nor <code>dog</code>.</p> <p> <code>"notIn": { "key": "animal", "value": ["cat", "dog"] }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `orAll` RetrievalFilter[] — Knowledge base data sources are returned if their metadata attributes fulfill at least one of the filter conditions inside this list.
          - `startsWith` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value starts with the <code>value</code> in this object. This filter is currently only supported for Amazon OpenSearch Serverless vector stores.</p> <p>The following example would return data sources with an <code>animal</code> attribute starts with <code>ca</code> (for example, <code>cat</code> or <code>camel</code>).</p> <p> <code>"startsWith": { "key": "animal", "value": "ca" }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `stringContains` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is one of the following:</p> <ul> <li> <p>A string that contains the <code>value</code> as a substring. The following example would return data sources with an <code>animal</code> attribute that contains the substring <code>at</code> (for example <code>cat</code>).</p> <p> <code>"stringContains": { "key": "animal", "value": "at" }</code> </p> </li> <li> <p>A list with a member that contains the <code>value</code> as a substring. The following example would return data sources with an <code>animals</code> attribute that is a list containing a member that contains the substring <code>at</code> (for example <code>["dog", "cat"]</code>).</p> <p> <code>"stringContains": { "key": "animals", "value": "at" }</code> </p> </li> </ul>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `equals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value matches the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>animal</code> attribute whose value is <code>cat</code>:</p> <p> <code>"equals": { "key": "animal", "value": "cat" }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `greaterThan` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is greater than the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is greater than <code>1989</code>:</p> <p> <code>"greaterThan": { "key": "year", "value": 1989 }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `greaterThanOrEquals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is greater than or equal to the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is greater than or equal to <code>1989</code>:</p> <p> <code>"greaterThanOrEquals": { "key": "year", "value": 1989 }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `in` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is in the list specified in the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>animal</code> attribute that is either <code>cat</code> or <code>dog</code>:</p> <p> <code>"in": { "key": "animal", "value": ["cat", "dog"] }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `lessThan` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is less than the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is less than to <code>1989</code>.</p> <p> <code>"lessThan": { "key": "year", "value": 1989 }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `lessThanOrEquals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is less than or equal to the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is less than or equal to <code>1989</code>.</p> <p> <code>"lessThanOrEquals": { "key": "year", "value": 1989 }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `listContains` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is a list that contains the <code>value</code> as one of its members.</p> <p>The following example would return data sources with an <code>animals</code> attribute that is a list containing a <code>cat</code> member (for example <code>["dog", "cat"]</code>).</p> <p> <code>"listContains": { "key": "animals", "value": "cat" }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `notEquals` object — <p>Knowledge base data sources are returned when:</p> <ul> <li> <p>It contains a metadata attribute whose name matches the <code>key</code> and whose value doesn't match the <code>value</code> in this object.</p> </li> <li> <p>The key is not present in the document.</p> </li> </ul> <p>The following example would return data sources that don't contain an <code>animal</code> attribute whose value is <code>cat</code>.</p> <p> <code>"notEquals": { "key": "animal", "value": "cat" }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `notIn` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value isn't in the list specified in the <code>value</code> in this object.</p> <p>The following example would return data sources whose <code>animal</code> attribute is neither <code>cat</code> nor <code>dog</code>.</p> <p> <code>"notIn": { "key": "animal", "value": ["cat", "dog"] }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `orAll` RetrievalFilter[] — Knowledge base data sources are returned if their metadata attributes fulfill at least one of the filter conditions inside this list.
          - `andAll` RetrievalFilter[] — Knowledge base data sources are returned if their metadata attributes fulfill all the filter conditions inside this list.
          - `equals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value matches the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>animal</code> attribute whose value is <code>cat</code>:</p> <p> <code>"equals": { "key": "animal", "value": "cat" }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `greaterThan` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is greater than the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is greater than <code>1989</code>:</p> <p> <code>"greaterThan": { "key": "year", "value": 1989 }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `greaterThanOrEquals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is greater than or equal to the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is greater than or equal to <code>1989</code>:</p> <p> <code>"greaterThanOrEquals": { "key": "year", "value": 1989 }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `in` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is in the list specified in the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>animal</code> attribute that is either <code>cat</code> or <code>dog</code>:</p> <p> <code>"in": { "key": "animal", "value": ["cat", "dog"] }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `lessThan` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is less than the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is less than to <code>1989</code>.</p> <p> <code>"lessThan": { "key": "year", "value": 1989 }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `lessThanOrEquals` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is less than or equal to the <code>value</code> in this object.</p> <p>The following example would return data sources with an <code>year</code> attribute whose value is less than or equal to <code>1989</code>.</p> <p> <code>"lessThanOrEquals": { "key": "year", "value": 1989 }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `listContains` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is a list that contains the <code>value</code> as one of its members.</p> <p>The following example would return data sources with an <code>animals</code> attribute that is a list containing a <code>cat</code> member (for example <code>["dog", "cat"]</code>).</p> <p> <code>"listContains": { "key": "animals", "value": "cat" }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `notEquals` object — <p>Knowledge base data sources are returned when:</p> <ul> <li> <p>It contains a metadata attribute whose name matches the <code>key</code> and whose value doesn't match the <code>value</code> in this object.</p> </li> <li> <p>The key is not present in the document.</p> </li> </ul> <p>The following example would return data sources that don't contain an <code>animal</code> attribute whose value is <code>cat</code>.</p> <p> <code>"notEquals": { "key": "animal", "value": "cat" }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `notIn` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value isn't in the list specified in the <code>value</code> in this object.</p> <p>The following example would return data sources whose <code>animal</code> attribute is neither <code>cat</code> nor <code>dog</code>.</p> <p> <code>"notIn": { "key": "animal", "value": ["cat", "dog"] }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `orAll` RetrievalFilter[] — Knowledge base data sources are returned if their metadata attributes fulfill at least one of the filter conditions inside this list.
          - `startsWith` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value starts with the <code>value</code> in this object. This filter is currently only supported for Amazon OpenSearch Serverless vector stores.</p> <p>The following example would return data sources with an <code>animal</code> attribute starts with <code>ca</code> (for example, <code>cat</code> or <code>camel</code>).</p> <p> <code>"startsWith": { "key": "animal", "value": "ca" }</code> </p>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
          - `stringContains` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is one of the following:</p> <ul> <li> <p>A string that contains the <code>value</code> as a substring. The following example would return data sources with an <code>animal</code> attribute that contains the substring <code>at</code> (for example <code>cat</code>).</p> <p> <code>"stringContains": { "key": "animal", "value": "at" }</code> </p> </li> <li> <p>A list with a member that contains the <code>value</code> as a substring. The following example would return data sources with an <code>animals</code> attribute that is a list containing a member that contains the substring <code>at</code> (for example <code>["dog", "cat"]</code>).</p> <p> <code>"stringContains": { "key": "animals", "value": "at" }</code> </p> </li> </ul>
            - `key` string, required — The name that the metadata attribute must match.
            - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `startsWith` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value starts with the <code>value</code> in this object. This filter is currently only supported for Amazon OpenSearch Serverless vector stores.</p> <p>The following example would return data sources with an <code>animal</code> attribute starts with <code>ca</code> (for example, <code>cat</code> or <code>camel</code>).</p> <p> <code>"startsWith": { "key": "animal", "value": "ca" }</code> </p>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
        - `stringContains` object — <p>Knowledge base data sources are returned if they contain a metadata attribute whose name matches the <code>key</code> and whose value is one of the following:</p> <ul> <li> <p>A string that contains the <code>value</code> as a substring. The following example would return data sources with an <code>animal</code> attribute that contains the substring <code>at</code> (for example <code>cat</code>).</p> <p> <code>"stringContains": { "key": "animal", "value": "at" }</code> </p> </li> <li> <p>A list with a member that contains the <code>value</code> as a substring. The following example would return data sources with an <code>animals</code> attribute that is a list containing a member that contains the substring <code>at</code> (for example <code>["dog", "cat"]</code>).</p> <p> <code>"stringContains": { "key": "animals", "value": "at" }</code> </p> </li> </ul>
          - `key` string, required — The name that the metadata attribute must match.
          - `value` object, required — The value to which to compare the value of the metadata attribute.
      - `implicitFilterConfiguration` object — Settings for implicit filtering.
        - `metadataAttributes` MetadataAttributeSchema[], required — Metadata that can be used in a filter.
          - `description` string, required — The attribute's description.
          - `key` string, required — The attribute's key.
          - `type` 'STRING' | 'NUMBER' | 'BOOLEAN' | 'STRING_LIST', required — The attribute's type.
        - `modelArn` string, required — The model that generates the filter.
      - `numberOfResults` integer — The number of source chunks to retrieve.
      - `overrideSearchType` 'HYBRID' | 'SEMANTIC' — By default, Amazon Bedrock decides a search strategy for you. If you're using an Amazon OpenSearch Serverless vector store that contains a filterable text field, you can specify whether to query the knowledge base with a <code>HYBRID</code> search using both vector embeddings and raw text, or <code>SEMANTIC</code> search using only vector embeddings. For other vector store configurations, only <code>SEMANTIC</code> search is available. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-test.html">Test a knowledge base</a>.
      - `rerankingConfiguration` object — Contains configurations for reranking the retrieved results. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/rerank.html">Improve the relevance of query responses with a reranker model</a>.
        - `bedrockRerankingConfiguration` object — Contains configurations for an Amazon Bedrock reranker model.
          - `metadataConfiguration` object — Contains configurations for the metadata to use in reranking.
            - `selectionMode` 'SELECTIVE' | 'ALL', required — Specifies whether to consider all metadata when reranking, or only the metadata that you select. If you specify <code>SELECTIVE</code>, include the <code>selectiveModeConfiguration</code> field.
            - `selectiveModeConfiguration` object — Contains configurations for the metadata fields to include or exclude when considering reranking.
              - …
          - `modelConfiguration` object, required — Contains configurations for the reranker model.
            - `additionalModelRequestFields` object — A JSON object whose keys are request fields for the model and whose values are values for those fields.
            - `modelArn` string, required — The ARN of the reranker model to use.
          - `numberOfRerankedResults` integer — The number of results to return after reranking.
        - `type` 'BEDROCK_RERANKING_MODEL', required — The type of reranker model.
  - `retrievalQuery` object, required — <p>Contains the query made to the knowledge base.</p> <p>This data type is used in the following API operations:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html#API_agent-runtime_Retrieve_RequestSyntax">Retrieve request</a> – in the <code>retrievalQuery</code> field</p> </li> </ul>
    - `image` object — An image to include in the knowledge base query for multimodal retrieval.
      - `format` 'png' | 'jpeg' | 'gif' | 'webp', required — The format of the input image. Supported formats include png, gif, jpeg, and webp.
      - `inlineContent` string, password, required — The base64-encoded image data for inline image content. Maximum size is 5MB.
    - `text` string — The text of the query made to the knowledge base.
    - `type` 'TEXT' | 'IMAGE' — The type of query being performed.
  - `userContext` object — Contains information about the user making the request. Use this to pass user identity information for access control filtering, so that retrieval results only include documents the user is authorized to access.
    - `userId` string — The identifier of the user making the retrieval request.

## Response `200`

Success

- RetrieveResponse
  - `guardrailAction` 'INTERVENED' | 'NONE' — Specifies if there is a guardrail intervention in the response.
  - `nextToken` string — If there are more results than can fit in the response, the response returns a <code>nextToken</code>. Use this token in the <code>nextToken</code> field of another request to retrieve the next batch of results.
  - `retrievalResults` KnowledgeBaseRetrievalResult[], required — A list of results from querying the knowledge base.
    - `content` object, required — Contains information about the content of the chunk.
      - `audio` object — Audio segment information when the retrieval result contains audio content.
        - `s3Uri` string, required — The S3 URI where this specific audio segment is stored in the multimodal storage destination.
        - `transcription` string — The text transcription of the audio segment content.
      - `byteContent` string — A data URI with base64-encoded content from the data source. The URI is in the following format: returned in the following format: <code>data:image/jpeg;base64,${base64-encoded string}</code>.
      - `row` RetrievalResultContentColumn[] — Specifies information about the rows with the cells to return in retrieval.
        - `columnName` string — The name of the column.
        - `columnValue` string — The value in the column.
        - `type` 'BLOB' | 'BOOLEAN' | 'DOUBLE' | 'NULL' | 'LONG' | 'STRING' — The data type of the value.
      - `text` string — The cited text from the data source.
      - `type` 'TEXT' | 'IMAGE' | 'ROW' | 'AUDIO' | 'VIDEO' — The type of content in the retrieval result.
      - `video` object — Video segment information when the retrieval result contains video content.
        - `s3Uri` string, required — The S3 URI where this specific video segment is stored in the multimodal storage destination.
        - `summary` string — A text summary describing the content of the video segment.
    - `documentId` string — The unique identifier of the document. Use with <code>GetDocumentContent</code> to retrieve the full document.
    - `location` object — Contains information about the location of the data source.
      - `confluenceLocation` object — The Confluence data source location.
        - `url` string — The Confluence host URL for the data source location.
      - `customDocumentLocation` object — Specifies the location of a document in a custom data source.
        - `id` string — The ID of the document.
      - `googleDriveLocation` object — The Google Drive data source location.
        - `url` string — The Google Drive URL for the data source location.
      - `kendraDocumentLocation` object — The location of a document in Amazon Kendra.
        - `uri` string — The document's uri.
      - `oneDriveLocation` object — The Microsoft OneDrive data source location.
        - `url` string — The OneDrive URL for the data source location.
      - `s3Location` object — The S3 data source location.
        - `uri` string — The S3 URI for the data source location.
      - `salesforceLocation` object — The Salesforce data source location.
        - `url` string — The Salesforce host URL for the data source location.
      - `sharePointLocation` object — The SharePoint data source location.
        - `url` string — The SharePoint site URL for the data source location.
      - `sqlLocation` object — Specifies information about the SQL query used to retrieve the result.
        - `query` string — The SQL query used to retrieve the result.
      - `type` 'S3' | 'WEB' | 'CONFLUENCE' | 'SALESFORCE' | 'SHAREPOINT' | 'CUSTOM' | 'KENDRA' | 'SQL' | 'ONEDRIVE' | 'GOOGLEDRIVE', required — The type of data source location.
      - `webLocation` object — The web URL/URLs data source location.
        - `url` string — The web URL/URLs for the data source location.
    - `metadata` object — Contains metadata attributes and their values for the file in the data source. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-ds.html#kb-ds-metadata">Metadata and filtering</a>.
    - `score` number, double — The level of relevance of the result to the query.

## Other responses

- `480` — ResourceNotFoundException
- `481` — ConflictException
- `482` — ValidationException
- `483` — InternalServerException
- `484` — DependencyFailedException
- `485` — BadGatewayException
- `486` — ThrottlingException
- `487` — AccessDeniedException
- `488` — ServiceQuotaExceededException

---

[API](https://skmtc.net/aws/apis/bedrock-agent-runtime.md) · [All operations](https://skmtc.net/aws/apis/bedrock-agent-runtime/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/aws/bedrock-agent-runtime/versions/fe358131c0ad/schema)
