Zum Hauptinhalt springen

Chat, RAG & Flows

Streamdiver turns every media asset into a knowledge base. The Chat API enables natural-language questions against videos, audio files, and documents -- powered by RAG that grounds answers in your actual content. The Flows API extends this with parameterized, agentic automation workflows.

What is RAG?

Retrieval-Augmented Generation (RAG) combines search with AI text generation. Instead of relying solely on a language model's training data, RAG first retrieves relevant passages from your media -- transcripts, document pages, speaker segments -- and then generates an answer grounded in that specific content. This means answers include source references and stay faithful to what was actually said or written.

Ask a Question

The Chat endpoint POST /chats accepts a prompt and optional filters. Without filters it searches your entire library; with filters you can scope the query to specific assets, channels, speakers, or asset types.

Ask About a Specific Asset

To ask a question about a single video, audio file, or document, pass its ID in the mediaIds filter:

curl --request POST \
--url https://api.streamdiver.com/v2/chats \
--header "Authorization: Bearer {token}" \
--header "Content-Type: application/json" \
--data '{
"prompt": "What are the key takeaways from this presentation?",
"mediaIds": ["{mediaId}"]
}'

The response includes the generated answer and the source context that was used:

{
"data": {
"answer": "The presentation highlights three key takeaways: ...",
"context": [
{
"parts": [
{
"text": "In summary, we achieved a 15% cost reduction...",
"metadata": { "startTime": 124.5 },
"ref": "chunk-abc123"
}
],
"presentation": { "thumbnail": { "url": "..." } }
}
]
}
}

For documents, metadata.page indicates the page number instead of startTime.

Ask Across Your Entire Library

Omit the filters to query all media assets at once:

curl --request POST \
--url https://api.streamdiver.com/v2/chats \
--header "Authorization: Bearer {token}" \
--header "Content-Type: application/json" \
--data '{
"prompt": "What has been said about sustainability across all recordings?"
}'

Filters

Narrow the scope with filters -- combine as needed:

{
"prompt": "What decisions were made?",
"channelIds": ["{channelId}"],
"mediaIds": ["{mediaId1}", "{mediaId2}"],
"speakers": ["Dr. Smith"],
"tags": ["board-meeting"],
"types": ["video", "audio"]
}
FilterDescription
channelIdsRestrict to specific channels
mediaIdsRestrict to specific assets (use a single ID to target one asset)
speakersOnly consider content from named speakers
tagsFilter by asset tags
typesFilter by asset type: video, audio, document

Inference Modes

Control the speed/quality tradeoff with the mode parameter:

ModeDescription
autoAutomatically selects the best mode (default)
turboFaster responses, may reduce precision due to limited context
smartDeeper analysis, considers more context for complex questions
curl --request POST \
--url https://api.streamdiver.com/v2/chats \
--header "Authorization: Bearer {token}" \
--header "Content-Type: application/json" \
--data '{
"prompt": "Summarize the budget discussion",
"mediaIds": ["{mediaId}"],
"mode": "smart"
}'
tipp

Use GET /tenants/current/speakers to list all recognized speakers across your library, including their IDs and labels. You can then pass speaker names in the speakers filter to ask what specific people said.

Conversation History

Maintain multi-turn conversations by passing previous messages in messageHistory:

{
"prompt": "Can you elaborate on the third point?",
"messageHistory": [
{ "role": "user", "content": "What are the key takeaways?" },
{ "role": "assistant", "content": "The presentation highlights three key takeaways: ..." }
]
}

Streaming Responses (SSE)

For real-time UIs, use the streaming endpoint that returns Server-Sent Events:

curl --request POST \
--url https://api.streamdiver.com/v2/chats/stream \
--header "Authorization: Bearer {token}" \
--header "Content-Type: application/json" \
--header "Accept: text/event-stream" \
--data '{ "prompt": "Summarize the latest board meeting" }'

Each SSE event contains a token chunk. The final event signals completion:

data: {"Token": "The board", "isComplete": false}
data: {"Token": " discussed", "isComplete": false}
data: {"Token": "", "isComplete": true}

Flows: Agentic Automation

Flows are parameterized AI workflows that go beyond simple Q&A. They enable automated content analysis (insights) and content generation (creation) -- from summarization to structured data extraction.

Discover Available Flows

List all flows available for your tenant, optionally filtered by category:

# List all insight flows
curl --request GET \
--url "https://api.streamdiver.com/v2/flows?category=insights&lang=en" \
--header "Authorization: Bearer {token}"

The response includes each flow's name, description, supported media types, and estimated duration:

{
"data": [
{
"id": "flow-uuid",
"name": "Meeting Summary",
"description": "Generates a structured summary of a meeting recording.",
"category": "insights",
"mediaTypes": ["video", "audio"],
"estimatedDuration": "medium"
}
]
}
CategoryPurpose
insightsAnalyze existing content (summaries, key topics, compliance checks)
creationGenerate new content (social media posts, newsletters, reports)

Inspect a Flow's Schema

Each flow has a dynamic input schema. Inspect it before execution to see what parameters are required:

curl --request GET \
--url "https://api.streamdiver.com/v2/flows/{flowId}/schema?lang=en" \
--header "Authorization: Bearer {token}"

Execute a Flow

Run a flow against a media asset. The response is streamed via SSE:

curl --request POST \
--url https://api.streamdiver.com/v2/flows/{flowId}/runs \
--header "Authorization: Bearer {token}" \
--header "Content-Type: application/json" \
--header "Accept: text/event-stream" \
--data '{
"mediaId": "{mediaId}",
"llmProvider": "streamdiver/nitrox",
"params": {
"language": "en",
"format": "bullet_points"
}
}'

The stream emits events of different types: message (content tokens), search (retrieval progress), progress (status updates), and error.

Further Resources