Skip to content

OpenAI-compatible RAG API, widgets and channels

DocsGPT exposes an OpenAI-compatible /v1/chat/completions endpoint and a native streaming API per agent, plus open-source chat and search widgets, webhooks, and Telegram, Discord, Slack and Chatwoot bots, so a private RAG backend can be embedded in your product, docs or support desk.

npm install docsgpt · POST /v1/chat/completions

Last updated:

# any OpenAI SDK or curl, pointed at your instance.
# the agent is selected by its API key; "model" is accepted and ignored
curl https://docsgpt.example.com/v1/chat/completions \
  -H "Authorization: Bearer $AGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "docsgpt-agent",
    "stream": true,
    "messages": [{
      "role": "user",
      "content": "What is our refund window?"
    }]
  }'

OpenAI-compatible API

A drop-in base URL for anything that already speaks OpenAI.

Each agent is reachable at POST /v1/chat/completions, authenticated with a per-agent API key. The OpenAI SDKs, Aider and LibreChat work by changing the base URL. There is no model to choose: the model field is accepted and ignored, and GET /v1/models returns exactly one entry: the agent that key is bound to, under the agent's own id and name.

Supported on the endpoint: streaming, structured outputs with JSON Schema, multimodal image input, client-side tool calling, reasoning_content for reasoning models, and an Idempotency-Key header (v0.17.3) that replays the stored answer on a retried non-streaming request. Streaming replay is deliberately not supported, so a retried stream re-runs the agent. Keys are issued and rotated per agent, and rotation invalidates the previous key immediately.

  • POST /v1/chat/completionsstreaming · structured outputs (JSON Schema)
  • GET /v1/modelsthe one agent behind the key
  • Authorization: Bearer <agent key>one key per agent
  • multimodal imagesin messages
  • client-side tool callingyour functions, our RAG
  • reasoning_contentfor reasoning models
  • Idempotency-Keynon-streaming retries (v0.17.3)
# drop-in for the OpenAI SDK: change base_url and the key
from openai import OpenAI

client = OpenAI(
    base_url="https://docsgpt.example.com/v1",
    api_key=AGENT_API_KEY,
)

stream = client.chat.completions.create(
    # required by the SDK, ignored by the server
    model="docsgpt-agent",
    messages=[{"role": "user", "content": "Summarise the Q3 security review"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Native API and webhooks

The endpoints the app itself uses, under two different authentication schemes.

Agent-facing endpoints take the agent's API key in the request body, so any backend that holds a key can call them. The endpoints that read a person's own history (conversation search, notifications and stream resume) take that user's signed-in token instead and are scoped to them, so they are not reachable with an agent key.

The native API exposes what the DocsGPT app uses: synchronous answers, a server-sent-event stream with typed events, attachments, task status, per-agent webhooks for asynchronous triggers, and, for a signed-in user, conversation search, notifications and stream resume.

Native API endpoints and webhook facilities
 PurposeAuthenticationNotes
POST /api/answerOne answer from an agentAgent API key in the bodyAttachments; passthrough variables into prompt templates
POST /streamServer-sent events while the agent worksAgent API key in the bodyTyped events, listed below
POST /api/store_attachmentUpload a file to ask a question aboutAgent API key or a signed-in user tokenMultipart; stored without vectorising
GET /api/task_statusPoll long-running workNone: the task id is the handlePairs with webhooks
POST /api/webhooks/agents/{token}Trigger an agent from another system, asynchronouslyThe token in the URLReturns a task_id; accepts Idempotency-Key
GET /api/search_conversationsFind earlier conversationsSigned-in user token, scoped to that user's conversationsReturns the matched field and a snippet
GET /api/eventsPush notifications to a signed-in clientSigned-in user tokenLast-Event-ID replay
GET /api/messages/{id}/eventsResume an interrupted answer streamSigned-in user tokenLast-Event-ID cursor; 14-day journal

Request bodies and examples are in the API reference below.

Every data: frame on /stream is JSON with a type. Eleven event types today; parse by type and ignore what you do not handle.

  • answerincremental chunk
  • sourcecited chunks
  • tool_callstool metadata
  • thoughtagent dependent
  • structured_answerschema mode
  • guardrailcheck fired
  • noticeoperator message
  • message_idfor stream resume
  • idconversation id
  • errorfailure
  • endstream complete

Widgets

A chat widget and a search bar for your docs or product, from one npm package.

The chat widget is a React or plain-HTML component published on npm as docsgpt, themable to your site. The same package exports a search-bar widget that answers from the same agent inline. On a Nextra documentation site the chat widget is added to pages/_app.js.

Both are open source under MIT, talk only to the instance URL you configure, and use a per-agent key, so a public docs site can expose a read-only agent while internal agents stay behind SSO. Building a product on the API? See for AI product builders.

# chat widget and search bar: one npm package, MIT, themable
npm install docsgpt

// React: see the chat-widget docs for all props
import { DocsGPTWidget } from "docsgpt";

<DocsGPTWidget
  apiHost="https://docsgpt.example.com"
  apiKey="…"
/>
docs.example.com
Ask the docsdocsgpt

How do I rotate an API key?

Open Settings › Agents, pick the agent and choose Regenerate key. The previous key stops working immediately and the new one is shown once, so update clients first 1.

→ Admin guide · API keys · p. 12

Channels

Four supported channels; everything else through the API.

Bots relay questions from a chat platform to an agent on your instance and post the cited answer back. They need outbound access to that platform, so they are not for air-gapped estates.

Supported chat channels
 What it doesOutbound accessWhere it lives
Telegram botStreams answers into private chats, groups and forum topics, with collapsible sourcesYes, to the Telegram APIarc53/tg-bot-docsgpt-extenstion · MIT
Discord botAnswers direct messages and channel mentions, keeping conversation historyYes, to the Discord APIarc53/discord-docsgpt-extension · MIT
Slack botAnswers mentions and direct messages in threads; multiple agents per workspaceYes, to the Slack API, Socket Modearc53/slack-bot-docsgpt-extenstion · MIT
Chatwoot extensionAnswers inside a Chatwoot support deskReachability to your Chatwootextensions/chatwoot in the platform repository · MIT

Each channel is an open-source project with its own repository; other systems connect through the API or webhooks.

The Telegram bot goes furthest. One binary runs any number of bots, each bound to one or more agents that users pick with /agents or a one-off #name prefix. Answers stream into private chats with Telegram's own Stop button, render the agent's markdown natively (headings, tables, code, LaTeX), and tuck citations into a collapsible block.

Photos and documents go in as attachments, voice notes are transcribed and can be answered with a voice note, and files the agent's tools produce come back into the chat. Each chat, and each forum topic, keeps its own conversation. It also covers inline mode, Telegram Business accounts, polling or webhooks, and a /healthz endpoint.

How it runs privately

The API, the widgets and the bots talk only to your instance URL; no Arc53 service sits in the path on Managed, On-premises or Air-gapped deployments. The Telegram, Discord and Slack bots need outbound access to those platforms, so they are for connected estates, not air-gapped ones. An air-gapped instance still serves the API and widgets inside the network.

Every deployment posture includes the API and widgets at no extra charge; see pricing. Teams comparing this with building a RAG backend in-house get the retrieval, citations and agents behind one endpoint.

Example

A developer-tools company adds the chat widget to its public documentation with a read-only agent over the docs and changelog. The same agent is exposed through /v1/chat/completions to the in-app help panel, and a webhook lets the support desk file a summary into the ticketing system when a conversation is escalated.

GitHub stars

18,273

on GitHub

Licence

MIT

platform and widgets

Widget package

docsgpt

npm

Named channels

4

Telegram · Discord · Slack · Chatwoot

Frequently asked questions

Is there an OpenAI-compatible API for RAG?

Yes. Each agent exposes POST /v1/chat/completions and GET /v1/models, authenticated with the agent's API key. Point the OpenAI SDK, Aider or LibreChat at your instance's base URL and answers come back grounded in your documents, with streaming, JSON Schema structured outputs and client-side tool calling. The model field is accepted and ignored; the key decides which agent, prompt, sources, tools and model answer.

Can I embed an AI chat widget in my documentation?

Yes. The chat widget is an open-source React/HTML component published on npm as docsgpt, themable to your site; the same package also exports a search-bar widget. On a Nextra documentation site the chat widget is added to pages/_app.js. Both the widget package and the platform are MIT.

Can another system trigger an agent?

Yes. Every agent can have a webhook URL at POST /api/webhooks/agents/{token}, which accepts an asynchronous request and returns a task id; the caller polls /api/task_status for the result, and an Idempotency-Key header makes retries safe.

Does it stream?

Yes. The native POST /stream endpoint emits server-sent events for answer tokens, sources, tool calls, thoughts, structured answers and stream control; the OpenAI-compatible endpoint streams too. A dropped stream is resumed by a signed-in client from GET /api/messages/{id}/events with a Last-Event-ID cursor, within the journal's 14 days.

Which chat channels are supported?

Four: Telegram, Discord, Slack and the Chatwoot support-desk extension, each an open-source project of its own. Other systems connect through the API or webhooks.

See DocsGPT on your documents

A 30-minute demo of the API and widgets on your documents, or self-host and call the endpoint today.