POST
/
v4
/
knowledge-bases
/
{knowledge_base_id}
/
query
import SGPClient from 'sgp';

const client = new SGPClient({
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

async function main() {
  // Automatically fetches more pages as needed.
  for await (const chunk of client.knowledgeBases.query('knowledge_base_id', { query: 'query', top_k: 1 })) {
    console.log(chunk.chunk_id);
  }
}

main();
{
  "chunks": [
    {
      "chunk_id": "<string>",
      "text": "<string>",
      "embedding": [
        123
      ],
      "metadata": {},
      "user_supplied_metadata": {},
      "attachment_url": "<string>",
      "title": "<string>",
      "score": 123
    }
  ],
  "started_at": "2023-11-07T05:31:56Z",
  "completed_at": "2023-11-07T05:31:56Z",
  "request_id": "<string>"
}

Authorizations

x-api-key
string
header
required

Path Parameters

knowledge_base_id
string
required

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.