Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
2395 lines (2394 loc) · 73.2 KB
/
Copy pathopenapi.yaml
File metadata and controls
2395 lines (2394 loc) · 73.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: RAG Service API
version: "1.0.0"
summary: Public API for querying and managing the RAG service.
description: |
Versioned public API for external applications integrating with the RAG
service. All `/api/v1/*` endpoints require an `X-API-Key` header. In
multi-user deployments, each API key resolves to exactly one user
workspace; queries, uploads, jobs, conversations, and deletes stay inside
that workspace boundary.
servers:
- url: http://127.0.0.1:5000
description: Local development server
tags:
- name: Health
description: Service readiness and runtime status.
- name: Models
description: Available providers and model selections.
- name: Query
description: RAG question answering.
- name: Files
description: RAG file upload and indexing.
- name: Knowledge Bases
description: Catalog and lifecycle management for isolated knowledge bases.
- name: Chat Agents
description: Named presets bundling a provider, model, knowledge bases, and prompt for query-by-agent_id.
- name: Conversation History
description: Session-auth endpoints for the persistent per-workspace conversation transcript.
- name: OCR
description: Text extraction from images and PDFs.
- name: Speech
description: Audio transcription and text-to-speech.
security:
- ApiKeyAuth: []
paths:
/api/v1/health:
get:
tags:
- Health
operationId: getApiV1Health
summary: Get service health
description: |
Returns runtime health for model configuration, settings, embeddings,
cache and ChromaDB.
parameters:
- $ref: "#/components/parameters/KnowledgeBaseId"
responses:
"200":
description: Service health payload.
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"
examples:
healthy:
value:
status: healthy
model_configuration_ready: true
settings_ready: true
embeddings_ready: true
cache_enabled: true
database_ready: true
tracked_files_count: 3
indexed_files_count: 3
stale_index_files_count: 0
needs_rebuild: false
system_ready: true
stt_ready: true
tts_ready: true
voice_provider: openai-compatible
ocr_ready: false
ocr_provider: ""
state_backend: memory
queue_backend: inline
redis_ready: true
queue_ready: true
queue_depth: 0
active_jobs_count: 0
collection: documents_user_123
documents_count: 128
"401":
$ref: "#/components/responses/Unauthorized"
/metrics:
get:
tags:
- Health
operationId: getMetrics
summary: Prometheus metrics
description: |
Returns service metrics in Prometheus text exposition format.
No authentication required. Useful for monitoring dashboards
(Grafana, Prometheus scraper, etc.).
Metrics include:
- Query count and latency histogram
- Retrieval latency histogram
- Cache hit/miss counters
- HTTP request count and latency
- Active queries gauge
- Memory usage
- Uptime
responses:
"200":
description: Prometheus text exposition format metrics.
content:
text/plain:
schema:
type: string
examples:
sample:
value: |
# HELP rag_queries_total Total RAG queries.
# TYPE rag_queries_total counter
rag_queries_total{status="success"} 142.0
rag_queries_total{status="error"} 5.0
# HELP rag_query_duration_seconds RAG query duration.
# TYPE rag_query_duration_seconds histogram
...
/api/v1/models:
get:
tags:
- Models
operationId: listApiV1Models
summary: List available models
description: |
Returns enabled built-in and custom OpenAI-compatible models that can
be used in `/api/v1/query`.
responses:
"200":
description: Available models grouped as a flat list.
content:
application/json:
schema:
$ref: "#/components/schemas/ModelsResponse"
examples:
default:
value:
default_provider: mistral
default_model: mistral-medium
default_value: mistral:mistral-medium
models:
- id: mistral-medium
name: mistral-medium (Mistral AI)
provider: mistral
provider_name: Mistral AI
value: mistral:mistral-medium
is_default: true
"401":
$ref: "#/components/responses/Unauthorized"
"500":
description: Model provider configuration is missing or invalid.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
modelConfigurationError:
value:
error: "No models configured in app/default_providers.json."
status: model_configuration_error
provider_config_file: app/default_providers.json
configure_url: /admin/config
/api/v1/query:
post:
tags:
- Query
operationId: postApiV1Query
summary: Query the RAG service
description: |
Answers a question using one or more authorized knowledge bases, up to
the runtime limit returned by the knowledge-base list endpoint. The
service embeds the question once, retrieves candidates from every
selected collection, deduplicates them, and applies one global ranking.
By default the response is JSON. When `stream` is `true`, the response body is progressive
`text/plain` output. Set `stream_format` to `ndjson` to receive one
structured JSON event per line, including final context sources.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/QueryRequest"
examples:
nonStreaming:
value:
query: What are the main points of the document?
provider: mistral
model: mistral-medium
conversation_id: chat-20260616-demo
knowledge_base_ids:
- default
- kb_11111111111111111111111111111111
response_language: auto
temperature: 0.3
k: 5
streaming:
value:
query: Summarize the document.
stream: true
structuredStreaming:
value:
query: Summarize the document.
stream: true
stream_format: ndjson
responses:
"200":
description: Query answer. JSON when `stream` is false, text or NDJSON events when `stream` is true.
headers:
X-Knowledge-Base-Ids:
description: Comma-separated knowledge base IDs used by the query.
schema:
type: string
X-Knowledge-Base-Id:
description: Present for text streaming only when exactly one KB was selected.
schema:
$ref: "#/components/schemas/KnowledgeBaseId"
content:
application/json:
schema:
$ref: "#/components/schemas/QueryResponse"
examples:
answer:
value:
answer: Response generated by the model.
model: mistral-medium
provider: mistral
provider_name: Mistral AI
conversation_id: chat-20260616-demo
knowledge_base_ids:
- default
- kb_11111111111111111111111111111111
response_language: auto
context:
- text: Chunk retrieved from document...
metadata:
source: app/uploads/workspaces/user_123/demo.pdf
chunk_id: 0
knowledge_base_id: default
knowledge_base_name: General
chunk_length: 924
sources:
- filename: demo.pdf
source_type: pdf
chunk_id: 0
knowledge_base_id: default
knowledge_base_name: General
snippet: Chunk retrieved from document...
usage: null
text/plain:
schema:
type: string
examples:
streamedText:
value: Response generated progressively...
application/x-ndjson:
schema:
type: string
description: Newline-delimited QueryStreamEvent JSON objects.
examples:
streamedEvents:
value: |
{"type":"meta","model":"mistral-medium","provider":"mistral","provider_name":"Mistral AI","response_language":"auto","conversation_id":"chat-20260616-demo","knowledge_base_ids":["default"],"knowledge_base_id":"default"}
{"type":"token","text":"Progressive "}
{"type":"token","text":"response..."}
{"type":"done","answer":"Progressive response...","model":"mistral-medium","provider":"mistral","provider_name":"Mistral AI","response_language":"auto","conversation_id":"chat-20260616-demo","knowledge_base_ids":["default"],"knowledge_base_id":"default","context":[],"sources":[],"usage":null}
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/KnowledgeBaseNotFound"
"409":
$ref: "#/components/responses/KnowledgeBaseConflict"
"429":
$ref: "#/components/responses/RateLimited"
"500":
$ref: "#/components/responses/ServerError"
/api/v1/knowledge-bases:
get:
tags:
- Knowledge Bases
operationId: listApiV1KnowledgeBases
summary: List knowledge bases authorized to the API key
description: Requires at least one of `query`, `ingest`, or `kb_manage`.
responses:
"200":
description: Authorized knowledge bases with file/source statistics.
content:
application/json:
schema:
type: object
required: [knowledge_bases, limits]
properties:
knowledge_bases:
type: array
items:
$ref: "#/components/schemas/KnowledgeBase"
limits:
type: object
required: [max_query_knowledge_bases, max_knowledge_bases]
properties:
max_query_knowledge_bases:
type: integer
minimum: 1
max_knowledge_bases:
type: integer
minimum: 1
description: Total workspace capacity, including the default knowledge base.
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
post:
tags:
- Knowledge Bases
operationId: createApiV1KnowledgeBase
summary: Create a knowledge base
description: Requires `kb_manage`. The creating key receives access; other keys are unchanged.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/KnowledgeBaseCreateInput"
responses:
"201":
description: Knowledge base created.
content:
application/json:
schema:
$ref: "#/components/schemas/KnowledgeBase"
"400":
$ref: "#/components/responses/ValidationError"
"409":
description: Duplicate name or configured KB limit reached.
/api/v1/knowledge-bases/{knowledge_base_id}:
parameters:
- $ref: "#/components/parameters/KnowledgeBaseIdPath"
get:
tags:
- Knowledge Bases
operationId: getApiV1KnowledgeBase
summary: Get one authorized knowledge base
responses:
"200":
description: Knowledge base.
content:
application/json:
schema:
$ref: "#/components/schemas/KnowledgeBase"
"404":
$ref: "#/components/responses/NotFound"
patch:
tags:
- Knowledge Bases
operationId: updateApiV1KnowledgeBase
summary: Rename or describe a knowledge base
description: Requires `kb_manage`; IDs, status, paths and default role are immutable.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/KnowledgeBaseUpdateInput"
responses:
"200":
description: Updated knowledge base.
content:
application/json:
schema:
$ref: "#/components/schemas/KnowledgeBase"
"404":
$ref: "#/components/responses/NotFound"
"409":
description: Duplicate name or deletion already in progress.
delete:
tags:
- Knowledge Bases
operationId: deleteApiV1KnowledgeBase
summary: Start asynchronous cascade deletion
description: |
Requires `kb_manage`. An authorized default KB always returns 409;
an unauthorized default target is hidden with 404.
responses:
"202":
description: Cascade deletion job accepted.
content:
application/json:
schema:
$ref: "#/components/schemas/AsyncJobResponse"
"404":
$ref: "#/components/responses/NotFound"
"409":
description: Default KB, deleting KB, or active jobs prevent deletion.
/api/v1/agents:
get:
tags:
- Chat Agents
operationId: listApiV1Agents
summary: List chat agents visible to the API key
description: |
Requires `query` or `agent_manage`. Only agents whose
`knowledge_base_ids` are a subset of the key's allowlist are returned.
responses:
"200":
description: Visible agents and workspace limits.
content:
application/json:
schema:
$ref: "#/components/schemas/ChatAgentsResponse"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
post:
tags:
- Chat Agents
operationId: createApiV1Agent
summary: Create a chat agent
description: Requires `agent_manage`.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ChatAgentCreateInput"
responses:
"201":
description: Agent created.
content:
application/json:
schema:
$ref: "#/components/schemas/ChatAgent"
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/KnowledgeBaseNotFound"
"409":
description: KB limit, agent count limit, or duplicate name.
/api/v1/agents/options:
get:
tags:
- Chat Agents
operationId: getApiV1AgentOptions
summary: Models, knowledge bases, prompts, and limits for the API key
description: |
Requires `query` or `agent_manage`. Useful for building agent
create/edit forms in external clients.
responses:
"200":
description: Available options.
content:
application/json:
schema:
$ref: "#/components/schemas/ChatAgentOptionsResponse"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
/api/v1/agents/{agent_id}:
parameters:
- $ref: "#/components/parameters/AgentIdPath"
get:
tags:
- Chat Agents
operationId: getApiV1Agent
summary: Get one chat agent
description: |
Requires `query` or `agent_manage`. An agent referencing a KB outside
the key's allowlist is hidden with 404.
responses:
"200":
description: Agent.
content:
application/json:
schema:
$ref: "#/components/schemas/ChatAgent"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/ChatAgentNotFound"
patch:
tags:
- Chat Agents
operationId: updateApiV1Agent
summary: Update a chat agent
description: |
Requires `agent_manage`. All fields are optional; only provided fields
change. At least one field is required.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ChatAgentUpdateInput"
responses:
"200":
description: Updated agent.
content:
application/json:
schema:
$ref: "#/components/schemas/ChatAgent"
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/ChatAgentNotFound"
"409":
description: KB limit or duplicate name.
delete:
tags:
- Chat Agents
operationId: deleteApiV1Agent
summary: Delete a chat agent
description: Requires `agent_manage`.
responses:
"200":
description: Agent deleted.
content:
application/json:
schema:
$ref: "#/components/schemas/ChatAgentDeleteResponse"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/ChatAgentNotFound"
/api/v1/conversations/{conversation_id}:
delete:
tags:
- Query
operationId: deleteApiV1Conversation
summary: Clear conversation memory
description: |
Removes the conversation memory associated with the supplied
`conversation_id`. Repeat `knowledge_base_ids` for the KB selection
whose plural conversation namespace must be cleared.
parameters:
- name: conversation_id
in: path
required: true
schema:
type: string
minLength: 8
maxLength: 80
pattern: "^[A-Za-z0-9][A-Za-z0-9_-]*$"
example: chat-20260616-demo
- $ref: "#/components/parameters/KnowledgeBaseIds"
responses:
"200":
description: Conversation memory reset result.
content:
application/json:
schema:
type: object
required:
- conversation_id
- cleared
- knowledge_base_ids
properties:
conversation_id:
type: string
cleared:
type: boolean
knowledge_base_ids:
type: array
minItems: 1
uniqueItems: true
items:
$ref: "#/components/schemas/KnowledgeBaseId"
knowledge_base_id:
allOf:
- $ref: "#/components/schemas/KnowledgeBaseId"
description: Present only when exactly one knowledge base was selected.
examples:
pluralSelectionCleared:
value:
conversation_id: chat-20260616-demo
cleared: true
knowledge_base_ids:
- default
- kb_11111111111111111111111111111111
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/KnowledgeBaseNotFound"
"409":
$ref: "#/components/responses/KnowledgeBaseConflict"
"500":
$ref: "#/components/responses/ServerError"
/api/conversations:
get:
tags:
- Conversation History
operationId: listConversations
summary: List persisted conversations
description: |
Lists conversations persisted to the per-workspace SQLite history store
for the logged-in workspace. Conversations with zero messages are
hidden. Session-authenticated (browser login cookie + CSRF); not part of
the API-key v1 contract. Returns an empty list when history is
disabled (`RAG_CONVERSATION_HISTORY_ENABLED=0`).
security:
- SessionAuth: []
parameters:
- name: page
in: query
required: false
schema:
type: integer
minimum: 1
default: 1
- name: per_page
in: query
required: false
schema:
type: integer
minimum: 1
maximum: 100
default: 20
- name: status
in: query
required: false
schema:
type: string
enum:
- active
- archived
- name: archived
in: query
required: false
description: "Sets `status` when `status` is omitted. `true` -> archived, `false` -> active."
schema:
type: string
enum:
- "true"
- "false"
responses:
"200":
description: Paginated conversation list.
content:
application/json:
schema:
type: object
required:
- conversations
- pagination
properties:
conversations:
type: array
items:
$ref: "#/components/schemas/ConversationRecord"
pagination:
$ref: "#/components/schemas/Pagination"
"401":
$ref: "#/components/responses/Unauthorized"
"500":
$ref: "#/components/responses/ServerError"
/api/conversations/{history_id}:
get:
tags:
- Conversation History
operationId: getConversation
summary: Get a conversation record
description: |
Returns the full conversation record by its server-side UUID
`history_id`. Session-authenticated. Returns `404` when the id is not a
UUID, history is disabled, or the conversation belongs to another
workspace.
security:
- SessionAuth: []
parameters:
- name: history_id
in: path
required: true
schema:
type: string
format: uuid
responses:
"200":
description: Conversation record.
content:
application/json:
schema:
$ref: "#/components/schemas/ConversationRecord"
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/ServerError"
patch:
tags:
- Conversation History
operationId: updateConversation
summary: Rename and/or archive a conversation
description: |
Updates the `title` and/or `archived` flag of a conversation.
Session-authenticated. `title` is max 120 chars; `archived` is a boolean.
security:
- SessionAuth: []
parameters:
- name: history_id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
type: object
minProperties: 1
properties:
title:
type: string
minLength: 1
maxLength: 120
archived:
type: boolean
additionalProperties: false
responses:
"200":
description: Updated conversation record.
content:
application/json:
schema:
$ref: "#/components/schemas/ConversationRecord"
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/ServerError"
delete:
tags:
- Conversation History
operationId: deleteConversation
summary: Hard-delete a conversation
description: |
Permanently deletes a conversation and all its messages and turn
records. Session-authenticated. Returns `{"deleted": false}` when
history is disabled.
security:
- SessionAuth: []
parameters:
- name: history_id
in: path
required: true
schema:
type: string
format: uuid
responses:
"200":
description: Deletion result.
content:
application/json:
schema:
type: object
required:
- deleted
properties:
deleted:
type: boolean
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/ServerError"
/api/conversations/{history_id}/messages:
get:
tags:
- Conversation History
operationId: listConversationMessages
summary: List messages for a conversation
description: |
Returns messages for a conversation with backward cursor pagination.
Messages are returned oldest-first within the requested window.
Session-authenticated.
security:
- SessionAuth: []
parameters:
- name: history_id
in: path
required: true
schema:
type: string
format: uuid
- name: before_sequence
in: query
required: false
description: Fetch messages with `sequence <` this value (cursor from a previous page).
schema:
type: integer
minimum: 0
- name: limit
in: query
required: false
schema:
type: integer
minimum: 1
maximum: 200
default: 50
responses:
"200":
description: Paginated messages.
content:
application/json:
schema:
type: object
required:
- messages
- next_cursor
- limit
properties:
messages:
type: array
items:
$ref: "#/components/schemas/ConversationMessage"
next_cursor:
description: "Sequence of the oldest message in the window, to pass as `before_sequence` for the previous page. `null` when there are no older messages."
oneOf:
- type: integer
- type: "null"
limit:
type: integer
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/ServerError"
/api/v1/files:
post:
tags:
- Files
operationId: postApiV1Files
summary: Upload and index a document
description: |
Uploads a PDF, TXT, or Markdown document and indexes it into the RAG
knowledge base of the user workspace resolved by the API key. The
request requires an API key with `ingest` scope. Public integrations
should use workspace API keys via `X-API-Key`. Synchronous processing remains the default for
backward compatibility; pass `async=true` to receive a job id and poll
`/api/v1/jobs/{job_id}`.
parameters:
- name: async
in: query
required: false
schema:
type: boolean
default: false
description: When true, save the upload and process indexing as a background job.
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- file
properties:
file:
type: string
format: binary
description: PDF, TXT, or Markdown file to index.
relative_path:
type: string
description: Optional safe relative path, including the filename.
knowledge_base_id:
$ref: "#/components/schemas/KnowledgeBaseId"
responses:
"200":
description: File uploaded and indexed.
content:
application/json:
schema:
$ref: "#/components/schemas/FileUploadResponse"
examples:
uploaded:
value:
message: documento.pdf uploaded and indexed
filename: documento.pdf
source_type: pdf
chunks: 18
"202":
description: File upload accepted for async processing.
content:
application/json:
schema:
$ref: "#/components/schemas/AsyncJobResponse"
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/UploadUnauthorized"
"500":
$ref: "#/components/responses/ServerError"
/api/v1/audio:
post:
tags:
- Speech
- Files
operationId: postApiV1Audio
summary: Upload, transcribe, and index audio
description: Uploads an audio file, transcribes it with the configured STT provider, and indexes the transcript. Optional multipart language overrides the configured STT language for this request. Synchronous processing remains the default for backward compatibility; pass async=true to receive a job id and poll /api/v1/jobs/{job_id}.
parameters:
- name: async
in: query
required: false
schema:
type: boolean
default: false
description: When true, save the upload and process transcription/indexing as a background job.
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- file
properties:
file:
type: string
format: binary
description: Audio file to transcribe and index.
language:
type: string
description: Optional STT language hint, such as it or en. Empty or omitted enables fallback to configured language/autodetect.
relative_path:
type: string
description: Optional safe relative path, including the filename.
knowledge_base_id:
$ref: "#/components/schemas/KnowledgeBaseId"
responses:
"200":
description: Audio transcribed and indexed.
content:
application/json:
schema:
$ref: "#/components/schemas/AudioUploadResponse"
"202":
description: Audio upload accepted for async transcription and indexing.
content:
application/json:
schema:
$ref: "#/components/schemas/AsyncJobResponse"
"400":
$ref: "#/components/responses/ValidationError"
"401":
$ref: "#/components/responses/UploadUnauthorized"
"500":
$ref: "#/components/responses/ServerError"
/api/v1/jobs/{job_id}:
get:
tags:
- Jobs
operationId: getApiV1Job
summary: Get async job status
description: |
Returns the current state, errors, and final result for async ingest,
rebuild, sync, and knowledge-base deletion jobs. Ingest jobs require
`ingest` plus current target authorization. Delete jobs require
`kb_manage` and are visible only to the API key that initiated DELETE.
That key can keep polling after deletion cleanup removes the target
from its allowlist.
parameters:
- name: job_id
in: path
required: true
schema:
type: string
description: Job id returned by an async endpoint.
responses:
"200":
description: Job status.