GET
/
v4
/
knowledge-bases
/
{knowledge_base_id}
/
chunks
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.chunks.list('knowledge_base_id')) {
    console.log(chunk.chunk_id);
  }
}

main();
{
  "chunks": [
    {
      "chunk_id": "<string>",
      "text": "<string>",
      "embedding": [
        123
      ],
      "metadata": {},
      "user_supplied_metadata": {},
      "attachment_url": "<string>",
      "title": "<string>"
    }
  ]
}

Authorizations

x-api-key
string
header
required

Path Parameters

knowledge_base_id
string
required

Query Parameters

chunk_id
string | null

Optional search by chunk_id

metadata_filters
string | null

Optional search by metadata fields, encoded as a JSON object

max_chunks
integer
default:
10

Maximum number of chunks returned by the get_chunks endpoint. Defaults to 10 and cannot be greater than 2000.

Required range: 1 < x < 2000

Response

200
application/json
Successful Response
chunks
object[]
required

List of chunks that match the chunk_id and metadata filters