Skip to content
Docs

Your chat.
Your documents.

Connect an OpenAI-compatible chat client using your DocSlurp service URL, API key, and a workspace model. Answers use that workspace's documents and include source references.

  1. 1

    Upload your documents

    Wait for processing to finish in your workspace.

  2. 2

    Create a service key

    Grant search access from API keys.

  3. 3

    Choose your workspace

    List models and select workspace:<workspace-id>.

Set DOCSLURP_URL to your service origin, such as http://localhost:4321. Your client's base URL is that origin plus /v1. Create a key at API keys; keep it on your server.

Discover workspaces

curl "$DOCSLURP_URL/v1/models" \
  -H "Authorization: Bearer $DOCSLURP_API_KEY"

OpenAI TypeScript SDK

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.DOCSLURP_API_KEY,
  baseURL: process.env.DOCSLURP_URL!.replace(/[/]$/, '') + '/v1',
});

const { data: models } = await client.models.list();
const model = models[0]?.id;
if (!model) throw new Error('Upload documents to a workspace first.');

const messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [
  { role: 'user', content: 'What are the key findings?' },
];
const answer = await client.chat.completions.create({ model, messages });
console.log(answer.choices[0].message.content);

// Send the history with your next question.
messages.push({ role: 'assistant', content: answer.choices[0].message.content ?? '' });
messages.push({ role: 'user', content: 'Which source supports that?' });

const stream = await client.chat.completions.create({
  model, messages, stream: true,
  stream_options: { include_usage: true },
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta.content ?? '');
  if (chunk.usage) console.log(chunk.usage);
}

REST completion

curl -X POST "$DOCSLURP_URL/v1/chat/completions" \
  -H "Authorization: Bearer $DOCSLURP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "workspace:<workspace-id>",
    "messages": [{"role":"user","content":"What are the key findings?"}]
  }'

A small, predictable contract

Send text messages with system, developer, user, or assistant roles. Include your conversation history with every request; the final message must be a nonempty user question. The model ID selects a workspace, not an upstream inference model. The endpoint uses the workspace's chat defaults.

Both JSON and streaming responses are supported. Set stream to true for server-sent content deltas, ending with [DONE]. With stream_options.include_usage, an extra chunk contains usage and an empty choices array. Usage reports actual answer-generation tokens; retrieval usage is recorded separately.

Set max_completion_tokens, or the max_tokens alias, up to 16,384. Tool calls, images, audio, files, and structured-output options are not supported. Unsupported requests return a descriptive error rather than silently changing behavior.

Answers include a Markdown source list. A DocSlurp-specific docslurp response extension also carries structured citations and availability. If indexing is still finishing, answers may use a partial corpus. The standard completion fields work with clients that ignore extensions.

This implements workspace chat through Chat Completions and model discovery. Clients requiring the Responses API, tool execution, or other OpenAI endpoints need a different integration. For uploads and search, see the SDK quickstart.