Skip to content

Search

Semantic search in bases: top_k, score cutoff, and query multiple bases at once.

Updated on Aug 10, 2026

The search embeds the question with the same hinow/hiembed from ingestion (with caching — repeated questions don't re-embed) and compares it with indexed passages. Returns the closest matches, with similarity score (0 to 1) and metadata from the source document.

POSThttps://api.hinow.ai/v1/rag/searchBearer

Semantic search in base(s).

Parâmetros

  • querystring· bodyobrigatório
  • rag_idstring· body

    The base to query. Without `rag_id` and without `rag_ids`, searches ALL bases in the scope.

  • rag_idsarray· body

    Multiple bases at once (OR). Takes precedence over `rag_id`.

  • top_kinteger· body

    How many passages to return. Default 5.

  • min_scorenumber· body

    Similarity cutoff (0–1). Passages below are excluded. Between 0.5 and 0.7 works well.

Respostas

200Passages ordered by similarity
{
  "query": "quanto custa o plano diamante?",
  "results": [
    {
      "score": 0.652,
      "document_id": "3f6a1a5e...",
      "source": "planos.xlsx#Planos",
      "chunk_index": 0,
      "text": "Plano\tPreço mensal\nPrata\t99 reais\nOuro\t199 reais\nDiamante\t399 reais",
      "metadata": { "rag_id": "1d9cf4ae...", ... }
    }
  ],
  "embed_tokens": 7
}

One base, multiple, or all

With rag_id the search stays in the specified base; with rag_ids you query multiple at once (a support agent can look at FAQ + policies + catalog); without either, the search scans all bases in the key's scope — including vector stores vs_... from assistants.

Using passages in chat

The complete RAG pattern in two calls: fetch the passages, inject into the prompt, and let the model respond anchored to them.

import requests

HEADERS = {"Authorization": "Bearer hi_SUA_API_KEY"}
RAG_ID = "1d9cf4ae05f64a9faf987981b22cdeae"
pergunta = "posso pagar com pix?"

# 1. buscar os trechos
r = requests.post("https://api.hinow.ai/v1/rag/search", headers=HEADERS, json={
    "rag_id": RAG_ID, "query": pergunta, "top_k": 5, "min_score": 0.5,
}).json()
contexto = "\n\n".join(
    f"[{i+1}] {t['text']}" for i, t in enumerate(r["results"])
)

# 2. responder ancorado nos trechos
resp = requests.post("https://api.hinow.ai/v1/chat/completions", headers=HEADERS, json={
    "model": "hinow/himax",
    "messages": [
        {"role": "system", "content": (
            "Responda APENAS com base no contexto abaixo. "
            "Se a resposta não estiver lá, diga que não encontrou.\n\n"
            f"CONTEXTO:\n{contexto}"
        )},
        {"role": "user", "content": pergunta},
    ],
}).json()
print(resp["choices"][0]["message"]["content"])

Prefer search to happen on its own?

Link the base to an agent (RAG node in the builder) or use file search from the Assistants API — in both cases the model decides when to search and injection is automatic.

Was this page helpful?