TypeScript SDK
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'
});curl --request POST \
--url https://api.orchata.ai/api/query/smart \
--header 'Content-Type: application/json' \
--header 'Oai-Api-Key: <api-key>' \
--data '
{
"query": "<string>",
"maxSpaces": 3,
"relevanceMethod": "hybrid",
"keywordWeight": 0.5
}
'import requests
url = "https://api.orchata.ai/api/query/smart"
payload = {
"query": "<string>",
"maxSpaces": 3,
"relevanceMethod": "hybrid",
"keywordWeight": 0.5
}
headers = {
"Oai-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Oai-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({query: '<string>', maxSpaces: 3, relevanceMethod: 'hybrid', keywordWeight: 0.5})
};
fetch('https://api.orchata.ai/api/query/smart', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.orchata.ai/api/query/smart",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'maxSpaces' => 3,
'relevanceMethod' => 'hybrid',
'keywordWeight' => 0.5
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Oai-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.orchata.ai/api/query/smart"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"maxSpaces\": 3,\n \"relevanceMethod\": \"hybrid\",\n \"keywordWeight\": 0.5\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Oai-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.orchata.ai/api/query/smart")
.header("Oai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"maxSpaces\": 3,\n \"relevanceMethod\": \"hybrid\",\n \"keywordWeight\": 0.5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orchata.ai/api/query/smart")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Oai-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"maxSpaces\": 3,\n \"relevanceMethod\": \"hybrid\",\n \"keywordWeight\": 0.5\n}"
response = http.request(request)
puts response.read_body{
"relevantSpaces": [
{
"space": {
"id": "<string>",
"name": "<string>",
"description": "<string>"
},
"relevanceScore": 123,
"matchReason": "keyword_match"
}
],
"totalSpaces": 123
}Queries
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).
POST
/
api
/
query
/
smart
TypeScript SDK
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'
});curl --request POST \
--url https://api.orchata.ai/api/query/smart \
--header 'Content-Type: application/json' \
--header 'Oai-Api-Key: <api-key>' \
--data '
{
"query": "<string>",
"maxSpaces": 3,
"relevanceMethod": "hybrid",
"keywordWeight": 0.5
}
'import requests
url = "https://api.orchata.ai/api/query/smart"
payload = {
"query": "<string>",
"maxSpaces": 3,
"relevanceMethod": "hybrid",
"keywordWeight": 0.5
}
headers = {
"Oai-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Oai-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({query: '<string>', maxSpaces: 3, relevanceMethod: 'hybrid', keywordWeight: 0.5})
};
fetch('https://api.orchata.ai/api/query/smart', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.orchata.ai/api/query/smart",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'maxSpaces' => 3,
'relevanceMethod' => 'hybrid',
'keywordWeight' => 0.5
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Oai-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.orchata.ai/api/query/smart"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"maxSpaces\": 3,\n \"relevanceMethod\": \"hybrid\",\n \"keywordWeight\": 0.5\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Oai-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.orchata.ai/api/query/smart")
.header("Oai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"maxSpaces\": 3,\n \"relevanceMethod\": \"hybrid\",\n \"keywordWeight\": 0.5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orchata.ai/api/query/smart")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Oai-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"maxSpaces\": 3,\n \"relevanceMethod\": \"hybrid\",\n \"keywordWeight\": 0.5\n}"
response = http.request(request)
puts response.read_body{
"relevantSpaces": [
{
"space": {
"id": "<string>",
"name": "<string>",
"description": "<string>"
},
"relevanceScore": 123,
"matchReason": "keyword_match"
}
],
"totalSpaces": 123
}Authorizations
Body
application/json
Smart query request
Was this page helpful?
⌘I