Bestseller
Knowledge Base RAG Streaming

AI RAG Knowledge Base Chat API

Build a private knowledge base and answer questions with citations

What can this API do?

Private knowledge bases from five document formats

Upload PDF, TXT, Markdown, HTML, and DOCX files for product guides, policies, support content, and internal documentation.

Evidence-based answers with citations

Generate answers from the uploaded content and return the supporting document passages for review and display.

Knowledge bases for each business context

Separate content by product, project, customer, or tenant while using one consistent API contract.

OpenAI-compatible JSON and real-time SSE

Use familiar chat completion responses for regular requests or stream answer text as it is generated.

Client-controlled multi-turn context

Send the complete conversation history your application wants the answer to consider on every request.

Replace and delete documents

Refresh a same-name document safely or remove a document when its content is no longer needed.

AI RAG Knowledge Base Chat API
Annual plan
$199
Try it for free!
Sign in to get a trial key and test all APIs.
Sign In
Secure checkout powered by Stripe

API Document

HTTP Protocol:HTTPS

HTTP Method:POST

HTTP Endpoint:https://api.gugudata.io/ai/knowledge-bases/{knowledge_base_id}/chat/completions

Response Type:application/json; charset=utf-8

DEMO Endpoint:https://api.gugudata.io/ai/knowledge-bases/default/chat/completions/demo

Live Demo:Try Interactive Demo

Full API Docs:developers.gugudata.io

API Request Parameters

NameTypeIs RequiredDefault ValueRemark
knowledge_base_idstringtruedefaultKnowledge base identifier in the URL path
appkeystringtrueYOUR_APPKEYApplication key obtained after subscription
modelstringfalsegugudata-knowledge-chatOpenAI Chat Completions compatible model name
messagesarray<object>true[{"role":"user","content":"What does the documentation say?"}]Complete client-managed conversation context with 1 to 20 system, user, or assistant messages
thread_idstringfalseOptional request correlation identifier; it does not restore server-side history
tenant_idstringfalsedefaultCustomer-defined knowledge base grouping; defaults to default
streambooleanfalsefalseReturn real-time Server-Sent Events when true
top_kintegerfalse6Number of retrieved source passages from 1 to 12

Upload Knowledge Base Documents

Upload documents and build a private knowledge base.

HTTP Endpoint:POST https://api.gugudata.io/ai/knowledge-bases/{knowledge_base_id}/documents

NameTypeIs RequiredRemark
knowledge_base_idstringtrueKnowledge base identifier; default may be used
appkeystringtrueApplication key obtained after subscription
filesarray<file>truePDF, TXT, Markdown, HTML, or DOCX documents; up to 5 files and 20 MB per file
tenant_idstringfalseCustomer-defined business grouping; defaults to default
metadataobjectfalseCustomer-defined metadata as a JSON object up to 8 KiB
replace_existingbooleanfalseReplace an existing document with the same name when true

Delete Knowledge Base Document

Delete one document and its searchable content from a private knowledge base.

HTTP Endpoint:DELETE https://api.gugudata.io/ai/knowledge-bases/{knowledge_base_id}/documents/{document_id}

NameTypeIs RequiredRemark
knowledge_base_idstringtrueKnowledge base identifier
document_idstringtrueDocument identifier returned by the upload operation
appkeystringtrueApplication key obtained after subscription
tenant_idstringfalseCustomer-defined knowledge base grouping; defaults to default

API Response Parameters

NameTypeRemark
idstringChat completion response identifier
message_idstringIdentifier for the generated answer
objectstringOpenAI-compatible response object type
thread_idstringRequest correlation identifier returned to the client
choices[0].message.contentstringAnswer generated from uploaded documents
sourcesarray<object>Document passages cited by the answer
usageobjectUsage summary for the request

API Response Status Codes

Status CodeExplanation of Status CodeRemarks
200Request processed successfully.Some endpoints expose a separate application-level status field in the response body, such as `dataStatus.statusCode`.
400Invalid request parameters or request format.Check required fields, data types, and request body format.
401Missing or unknown application key.Provide a valid `appkey` with the request.
403The application key is recognized but access is not allowed.The key may be expired, inactive, or not permitted for the requested API.
429Request rate or trial usage limit exceeded.Reduce concurrency or retry after the limit window resets.
500Internal service error.Retry later or contact support if the error persists.
503Upstream service unavailable.Retry later; the requested upstream dependency is temporarily unavailable.

Remote MCP

AI client access

Use this API through GuGuData Remote MCP

Connect your AI client once, authorize in the browser, and the client can use the GuGuData API tools available to your account. You do not need to paste an appkey into the MCP client.

Endpoint https://mcp.gugudata.io/mcp
Open MCP Guide
Generic MCP configuration
{
  "mcpServers": {
    "gugudata": {
      "url": "https://mcp.gugudata.io/mcp",
      "transportType": "streamable-http"
    }
  }
}

Code Snippets