POST
/
v4
/
knowledge-bases
/
{knowledge_base_id}
/
artifacts
/
{artifact_id}
/
chunks
JavaScript
import SGPClient from 'sgp';

const client = new SGPClient({
  apiKey: 'My API Key',
});

const chunk = await client.knowledgeBases.artifacts.chunks.create('knowledge_base_id', 'artifact_id', {
  chunk_position: 0,
  text: 'text',
});

console.log(chunk.id);
{
  "id": "<string>",
  "text": "<string>",
  "artifact_id": "<string>",
  "chunk_position": 123,
  "metadata": {},
  "user_supplied_metadata": {},
  "status": "Pending",
  "status_reason": "<string>",
  "created_at": "2023-11-07T05:31:56Z"
}

Authorizations

x-api-key
string
header
required

Path Parameters

knowledge_base_id
string
required
artifact_id
string
required

Body

application/json
text
string
required

Associated text of the chunk.

chunk_position
integer
required

Position of the chunk in the artifact.

metadata
object

Additional metadata associated with the chunk.

Response

Successful Response

id
string
required

The id of the chunk

text
string
required

The text of the chunk as stored in the database

artifact_id
string
required

The id of the artifact

chunk_position
integer
required

Chunk position

status
enum<string>
required

Status of the chunk. If Failed or Pending, its possible that the chunk does not reflect in OpenSearch

Available options:
Pending,
Completed,
Failed
metadata
object

Metadata of the chunk which is stored in OpenSearch

user_supplied_metadata
object

Metadata of the chunk which is stored in the database only provided via custom chunking.

status_reason
string

Status reason of the chunk. May be successful

created_at
string<date-time>

Date and time of chunk creation