@@ -336,20 +336,136 @@ To include Transformer and Image in the **API image** (larger image): `podman bu
336336
337337## API Overview
338338
339- * (To be filled after implementation; summary here.)*
339+ The API is REST-style. All IDs are UUIDs. Base URL when running locally: ` http://localhost:8000 ` . Interactive docs: ** http://localhost:8000/docs ** .
340+
341+ ### Endpoints summary
340342
341343| Method | Endpoint | Purpose |
342344| --------| ----------| ---------|
343345| POST | ` /libraries ` | Create library |
344- | GET | ` /libraries ` | List libraries |
345- | GET | ` /libraries/{id} ` | Get library |
346- | PUT | ` /libraries/{id} ` | Update library |
347- | DELETE | ` /libraries/{id} ` | Delete library |
348- | POST | ` /libraries/{id}/documents ` | Create document |
349- | GET | ` /libraries/{id}/documents ` | List documents |
350- | ... | ... | (similar for documents and chunks) |
351- | POST | ` /libraries/{id}/index ` | Build/rebuild index |
352- | POST | ` /libraries/{id}/search ` | kNN search by embedding |
346+ | GET | ` /libraries ` | List all libraries |
347+ | GET | ` /libraries/{library_id} ` | Get library |
348+ | PUT | ` /libraries/{library_id} ` | Update library |
349+ | DELETE | ` /libraries/{library_id} ` | Delete library (and index, documents, chunks) |
350+ | POST | ` /libraries/{library_id}/documents ` | Create document |
351+ | GET | ` /libraries/{library_id}/documents ` | List documents in library |
352+ | GET | ` /libraries/{library_id}/documents/{document_id} ` | Get document |
353+ | PUT | ` /libraries/{library_id}/documents/{document_id} ` | Update document |
354+ | DELETE | ` /libraries/{library_id}/documents/{document_id} ` | Delete document (and its chunks) |
355+ | POST | ` /libraries/{library_id}/documents/{document_id}/chunks ` | Create chunk |
356+ | GET | ` /libraries/{library_id}/documents/{document_id}/chunks ` | List chunks in document |
357+ | GET | ` /libraries/{library_id}/documents/{document_id}/chunks/{chunk_id} ` | Get chunk |
358+ | PUT | ` /libraries/{library_id}/documents/{document_id}/chunks/{chunk_id} ` | Update chunk |
359+ | DELETE | ` /libraries/{library_id}/documents/{document_id}/chunks/{chunk_id} ` | Delete chunk |
360+ | POST | ` /libraries/{library_id}/index ` | Build or rebuild vector index |
361+ | POST | ` /libraries/{library_id}/search ` | k-NN search by embedding |
362+
363+ ### Status codes
364+
365+ | Code | Meaning |
366+ | ------| ---------|
367+ | 200 | OK (get, list, update, search) |
368+ | 201 | Created (post library, document, chunk) |
369+ | 204 | No content (delete, build index) |
370+ | 404 | Not found (library, document, or chunk missing) |
371+ | 409 | Conflict (search called but index not built yet) |
372+ | 422 | Validation error (e.g. empty name, invalid body) |
373+
374+ ### Request / response examples
375+
376+ ** Create library** — ` POST /libraries `
377+
378+ ``` json
379+ // Request
380+ { "name" : " My Library" }
381+
382+ // Response 201
383+ {
384+ "id" : " 550e8400-e29b-41d4-a716-446655440000" ,
385+ "name" : " My Library" ,
386+ "created_at" : " 2025-01-29T12:00:00Z" ,
387+ "document_ids" : []
388+ }
389+ ```
390+
391+ ** Create document** — ` POST /libraries/{library_id}/documents `
392+
393+ ``` json
394+ // Request
395+ { "name" : " Doc 1" }
396+
397+ // Response 201
398+ {
399+ "id" : " 6ba7b810-9dad-11d1-80b4-00c04fd430c8" ,
400+ "name" : " Doc 1" ,
401+ "created_at" : " 2025-01-29T12:00:00Z" ,
402+ "chunk_ids" : [],
403+ "library_id" : " 550e8400-e29b-41d4-a716-446655440000"
404+ }
405+ ```
406+
407+ ** Create chunk** — ` POST /libraries/{library_id}/documents/{document_id}/chunks `
408+
409+ ``` json
410+ // Request
411+ {
412+ "text" : " A short paragraph of content." ,
413+ "embedding" : [0.1 , -0.2 , 0.3 , ... ],
414+ "name" : " chunk-1"
415+ }
416+
417+ // Response 201
418+ {
419+ "id" : " 7c9e6679-7425-40de-944b-e07fc1f90ae7" ,
420+ "text" : " A short paragraph of content." ,
421+ "embedding" : [0.1 , -0.2 , 0.3 , ... ],
422+ "created_at" : " 2025-01-29T12:00:00Z" ,
423+ "name" : " chunk-1" ,
424+ "document_id" : " 6ba7b810-9dad-11d1-80b4-00c04fd430c8"
425+ }
426+ ```
427+
428+ - ` embedding ` must have the same dimension for all chunks in the library (e.g. 384 for many Sentence Transformers). Omit ` name ` if not needed.
429+
430+ ** Build index** — ` POST /libraries/{library_id}/index `
431+
432+ ``` json
433+ // Request (body optional; default algorithm is brute_force)
434+ { "algorithm" : " brute_force" }
435+ // or: "kd_tree" | "ivf"
436+
437+ // Response 204 No Content
438+ ```
439+
440+ - Must be called before search. Rebuilding replaces the previous index.
441+
442+ ** Search** — ` POST /libraries/{library_id}/search `
443+
444+ ``` json
445+ // Request
446+ {
447+ "embedding" : [0.1 , -0.2 , 0.3 , ... ],
448+ "k" : 10
449+ }
450+
451+ // Response 200
452+ {
453+ "results" : [
454+ { "chunk_id" : " 7c9e6679-7425-40de-944b-e07fc1f90ae7" , "distance" : 0.0 },
455+ { "chunk_id" : " ..." , "distance" : 0.42 }
456+ ]
457+ }
458+ ```
459+
460+ - ` k ` between 1 and 1000. Results sorted by L2 distance ascending. If the index has not been built, response is ** 409 Conflict** with ` {"detail": "Index not built for library ..."} ` .
461+
462+ ** Error response (404, 409, 422)** — body shape:
463+
464+ ``` json
465+ { "detail" : " Library 550e8400-e29b-41d4-a716-446655440000 not found" }
466+ ```
467+
468+ - For 422, ` detail ` may be a list of validation errors (FastAPI default).
353469
354470---
355471
0 commit comments