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

> Complete retrieval pipeline for RAG with semantic search, filtering, and reranking

# Search a namespace



## OpenAPI

````yaml post /v1/namespace/{namespaceId}/search
openapi: 3.1.1
info:
  title: AgentsetAPI
  description: Agentset is agentic rag-as-a-service
  version: 0.0.1
  contact:
    name: Agentset Support
    email: support@agentset.ai
    url: https://api.agentset.ai/
  license:
    name: MIT License
    url: https://github.com/agentset-ai/agentset/blob/main/LICENSE.md
servers:
  - url: https://api.agentset.ai
    description: Production API
security: []
paths:
  /v1/namespace/{namespaceId}/search:
    post:
      tags:
        - Search
      summary: Search a namespace
      description: Search a namespace for a query.
      operationId: search
      parameters:
        - $ref: '#/components/parameters/NamespaceIdRef'
        - $ref: '#/components/parameters/TenantIdRef'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  description: The query to search for.
                topK:
                  default: 10
                  description: >-
                    The number of results to fetch from the vector store.
                    Defaults to `10`.
                  type: number
                  minimum: 1
                  maximum: 100
                rerank:
                  default: true
                  description: Whether to rerank the results. Defaults to `true`.
                  type: boolean
                rerankLimit:
                  description: >-
                    The number of results to return after reranking. Defaults to
                    `topK`.
                  type: number
                  minimum: 1
                  maximum: 100
                rerankModel:
                  default: zeroentropy:zerank-2
                  description: The reranking model to use.
                  type: string
                  enum:
                    - cohere:rerank-v4.0-pro
                    - cohere:rerank-v4.0-fast
                    - cohere:rerank-v3.5
                    - cohere:rerank-english-v3.0
                    - cohere:rerank-multilingual-v3.0
                    - zeroentropy:zerank-2
                    - zeroentropy:zerank-1
                    - zeroentropy:zerank-1-small
                filter:
                  description: A filter to apply to the results.
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties: {}
                minScore:
                  description: The minimum score to return.
                  type: number
                  minimum: 0
                  maximum: 1
                includeRelationships:
                  default: false
                  description: >-
                    Whether to include relationships in the results. Defaults to
                    `false`.
                  type: boolean
                includeMetadata:
                  default: true
                  description: >-
                    Whether to include metadata in the results. Defaults to
                    `true`.
                  type: boolean
                keywordFilter:
                  type: string
                mode:
                  default: semantic
                  type: string
                  enum:
                    - semantic
                    - keyword
              required:
                - query
      responses:
        '200':
          description: The retrieved namespace
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    const: true
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        score:
                          type: number
                          minimum: 0
                          maximum: 1
                        text:
                          type: string
                        relationships:
                          type: object
                          propertyNames:
                            type: string
                          additionalProperties: {}
                        metadata:
                          type: object
                          propertyNames:
                            type: string
                          additionalProperties: {}
                      required:
                        - id
                        - score
                      additionalProperties: false
                required:
                  - success
                  - data
                additionalProperties: false
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '409':
          $ref: '#/components/responses/409'
        '410':
          $ref: '#/components/responses/410'
        '422':
          $ref: '#/components/responses/422'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
      security:
        - token: []
      x-codeSamples:
        - lang: TypeScript
          source: |

            import { Agentset } from "agentset";

            const agentset = new Agentset({ apiKey: 'agentset_xxx' });
            const ns = agentset.namespace('ns_xxx');

            const results = await ns.search("What is machine learning?", {
              topK: 20,
              rerank: true,
              rerankLimit: 10,
            });
            console.log(results);
        - lang: python
          label: Python (SDK)
          source: |-
            from agentset import Agentset


            with Agentset(
                namespace_id="ns_123",
                x_tenant_id="<id>",
                token="AGENTSET_API_KEY",
            ) as a_client:

                res = a_client.search.execute(query="<value>", top_k=10, rerank=True, rerank_model="zeroentropy:zerank-2", include_relationships=False, include_metadata=True, mode="semantic")

                # Handle response
                print(res)
components:
  parameters:
    NamespaceIdRef:
      in: path
      name: namespaceId
      schema:
        type: string
        examples:
          - ns_123
        description: The id of the namespace (prefixed with ns_)
      x-speakeasy-globals-hidden: true
      required: true
      description: The id of the namespace (prefixed with ns_)
    TenantIdRef:
      in: header
      name: x-tenant-id
      schema:
        description: >-
          Optional tenant id to use for the request. If not provided, the
          namespace will be used directly. Must be alphanumeric and up to 64
          characters.
        type: string
        pattern: ^[A-Za-z0-9]{1,64}$
      description: >-
        Optional tenant id to use for the request. If not provided, the
        namespace will be used directly. Must be alphanumeric and up to 64
        characters.
  responses:
    '400':
      description: >-
        The server cannot or will not process the request due to something that
        is perceived to be a client error (e.g., malformed request syntax,
        invalid request message framing, or deceptive request routing).
      content:
        application/json:
          schema:
            x-speakeasy-name-override: BadRequest
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - bad_request
                    description: A short code indicating the error code returned.
                    example: bad_request
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://docs.agentset.ai/api-reference/errors#bad-request
                required:
                  - code
                  - message
            required:
              - success
              - error
    '401':
      description: >-
        Although the HTTP standard specifies "unauthorized", semantically this
        response means "unauthenticated". That is, the client must authenticate
        itself to get the requested response.
      content:
        application/json:
          schema:
            x-speakeasy-name-override: Unauthorized
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - unauthorized
                    description: A short code indicating the error code returned.
                    example: unauthorized
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://docs.agentset.ai/api-reference/errors#unauthorized
                required:
                  - code
                  - message
            required:
              - success
              - error
    '403':
      description: >-
        The client does not have access rights to the content; that is, it is
        unauthorized, so the server is refusing to give the requested resource.
        Unlike 401 Unauthorized, the client's identity is known to the server.
      content:
        application/json:
          schema:
            x-speakeasy-name-override: Forbidden
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - forbidden
                    description: A short code indicating the error code returned.
                    example: forbidden
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://docs.agentset.ai/api-reference/errors#forbidden
                required:
                  - code
                  - message
            required:
              - success
              - error
    '404':
      description: The server cannot find the requested resource.
      content:
        application/json:
          schema:
            x-speakeasy-name-override: NotFound
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - not_found
                    description: A short code indicating the error code returned.
                    example: not_found
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://docs.agentset.ai/api-reference/errors#not-found
                required:
                  - code
                  - message
            required:
              - success
              - error
    '409':
      description: >-
        This response is sent when a request conflicts with the current state of
        the server.
      content:
        application/json:
          schema:
            x-speakeasy-name-override: Conflict
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - conflict
                    description: A short code indicating the error code returned.
                    example: conflict
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://docs.agentset.ai/api-reference/errors#conflict
                required:
                  - code
                  - message
            required:
              - success
              - error
    '410':
      description: >-
        This response is sent when the requested content has been permanently
        deleted from server, with no forwarding address.
      content:
        application/json:
          schema:
            x-speakeasy-name-override: InviteExpired
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - invite_expired
                    description: A short code indicating the error code returned.
                    example: invite_expired
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: >-
                      https://docs.agentset.ai/api-reference/errors#invite-expired
                required:
                  - code
                  - message
            required:
              - success
              - error
    '422':
      description: >-
        The request was well-formed but was unable to be followed due to
        semantic errors.
      content:
        application/json:
          schema:
            x-speakeasy-name-override: UnprocessableEntity
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - unprocessable_entity
                    description: A short code indicating the error code returned.
                    example: unprocessable_entity
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: >-
                      https://docs.agentset.ai/api-reference/errors#unprocessable-entity
                required:
                  - code
                  - message
            required:
              - success
              - error
    '429':
      description: >-
        The user has sent too many requests in a given amount of time ("rate
        limiting")
      content:
        application/json:
          schema:
            x-speakeasy-name-override: RateLimitExceeded
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - rate_limit_exceeded
                    description: A short code indicating the error code returned.
                    example: rate_limit_exceeded
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: >-
                      https://docs.agentset.ai/api-reference/errors#rate-limit_exceeded
                required:
                  - code
                  - message
            required:
              - success
              - error
    '500':
      description: The server has encountered a situation it does not know how to handle.
      content:
        application/json:
          schema:
            x-speakeasy-name-override: InternalServerError
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - internal_server_error
                    description: A short code indicating the error code returned.
                    example: internal_server_error
                  message:
                    x-speakeasy-error-message: true
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: >-
                      https://docs.agentset.ai/api-reference/errors#internal-server_error
                required:
                  - code
                  - message
            required:
              - success
              - error
  securitySchemes:
    token:
      type: http
      description: Default authentication mechanism
      scheme: bearer
      x-speakeasy-example: AGENTSET_API_KEY

````