NewWacht Bench is live — AI-assisted development for Wacht

createKnowledgeBase()

This method manages AI knowledge base resources or their linked documents.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { wachtClient } from '@wacht/nextjs/server';export async function example() {  const client = await wachtClient();  const request: CreateAiKnowledgeBaseRequest = {    name: 'Product Docs',    description: 'Knowledge base for product documentation',  };  return client.ai.createKnowledgeBase(request);}

Signature

function createKnowledgeBase(  request: CreateAiKnowledgeBaseRequest,  client?: WachtClient,): Promise<AiKnowledgeBase>

Parameters

request: CreateAiKnowledgeBaseRequest;
Request payload object sent to the backend API.
name?: string | undefined;
Display name for the target resource.
description?: string | undefined;
Optional description text.

Return value

id?: string | undefined;
Knowledge base id.
name?: string | undefined;
Knowledge base name.
description?: string | undefined;
Knowledge base description.

Examples

AI usage pattern

import { wachtClient } from '@wacht/nextjs/server';export async function createKbAndUpload(file: File) {  const client = await wachtClient();  const kb = await client.ai.createKnowledgeBase({    name: 'Support Docs',    description: 'Knowledge base for support runbooks',  });  const doc = await client.ai.uploadKnowledgeBaseDocument(kb.id, file, 'runbook.md', 'Support runbook');  return { kb, doc };}

On this page