Skip to main content
POST
/
query
/
smart
TypeScript SDK
import { Orchata } from '@orchata/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'
});
{
  "relevantSpaces": [
    {
      "space": {
        "id": "<string>",
        "name": "<string>",
        "description": "<string>"
      },
      "relevanceScore": 123,
      "matchReason": "keyword_match"
    }
  ],
  "totalSpaces": 123
}

Authorizations

Oai-Api-Key
string
header
required

Body

application/json

Smart query request

query
string
required
Minimum string length: 1
maxSpaces
integer
default:3
Required range: 1 <= x <= 50
relevanceMethod
enum<string>
default:hybrid
Available options:
keyword,
embedding,
hybrid
keywordWeight
number
default:0.5
Required range: 0 <= x <= 1

Response

Successfully retrieved relevant spaces

relevantSpaces
object[]
required
totalSpaces
number
required