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

# Query the vector database for semantic search

> Proxies to the WG vector DB (Chroma). Use for semantic / nearest-neighbor lookups across spell or feat names and descriptions.



## OpenAPI

````yaml POST /vector-db-query-collection
openapi: 3.1.0
info:
  title: Wanderer's Guide API
  description: >-
    Public HTTP API for Wanderer's Guide, the Pathfinder 2e character builder.
    Every endpoint is a Supabase Edge Function reached via `POST
    /functions/v1/<name>`. All responses follow the
    [JSend](https://github.com/omniti-labs/jsend) convention: `{ status:
    'success' | 'fail' | 'error', data?, message? }`.
  version: 1.0.0
  contact:
    name: Wanderer's Guide Discord
    url: https://discord.com/invite/FxsFZVvedr
  license:
    name: MIT
    url: https://github.com/wanderers-guide/wanderers-guide/blob/main/LICENSE
servers:
  - url: https://api.wanderersguide.app/functions/v1
    description: Production
  - url: '{supabaseUrl}/functions/v1'
    description: Self-hosted Supabase
    variables:
      supabaseUrl:
        default: http://127.0.0.1:54321
        description: Base URL of your Supabase instance, including scheme and port.
security:
  - apiKeyAuth: []
tags:
  - name: Content
    description: 'Pathfinder 2e content: spells, items, feats, ancestries, classes, etc.'
  - name: Characters
    description: Player characters.
  - name: Campaigns
    description: Campaigns and encounters.
  - name: GM
    description: 'Game-master tools: group management, access codes.'
  - name: Users
    description: Public user profiles, account management, Patreon integration.
  - name: Search
    description: Full-text and advanced search across content.
  - name: Files
    description: User-uploaded portrait and background images.
  - name: Integrations
    description: Vector DB and Discord webhooks.
paths:
  /vector-db-query-collection:
    post:
      tags:
        - Integrations
      summary: Query the vector database for semantic search
      description: >-
        Requires a verified, non-anonymous signed-in WG user (or API key for
        that user). Queries name/content collections with a 64 KiB wire limit
        and 20-second upstream deadline. One daily work unit per 4,000 query
        characters or per 10 requested results, whichever is greater; 1,000
        units per account and 20,000 globally.
      operationId: vectorDbQueryCollection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - collection
                - query
              properties:
                collection:
                  type: string
                  enum:
                    - name
                    - content
                nResults:
                  type: integer
                  default: 1
                  minimum: 1
                  maximum: 50
                maxDistance:
                  type: number
                  description: 0.0 = identical; higher = more dissimilar.
                  minimum: 0
                  maximum: 10
                  default: 1
                query:
                  type: string
                  minLength: 1
                  maxLength: 16000
                where:
                  type: object
                  additionalProperties: false
                  required:
                    - _type
                  properties:
                    _type:
                      $ref: '#/components/schemas/ContentType'
              additionalProperties: false
      responses:
        '200':
          description: JSend success with nearest matches.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  data:
                    type: array
                    maxItems: 50
                    items:
                      type: object
                      properties:
                        distance:
                          type: number
                        data:
                          type: object
                          additionalProperties: true
        '400':
          description: Invalid request fields or bounds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendFail'
        '401':
          description: >-
            Missing, invalid or expired credentials. Invalid sessions return
            data.code AUTH_REQUIRED; refresh or sign in before resuming.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendFail'
        '403':
          description: >-
            A WG profile is required; population additionally requires an
            administrator.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendFail'
        '413':
          description: >-
            JSON request exceeds the wire-body limit (8 MiB unless this endpoint
            specifies a smaller limit).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendFail'
        '429':
          description: >-
            Admission or work budget exceeded; Retry-After gives the delay in
            seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendFail'
        '502':
          description: The external service failed or returned an invalid response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendError'
        '503':
          description: The shared work budget is unavailable; no external request is made.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendError'
        '504':
          description: The external service exceeded its deadline.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendError'
components:
  schemas:
    ContentType:
      type: string
      enum:
        - trait
        - item
        - spell
        - class
        - archetype
        - versatile-heritage
        - class-archetype
        - ability-block
        - creature
        - ancestry
        - background
        - language
        - content-source
    JSendFail:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: string
          enum:
            - fail
        data:
          type: object
          properties:
            message:
              type: string
    JSendError:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
        data: {}
        code:
          type: integer
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key (UUID, 36 chars)
      description: >-
        API key created in your Wanderer's Guide account settings. Send as
        `Authorization: Bearer <key>`. Used for direct API access from external
        tools and scripts.

````