openapi.json 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. {
  2. "openapi": "3.1.0",
  3. "info": {
  4. "title": "smartbotic-vectorapi",
  5. "version": "0.1.0",
  6. "description": "General-purpose REST API fronting smartbotic-database. Supports multi-project namespacing and multi-key authorization with per-project grants."
  7. },
  8. "components": {
  9. "securitySchemes": {
  10. "bearerAuth": {
  11. "type": "http",
  12. "scheme": "bearer",
  13. "description": "API key issued by the /api/v1/keys endpoint. Pass as Authorization: Bearer <KEY>."
  14. }
  15. },
  16. "schemas": {
  17. "Error": {
  18. "type": "object",
  19. "properties": {
  20. "error": { "type": "string" },
  21. "message": { "type": "string" }
  22. },
  23. "required": ["error", "message"]
  24. },
  25. "CollectionMeta": {
  26. "type": "object",
  27. "properties": {
  28. "name": { "type": "string" },
  29. "kind": { "type": "string", "enum": ["json", "vector"] },
  30. "vector_dimension": { "type": "integer", "minimum": 1 },
  31. "embedding_model": { "type": "string" },
  32. "created_at": { "type": "integer" }
  33. },
  34. "required": ["name", "kind"]
  35. },
  36. "ApiKeyPublic": {
  37. "type": "object",
  38. "properties": {
  39. "id": { "type": "string", "description": "Stable non-secret identifier used to reference the key in PATCH/DELETE" },
  40. "key_prefix": { "type": "string" },
  41. "label": { "type": "string" },
  42. "projects": { "type": "array", "items": { "type": "string" } },
  43. "admin": { "type": "boolean" },
  44. "created_at": { "type": "integer" }
  45. }
  46. }
  47. }
  48. },
  49. "security": [{ "bearerAuth": [] }],
  50. "paths": {
  51. "/healthz": {
  52. "get": {
  53. "summary": "Liveness check — always 200 if the process is running",
  54. "operationId": "healthz",
  55. "security": [],
  56. "responses": {
  57. "200": { "description": "OK" }
  58. }
  59. }
  60. },
  61. "/readyz": {
  62. "get": {
  63. "summary": "Readiness check — 200 when the database is reachable",
  64. "operationId": "readyz",
  65. "security": [],
  66. "responses": {
  67. "200": { "description": "Ready" },
  68. "503": { "description": "Database not reachable" }
  69. }
  70. }
  71. },
  72. "/api/v1/projects": {
  73. "get": {
  74. "summary": "List projects the key may access (admin sees all)",
  75. "operationId": "listProjects",
  76. "responses": {
  77. "200": {
  78. "description": "Project list",
  79. "content": {
  80. "application/json": {
  81. "schema": {
  82. "type": "object",
  83. "properties": {
  84. "projects": { "type": "array", "items": { "type": "string" } }
  85. }
  86. }
  87. }
  88. }
  89. },
  90. "401": { "description": "Unauthorized" }
  91. }
  92. },
  93. "post": {
  94. "summary": "Create a new project (admin only)",
  95. "operationId": "createProject",
  96. "requestBody": {
  97. "required": true,
  98. "content": {
  99. "application/json": {
  100. "schema": {
  101. "type": "object",
  102. "properties": {
  103. "name": { "type": "string" }
  104. },
  105. "required": ["name"]
  106. }
  107. }
  108. }
  109. },
  110. "responses": {
  111. "201": { "description": "Project created" },
  112. "401": { "description": "Unauthorized" },
  113. "403": { "description": "Forbidden — admin required" },
  114. "422": { "description": "Validation error" }
  115. }
  116. }
  117. },
  118. "/api/v1/projects/{project}": {
  119. "parameters": [
  120. {
  121. "name": "project",
  122. "in": "path",
  123. "required": true,
  124. "schema": { "type": "string" },
  125. "description": "Project name"
  126. }
  127. ],
  128. "get": {
  129. "summary": "Get project info (collection and document counts)",
  130. "operationId": "getProject",
  131. "responses": {
  132. "200": {
  133. "description": "Project info",
  134. "content": {
  135. "application/json": {
  136. "schema": {
  137. "type": "object",
  138. "properties": {
  139. "name": { "type": "string" },
  140. "collections": { "type": "integer" },
  141. "documents": { "type": "integer" }
  142. }
  143. }
  144. }
  145. }
  146. },
  147. "401": { "description": "Unauthorized" },
  148. "403": { "description": "Forbidden" },
  149. "404": { "description": "Project not found" }
  150. }
  151. },
  152. "delete": {
  153. "summary": "Drop a project (admin only; not 'default')",
  154. "operationId": "deleteProject",
  155. "responses": {
  156. "200": { "description": "Project deleted" },
  157. "401": { "description": "Unauthorized" },
  158. "403": { "description": "Forbidden — admin required or cannot drop default" },
  159. "404": { "description": "Project not found" }
  160. }
  161. }
  162. },
  163. "/api/v1/keys": {
  164. "get": {
  165. "summary": "List API keys (admin only; secret masked; returns id and key_prefix)",
  166. "operationId": "listKeys",
  167. "responses": {
  168. "200": {
  169. "description": "Key list",
  170. "content": {
  171. "application/json": {
  172. "schema": {
  173. "type": "object",
  174. "properties": {
  175. "keys": {
  176. "type": "array",
  177. "items": { "$ref": "#/components/schemas/ApiKeyPublic" }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. },
  184. "401": { "description": "Unauthorized" },
  185. "403": { "description": "Forbidden — admin required" }
  186. }
  187. },
  188. "post": {
  189. "summary": "Generate a new API key (admin only); returns the secret key value once",
  190. "operationId": "createKey",
  191. "requestBody": {
  192. "required": true,
  193. "content": {
  194. "application/json": {
  195. "schema": {
  196. "type": "object",
  197. "properties": {
  198. "label": { "type": "string" },
  199. "projects": {
  200. "type": "array",
  201. "items": { "type": "string" },
  202. "description": "Project names the key may access; use [\"*\"] for all projects"
  203. },
  204. "admin": { "type": "boolean", "default": false }
  205. },
  206. "required": ["label", "projects"]
  207. }
  208. }
  209. }
  210. },
  211. "responses": {
  212. "201": {
  213. "description": "Key created; contains the secret key value (shown once) and the stable id",
  214. "content": {
  215. "application/json": {
  216. "schema": {
  217. "type": "object",
  218. "properties": {
  219. "id": { "type": "string", "description": "Stable non-secret identifier for this key" },
  220. "key": { "type": "string", "description": "Secret key value — shown only once" },
  221. "label": { "type": "string" },
  222. "projects": { "type": "array", "items": { "type": "string" } },
  223. "admin": { "type": "boolean" }
  224. }
  225. }
  226. }
  227. }
  228. },
  229. "401": { "description": "Unauthorized" },
  230. "403": { "description": "Forbidden — admin required" },
  231. "422": { "description": "Validation error" }
  232. }
  233. }
  234. },
  235. "/api/v1/keys/{id}": {
  236. "parameters": [
  237. {
  238. "name": "id",
  239. "in": "path",
  240. "required": true,
  241. "schema": { "type": "string" },
  242. "description": "Stable non-secret key id (from the id field in list/create responses)"
  243. }
  244. ],
  245. "patch": {
  246. "summary": "Update key grants (admin only)",
  247. "operationId": "updateKey",
  248. "requestBody": {
  249. "required": true,
  250. "content": {
  251. "application/json": {
  252. "schema": {
  253. "type": "object",
  254. "properties": {
  255. "label": { "type": "string" },
  256. "projects": { "type": "array", "items": { "type": "string" } },
  257. "admin": { "type": "boolean" }
  258. }
  259. }
  260. }
  261. }
  262. },
  263. "responses": {
  264. "200": { "description": "Key updated" },
  265. "401": { "description": "Unauthorized" },
  266. "403": { "description": "Forbidden — admin required" },
  267. "404": { "description": "Key not found" }
  268. }
  269. },
  270. "delete": {
  271. "summary": "Revoke an API key (admin only)",
  272. "operationId": "deleteKey",
  273. "responses": {
  274. "200": { "description": "Key revoked" },
  275. "401": { "description": "Unauthorized" },
  276. "403": { "description": "Forbidden — admin required" },
  277. "404": { "description": "Key not found" }
  278. }
  279. }
  280. },
  281. "/api/v1/projects/{project}/collections": {
  282. "parameters": [
  283. {
  284. "name": "project",
  285. "in": "path",
  286. "required": true,
  287. "schema": { "type": "string" },
  288. "description": "Project name"
  289. }
  290. ],
  291. "get": {
  292. "summary": "List collections in a project",
  293. "operationId": "listCollections",
  294. "parameters": [
  295. {
  296. "name": "q",
  297. "in": "query",
  298. "schema": { "type": "string" },
  299. "description": "Case-insensitive substring filter on collection name (applied server-side)."
  300. },
  301. {
  302. "name": "sort",
  303. "in": "query",
  304. "schema": { "type": "string", "enum": ["name", "kind", "documents", "size", "created_at"], "default": "name" },
  305. "description": "Field to sort by (applied server-side). Ties break by name."
  306. },
  307. {
  308. "name": "desc",
  309. "in": "query",
  310. "schema": { "type": "boolean", "default": false }
  311. }
  312. ],
  313. "responses": {
  314. "200": {
  315. "description": "Collection list",
  316. "content": {
  317. "application/json": {
  318. "schema": {
  319. "type": "object",
  320. "properties": {
  321. "collections": {
  322. "type": "array",
  323. "items": { "$ref": "#/components/schemas/CollectionMeta" }
  324. }
  325. }
  326. }
  327. }
  328. }
  329. },
  330. "401": { "description": "Unauthorized" },
  331. "403": { "description": "Forbidden" }
  332. }
  333. },
  334. "post": {
  335. "summary": "Create a collection in a project",
  336. "operationId": "createCollection",
  337. "requestBody": {
  338. "required": true,
  339. "content": {
  340. "application/json": {
  341. "schema": {
  342. "type": "object",
  343. "properties": {
  344. "name": { "type": "string" },
  345. "kind": { "type": "string", "enum": ["json", "vector"] },
  346. "vector_dimension": {
  347. "type": "integer",
  348. "minimum": 1,
  349. "description": "Required when kind=vector"
  350. },
  351. "embedding_model": {
  352. "type": "string",
  353. "description": "Optional; defaults to global default_embedding_model"
  354. }
  355. },
  356. "required": ["name", "kind"]
  357. }
  358. }
  359. }
  360. },
  361. "responses": {
  362. "201": { "description": "Collection created" },
  363. "401": { "description": "Unauthorized" },
  364. "403": { "description": "Forbidden" },
  365. "422": { "description": "Validation error (e.g. missing vector_dimension for vector kind)" }
  366. }
  367. }
  368. },
  369. "/api/v1/projects/{project}/collections/{name}": {
  370. "parameters": [
  371. {
  372. "name": "project",
  373. "in": "path",
  374. "required": true,
  375. "schema": { "type": "string" },
  376. "description": "Project name"
  377. },
  378. {
  379. "name": "name",
  380. "in": "path",
  381. "required": true,
  382. "schema": { "type": "string" },
  383. "description": "Collection name"
  384. }
  385. ],
  386. "get": {
  387. "summary": "Get collection metadata",
  388. "operationId": "getCollection",
  389. "responses": {
  390. "200": {
  391. "description": "Collection metadata",
  392. "content": {
  393. "application/json": {
  394. "schema": { "$ref": "#/components/schemas/CollectionMeta" }
  395. }
  396. }
  397. },
  398. "401": { "description": "Unauthorized" },
  399. "403": { "description": "Forbidden" },
  400. "404": { "description": "Collection not found" }
  401. }
  402. },
  403. "delete": {
  404. "summary": "Drop a collection and all its documents",
  405. "operationId": "deleteCollection",
  406. "responses": {
  407. "200": { "description": "Collection deleted" },
  408. "401": { "description": "Unauthorized" },
  409. "403": { "description": "Forbidden" },
  410. "404": { "description": "Collection not found" }
  411. }
  412. }
  413. },
  414. "/api/v1/projects/{project}/collections/{name}/documents": {
  415. "parameters": [
  416. {
  417. "name": "project",
  418. "in": "path",
  419. "required": true,
  420. "schema": { "type": "string" },
  421. "description": "Project name"
  422. },
  423. {
  424. "name": "name",
  425. "in": "path",
  426. "required": true,
  427. "schema": { "type": "string" },
  428. "description": "Collection name"
  429. }
  430. ],
  431. "get": {
  432. "summary": "Find documents with optional filter, pagination, and sort",
  433. "operationId": "findDocuments",
  434. "parameters": [
  435. {
  436. "name": "filter",
  437. "in": "query",
  438. "schema": { "type": "string" },
  439. "description": "Filter expression in field:op:value grammar (e.g. age:gte:30, name:eq:Alice). Multiple filters are ANDed."
  440. },
  441. {
  442. "name": "limit",
  443. "in": "query",
  444. "schema": { "type": "integer", "default": 20 }
  445. },
  446. {
  447. "name": "offset",
  448. "in": "query",
  449. "schema": { "type": "integer", "default": 0 }
  450. },
  451. {
  452. "name": "sort",
  453. "in": "query",
  454. "schema": { "type": "string" },
  455. "description": "Field to sort by"
  456. },
  457. {
  458. "name": "desc",
  459. "in": "query",
  460. "schema": { "type": "boolean", "default": false }
  461. }
  462. ],
  463. "responses": {
  464. "200": {
  465. "description": "Document list",
  466. "content": {
  467. "application/json": {
  468. "schema": {
  469. "type": "object",
  470. "properties": {
  471. "documents": { "type": "array", "items": { "type": "object" } },
  472. "count": { "type": "integer" }
  473. }
  474. }
  475. }
  476. }
  477. },
  478. "401": { "description": "Unauthorized" },
  479. "403": { "description": "Forbidden" },
  480. "404": { "description": "Collection not found" }
  481. }
  482. },
  483. "post": {
  484. "summary": "Insert a new JSON document",
  485. "operationId": "insertDocument",
  486. "requestBody": {
  487. "required": true,
  488. "content": {
  489. "application/json": {
  490. "schema": {
  491. "type": "object",
  492. "properties": {
  493. "data": {
  494. "type": "object",
  495. "description": "Arbitrary JSON document payload"
  496. }
  497. }
  498. }
  499. }
  500. }
  501. },
  502. "responses": {
  503. "201": {
  504. "description": "Document inserted",
  505. "content": {
  506. "application/json": {
  507. "schema": {
  508. "type": "object",
  509. "properties": {
  510. "id": { "type": "string" }
  511. }
  512. }
  513. }
  514. }
  515. },
  516. "401": { "description": "Unauthorized" },
  517. "403": { "description": "Forbidden" },
  518. "404": { "description": "Collection not found" },
  519. "422": { "description": "Validation error" }
  520. }
  521. }
  522. },
  523. "/api/v1/projects/{project}/collections/{name}/documents/{id}": {
  524. "parameters": [
  525. {
  526. "name": "project",
  527. "in": "path",
  528. "required": true,
  529. "schema": { "type": "string" },
  530. "description": "Project name"
  531. },
  532. {
  533. "name": "name",
  534. "in": "path",
  535. "required": true,
  536. "schema": { "type": "string" },
  537. "description": "Collection name"
  538. },
  539. {
  540. "name": "id",
  541. "in": "path",
  542. "required": true,
  543. "schema": { "type": "string" },
  544. "description": "Document ID"
  545. }
  546. ],
  547. "get": {
  548. "summary": "Get a document by ID",
  549. "operationId": "getDocument",
  550. "responses": {
  551. "200": {
  552. "description": "Document",
  553. "content": {
  554. "application/json": {
  555. "schema": { "type": "object" }
  556. }
  557. }
  558. },
  559. "401": { "description": "Unauthorized" },
  560. "403": { "description": "Forbidden" },
  561. "404": { "description": "Document not found" }
  562. }
  563. },
  564. "put": {
  565. "summary": "Replace a document (full upsert by ID)",
  566. "operationId": "replaceDocument",
  567. "requestBody": {
  568. "required": true,
  569. "content": {
  570. "application/json": {
  571. "schema": { "type": "object" }
  572. }
  573. }
  574. },
  575. "responses": {
  576. "200": { "description": "Document replaced" },
  577. "401": { "description": "Unauthorized" },
  578. "403": { "description": "Forbidden" },
  579. "404": { "description": "Collection not found" },
  580. "422": { "description": "Validation error" }
  581. }
  582. },
  583. "patch": {
  584. "summary": "Partially update a document (merge fields)",
  585. "operationId": "patchDocument",
  586. "requestBody": {
  587. "required": true,
  588. "content": {
  589. "application/json": {
  590. "schema": { "type": "object" }
  591. }
  592. }
  593. },
  594. "responses": {
  595. "200": { "description": "Document updated" },
  596. "401": { "description": "Unauthorized" },
  597. "403": { "description": "Forbidden" },
  598. "404": { "description": "Document not found" },
  599. "422": { "description": "Validation error" }
  600. }
  601. },
  602. "delete": {
  603. "summary": "Delete a document by ID",
  604. "operationId": "deleteDocument",
  605. "responses": {
  606. "200": { "description": "Document deleted" },
  607. "401": { "description": "Unauthorized" },
  608. "403": { "description": "Forbidden" },
  609. "404": { "description": "Document not found" }
  610. }
  611. }
  612. },
  613. "/api/v1/projects/{project}/collections/{name}/vectors": {
  614. "parameters": [
  615. {
  616. "name": "project",
  617. "in": "path",
  618. "required": true,
  619. "schema": { "type": "string" },
  620. "description": "Project name"
  621. },
  622. {
  623. "name": "name",
  624. "in": "path",
  625. "required": true,
  626. "schema": { "type": "string" },
  627. "description": "Collection name (must be kind=vector)"
  628. }
  629. ],
  630. "post": {
  631. "summary": "Store a vector; supply either text (auto-embedded) or an explicit vector array",
  632. "operationId": "upsertVector",
  633. "requestBody": {
  634. "required": true,
  635. "content": {
  636. "application/json": {
  637. "schema": {
  638. "type": "object",
  639. "properties": {
  640. "id": {
  641. "type": "string",
  642. "description": "Optional stable ID; auto-generated if omitted"
  643. },
  644. "text": {
  645. "type": "string",
  646. "description": "Source text; will be embedded using the collection's embedding_model"
  647. },
  648. "vector": {
  649. "type": "array",
  650. "items": { "type": "number" },
  651. "description": "Pre-computed embedding; dimension must match the collection's vector_dimension"
  652. },
  653. "metadata": {
  654. "type": "object",
  655. "description": "Arbitrary JSON payload stored alongside the vector"
  656. }
  657. }
  658. }
  659. }
  660. }
  661. },
  662. "responses": {
  663. "201": {
  664. "description": "Vector stored",
  665. "content": {
  666. "application/json": {
  667. "schema": {
  668. "type": "object",
  669. "properties": {
  670. "id": { "type": "string" }
  671. }
  672. }
  673. }
  674. }
  675. },
  676. "401": { "description": "Unauthorized" },
  677. "403": { "description": "Forbidden" },
  678. "404": { "description": "Collection not found" },
  679. "422": { "description": "Validation error (wrong dimension, not a vector collection, etc.)" }
  680. }
  681. }
  682. },
  683. "/api/v1/projects/{project}/collections/{name}/search": {
  684. "parameters": [
  685. {
  686. "name": "project",
  687. "in": "path",
  688. "required": true,
  689. "schema": { "type": "string" },
  690. "description": "Project name"
  691. },
  692. {
  693. "name": "name",
  694. "in": "path",
  695. "required": true,
  696. "schema": { "type": "string" },
  697. "description": "Collection name (must be kind=vector)"
  698. }
  699. ],
  700. "post": {
  701. "summary": "Cosine-similarity search; supply either query_text (auto-embedded) or query_vector",
  702. "description": "Supply either `query_text` or `query_vector`. **For low latency, prefer `query_vector`.** `query_text` requires a synchronous server-side embedding round-trip to the configured provider, which typically dominates request latency (seconds for large models). Clients issuing many searches (e.g. an LLM/n8n agent) should embed once on their side and pass `query_vector` to skip that step entirely; cosine search itself is sub-millisecond.",
  703. "operationId": "searchVectors",
  704. "requestBody": {
  705. "required": true,
  706. "content": {
  707. "application/json": {
  708. "schema": {
  709. "type": "object",
  710. "properties": {
  711. "query_text": {
  712. "type": "string",
  713. "description": "Query text; embedded with the collection's model. Slow path: incurs a server-side embedding round-trip. Prefer query_vector when you can pre-embed."
  714. },
  715. "query_vector": {
  716. "type": "array",
  717. "items": { "type": "number" },
  718. "description": "Pre-computed query embedding (length must equal the collection's vector_dimension). Fast path: skips server-side embedding."
  719. },
  720. "top_k": {
  721. "type": "integer",
  722. "minimum": 1,
  723. "description": "Maximum number of results to return"
  724. },
  725. "min_score": {
  726. "type": "number",
  727. "description": "Minimum cosine similarity score (0–1)"
  728. },
  729. "filters": {
  730. "type": "array",
  731. "items": { "type": "string" },
  732. "description": "Metadata filters in field:op:value grammar (e.g. src:eq:n8n)"
  733. }
  734. },
  735. "required": ["top_k"]
  736. }
  737. }
  738. }
  739. },
  740. "responses": {
  741. "200": {
  742. "description": "Search results",
  743. "content": {
  744. "application/json": {
  745. "schema": {
  746. "type": "object",
  747. "properties": {
  748. "results": {
  749. "type": "array",
  750. "items": {
  751. "type": "object",
  752. "properties": {
  753. "id": { "type": "string" },
  754. "score": { "type": "number" },
  755. "metadata": { "type": "object" }
  756. }
  757. }
  758. }
  759. }
  760. }
  761. }
  762. }
  763. },
  764. "401": { "description": "Unauthorized" },
  765. "403": { "description": "Forbidden" },
  766. "404": { "description": "Collection not found" },
  767. "422": { "description": "Validation error" }
  768. }
  769. }
  770. },
  771. "/api/v1/projects/{project}/stats": {
  772. "parameters": [
  773. {
  774. "name": "project",
  775. "in": "path",
  776. "required": true,
  777. "schema": { "type": "string" },
  778. "description": "Project name"
  779. }
  780. ],
  781. "get": {
  782. "summary": "Per-project stats (accessible by any key granted the project)",
  783. "operationId": "projectStats",
  784. "responses": {
  785. "200": {
  786. "description": "Project stats",
  787. "content": {
  788. "application/json": {
  789. "schema": {
  790. "type": "object",
  791. "properties": {
  792. "project": { "type": "string" },
  793. "collections": { "type": "integer" },
  794. "documents": { "type": "integer" }
  795. }
  796. }
  797. }
  798. }
  799. },
  800. "401": { "description": "Unauthorized" },
  801. "403": { "description": "Forbidden" }
  802. }
  803. }
  804. },
  805. "/api/v1/settings": {
  806. "get": {
  807. "summary": "Get current settings (admin only); openai_api_key is masked to a boolean openai_api_key_set",
  808. "operationId": "getSettings",
  809. "responses": {
  810. "200": {
  811. "description": "Settings (with secret masked)",
  812. "content": {
  813. "application/json": {
  814. "schema": {
  815. "type": "object",
  816. "properties": {
  817. "openai_api_base": { "type": "string" },
  818. "openai_api_key_set": { "type": "boolean" },
  819. "default_embedding_model": { "type": "string" },
  820. "cors_origins": { "type": "array", "items": { "type": "string" } },
  821. "session_ttl_minutes": { "type": "integer" },
  822. "webui_enabled": { "type": "boolean" },
  823. "default_project": { "type": "string" }
  824. }
  825. }
  826. }
  827. }
  828. },
  829. "401": { "description": "Unauthorized" },
  830. "403": { "description": "Forbidden — admin required" }
  831. }
  832. },
  833. "put": {
  834. "summary": "Update settings (admin only); omit openai_api_key to keep the existing secret",
  835. "operationId": "updateSettings",
  836. "requestBody": {
  837. "required": true,
  838. "content": {
  839. "application/json": {
  840. "schema": {
  841. "type": "object",
  842. "properties": {
  843. "openai_api_base": { "type": "string" },
  844. "openai_api_key": { "type": "string", "description": "Omit or pass empty string to preserve the existing key" },
  845. "default_embedding_model": { "type": "string" },
  846. "cors_origins": { "type": "array", "items": { "type": "string" } },
  847. "session_ttl_minutes": { "type": "integer", "minimum": 1 },
  848. "webui_enabled": { "type": "boolean" },
  849. "default_project": { "type": "string" },
  850. "embedding_connect_timeout_sec": { "type": "integer", "minimum": 1, "description": "Embedding HTTP connect timeout in seconds (default 10)" },
  851. "embedding_read_timeout_sec": { "type": "integer", "minimum": 1, "description": "Embedding HTTP read timeout in seconds (default 60)" }
  852. }
  853. }
  854. }
  855. }
  856. },
  857. "responses": {
  858. "200": { "description": "Settings updated", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" } } } } } },
  859. "401": { "description": "Unauthorized" },
  860. "403": { "description": "Forbidden — admin required" }
  861. }
  862. }
  863. },
  864. "/api/v1/stats": {
  865. "get": {
  866. "summary": "Server-wide stats (admin only)",
  867. "operationId": "globalStats",
  868. "responses": {
  869. "200": {
  870. "description": "Global stats",
  871. "content": {
  872. "application/json": {
  873. "schema": {
  874. "type": "object",
  875. "properties": {
  876. "projects": { "type": "integer" },
  877. "memory_pressure_level": { "type": "integer" },
  878. "collections": { "type": "integer" },
  879. "documents": { "type": "integer" }
  880. }
  881. }
  882. }
  883. }
  884. },
  885. "401": { "description": "Unauthorized" },
  886. "403": { "description": "Forbidden — admin required" }
  887. }
  888. }
  889. }
  890. }
  891. }