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

# Smart Query - Discover Relevant Spaces

> Discover the most relevant spaces for a query using hybrid keyword and embedding similarity. Returns space recommendations (not actual query results).



## OpenAPI

````yaml api/openapi.json post /api/query/smart
openapi: 3.1.0
info:
  version: '0.1'
  title: Orchata API
servers:
  - url: https://api.orchata.ai
    description: Orchata API Server
security:
  - ApiKey: []
paths:
  /api/query/smart:
    post:
      tags:
        - Queries
      summary: Smart Query - Discover Relevant Spaces
      description: >-
        Discover the most relevant spaces for a query using hybrid keyword and
        embedding similarity. Returns space recommendations (not actual query
        results).
      requestBody:
        description: Smart query request
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  minLength: 1
                maxSpaces:
                  type: integer
                  minimum: 1
                  maximum: 50
                  default: 3
                relevanceMethod:
                  type: string
                  enum:
                    - keyword
                    - embedding
                    - hybrid
                  default: hybrid
                keywordWeight:
                  type: number
                  minimum: 0
                  maximum: 1
                  default: 0.5
              required:
                - query
      responses:
        '200':
          description: Successfully retrieved relevant spaces
          content:
            application/json:
              schema:
                type: object
                properties:
                  relevantSpaces:
                    type: array
                    items:
                      type: object
                      properties:
                        space:
                          type: object
                          properties:
                            id:
                              type: string
                            name:
                              type: string
                            description:
                              type: string
                          required:
                            - id
                            - name
                            - description
                        relevanceScore:
                          type: number
                        matchReason:
                          type: string
                          enum:
                            - keyword_match
                            - embedding_similarity
                            - both
                      required:
                        - space
                        - relevanceScore
                        - matchReason
                  totalSpaces:
                    type: number
                required:
                  - relevantSpaces
                  - totalSpaces
        '400':
          description: Invalid request
        '401':
          description: Authentication required
      x-codeSamples:
        - lang: typescript
          label: TypeScript SDK
          source: |-
            import { Orchata } from '@orchata-ai/sdk';

            const client = new Orchata({ apiKey: 'oai_your_api_key' });

            // Discover relevant spaces
            const { relevantSpaces } = await client.smartQuery({
              query: 'How do I authenticate users?',
              maxSpaces: 3,
              relevanceMethod: 'hybrid'
            });

            // Then query those spaces
            const { results } = await client.query({
              spaceIds: relevantSpaces.map(s => s.space.id),
              query: 'user authentication'
            });
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Oai-Api-Key

````