openapi.json 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  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. "responses": {
  295. "200": {
  296. "description": "Collection list",
  297. "content": {
  298. "application/json": {
  299. "schema": {
  300. "type": "object",
  301. "properties": {
  302. "collections": {
  303. "type": "array",
  304. "items": { "$ref": "#/components/schemas/CollectionMeta" }
  305. }
  306. }
  307. }
  308. }
  309. }
  310. },
  311. "401": { "description": "Unauthorized" },
  312. "403": { "description": "Forbidden" }
  313. }
  314. },
  315. "post": {
  316. "summary": "Create a collection in a project",
  317. "operationId": "createCollection",
  318. "requestBody": {
  319. "required": true,
  320. "content": {
  321. "application/json": {
  322. "schema": {
  323. "type": "object",
  324. "properties": {
  325. "name": { "type": "string" },
  326. "kind": { "type": "string", "enum": ["json", "vector"] },
  327. "vector_dimension": {
  328. "type": "integer",
  329. "minimum": 1,
  330. "description": "Required when kind=vector"
  331. },
  332. "embedding_model": {
  333. "type": "string",
  334. "description": "Optional; defaults to global default_embedding_model"
  335. }
  336. },
  337. "required": ["name", "kind"]
  338. }
  339. }
  340. }
  341. },
  342. "responses": {
  343. "201": { "description": "Collection created" },
  344. "401": { "description": "Unauthorized" },
  345. "403": { "description": "Forbidden" },
  346. "422": { "description": "Validation error (e.g. missing vector_dimension for vector kind)" }
  347. }
  348. }
  349. },
  350. "/api/v1/projects/{project}/collections/{name}": {
  351. "parameters": [
  352. {
  353. "name": "project",
  354. "in": "path",
  355. "required": true,
  356. "schema": { "type": "string" },
  357. "description": "Project name"
  358. },
  359. {
  360. "name": "name",
  361. "in": "path",
  362. "required": true,
  363. "schema": { "type": "string" },
  364. "description": "Collection name"
  365. }
  366. ],
  367. "get": {
  368. "summary": "Get collection metadata",
  369. "operationId": "getCollection",
  370. "responses": {
  371. "200": {
  372. "description": "Collection metadata",
  373. "content": {
  374. "application/json": {
  375. "schema": { "$ref": "#/components/schemas/CollectionMeta" }
  376. }
  377. }
  378. },
  379. "401": { "description": "Unauthorized" },
  380. "403": { "description": "Forbidden" },
  381. "404": { "description": "Collection not found" }
  382. }
  383. },
  384. "delete": {
  385. "summary": "Drop a collection and all its documents",
  386. "operationId": "deleteCollection",
  387. "responses": {
  388. "200": { "description": "Collection deleted" },
  389. "401": { "description": "Unauthorized" },
  390. "403": { "description": "Forbidden" },
  391. "404": { "description": "Collection not found" }
  392. }
  393. }
  394. },
  395. "/api/v1/projects/{project}/collections/{name}/documents": {
  396. "parameters": [
  397. {
  398. "name": "project",
  399. "in": "path",
  400. "required": true,
  401. "schema": { "type": "string" },
  402. "description": "Project name"
  403. },
  404. {
  405. "name": "name",
  406. "in": "path",
  407. "required": true,
  408. "schema": { "type": "string" },
  409. "description": "Collection name"
  410. }
  411. ],
  412. "get": {
  413. "summary": "Find documents with optional filter, pagination, and sort",
  414. "operationId": "findDocuments",
  415. "parameters": [
  416. {
  417. "name": "filter",
  418. "in": "query",
  419. "schema": { "type": "string" },
  420. "description": "Filter expression in field:op:value grammar (e.g. age:gte:30, name:eq:Alice). Multiple filters are ANDed."
  421. },
  422. {
  423. "name": "limit",
  424. "in": "query",
  425. "schema": { "type": "integer", "default": 20 }
  426. },
  427. {
  428. "name": "offset",
  429. "in": "query",
  430. "schema": { "type": "integer", "default": 0 }
  431. },
  432. {
  433. "name": "sort",
  434. "in": "query",
  435. "schema": { "type": "string" },
  436. "description": "Field to sort by"
  437. },
  438. {
  439. "name": "desc",
  440. "in": "query",
  441. "schema": { "type": "boolean", "default": false }
  442. }
  443. ],
  444. "responses": {
  445. "200": {
  446. "description": "Document list",
  447. "content": {
  448. "application/json": {
  449. "schema": {
  450. "type": "object",
  451. "properties": {
  452. "documents": { "type": "array", "items": { "type": "object" } },
  453. "count": { "type": "integer" }
  454. }
  455. }
  456. }
  457. }
  458. },
  459. "401": { "description": "Unauthorized" },
  460. "403": { "description": "Forbidden" },
  461. "404": { "description": "Collection not found" }
  462. }
  463. },
  464. "post": {
  465. "summary": "Insert a new JSON document",
  466. "operationId": "insertDocument",
  467. "requestBody": {
  468. "required": true,
  469. "content": {
  470. "application/json": {
  471. "schema": {
  472. "type": "object",
  473. "properties": {
  474. "data": {
  475. "type": "object",
  476. "description": "Arbitrary JSON document payload"
  477. }
  478. }
  479. }
  480. }
  481. }
  482. },
  483. "responses": {
  484. "201": {
  485. "description": "Document inserted",
  486. "content": {
  487. "application/json": {
  488. "schema": {
  489. "type": "object",
  490. "properties": {
  491. "id": { "type": "string" }
  492. }
  493. }
  494. }
  495. }
  496. },
  497. "401": { "description": "Unauthorized" },
  498. "403": { "description": "Forbidden" },
  499. "404": { "description": "Collection not found" },
  500. "422": { "description": "Validation error" }
  501. }
  502. }
  503. },
  504. "/api/v1/projects/{project}/collections/{name}/documents/{id}": {
  505. "parameters": [
  506. {
  507. "name": "project",
  508. "in": "path",
  509. "required": true,
  510. "schema": { "type": "string" },
  511. "description": "Project name"
  512. },
  513. {
  514. "name": "name",
  515. "in": "path",
  516. "required": true,
  517. "schema": { "type": "string" },
  518. "description": "Collection name"
  519. },
  520. {
  521. "name": "id",
  522. "in": "path",
  523. "required": true,
  524. "schema": { "type": "string" },
  525. "description": "Document ID"
  526. }
  527. ],
  528. "get": {
  529. "summary": "Get a document by ID",
  530. "operationId": "getDocument",
  531. "responses": {
  532. "200": {
  533. "description": "Document",
  534. "content": {
  535. "application/json": {
  536. "schema": { "type": "object" }
  537. }
  538. }
  539. },
  540. "401": { "description": "Unauthorized" },
  541. "403": { "description": "Forbidden" },
  542. "404": { "description": "Document not found" }
  543. }
  544. },
  545. "put": {
  546. "summary": "Replace a document (full upsert by ID)",
  547. "operationId": "replaceDocument",
  548. "requestBody": {
  549. "required": true,
  550. "content": {
  551. "application/json": {
  552. "schema": { "type": "object" }
  553. }
  554. }
  555. },
  556. "responses": {
  557. "200": { "description": "Document replaced" },
  558. "401": { "description": "Unauthorized" },
  559. "403": { "description": "Forbidden" },
  560. "404": { "description": "Collection not found" },
  561. "422": { "description": "Validation error" }
  562. }
  563. },
  564. "patch": {
  565. "summary": "Partially update a document (merge fields)",
  566. "operationId": "patchDocument",
  567. "requestBody": {
  568. "required": true,
  569. "content": {
  570. "application/json": {
  571. "schema": { "type": "object" }
  572. }
  573. }
  574. },
  575. "responses": {
  576. "200": { "description": "Document updated" },
  577. "401": { "description": "Unauthorized" },
  578. "403": { "description": "Forbidden" },
  579. "404": { "description": "Document not found" },
  580. "422": { "description": "Validation error" }
  581. }
  582. },
  583. "delete": {
  584. "summary": "Delete a document by ID",
  585. "operationId": "deleteDocument",
  586. "responses": {
  587. "200": { "description": "Document deleted" },
  588. "401": { "description": "Unauthorized" },
  589. "403": { "description": "Forbidden" },
  590. "404": { "description": "Document not found" }
  591. }
  592. }
  593. },
  594. "/api/v1/projects/{project}/collections/{name}/vectors": {
  595. "parameters": [
  596. {
  597. "name": "project",
  598. "in": "path",
  599. "required": true,
  600. "schema": { "type": "string" },
  601. "description": "Project name"
  602. },
  603. {
  604. "name": "name",
  605. "in": "path",
  606. "required": true,
  607. "schema": { "type": "string" },
  608. "description": "Collection name (must be kind=vector)"
  609. }
  610. ],
  611. "post": {
  612. "summary": "Store a vector; supply either text (auto-embedded) or an explicit vector array",
  613. "operationId": "upsertVector",
  614. "requestBody": {
  615. "required": true,
  616. "content": {
  617. "application/json": {
  618. "schema": {
  619. "type": "object",
  620. "properties": {
  621. "id": {
  622. "type": "string",
  623. "description": "Optional stable ID; auto-generated if omitted"
  624. },
  625. "text": {
  626. "type": "string",
  627. "description": "Source text; will be embedded using the collection's embedding_model"
  628. },
  629. "vector": {
  630. "type": "array",
  631. "items": { "type": "number" },
  632. "description": "Pre-computed embedding; dimension must match the collection's vector_dimension"
  633. },
  634. "metadata": {
  635. "type": "object",
  636. "description": "Arbitrary JSON payload stored alongside the vector"
  637. }
  638. }
  639. }
  640. }
  641. }
  642. },
  643. "responses": {
  644. "201": {
  645. "description": "Vector stored",
  646. "content": {
  647. "application/json": {
  648. "schema": {
  649. "type": "object",
  650. "properties": {
  651. "id": { "type": "string" }
  652. }
  653. }
  654. }
  655. }
  656. },
  657. "401": { "description": "Unauthorized" },
  658. "403": { "description": "Forbidden" },
  659. "404": { "description": "Collection not found" },
  660. "422": { "description": "Validation error (wrong dimension, not a vector collection, etc.)" }
  661. }
  662. }
  663. },
  664. "/api/v1/projects/{project}/collections/{name}/search": {
  665. "parameters": [
  666. {
  667. "name": "project",
  668. "in": "path",
  669. "required": true,
  670. "schema": { "type": "string" },
  671. "description": "Project name"
  672. },
  673. {
  674. "name": "name",
  675. "in": "path",
  676. "required": true,
  677. "schema": { "type": "string" },
  678. "description": "Collection name (must be kind=vector)"
  679. }
  680. ],
  681. "post": {
  682. "summary": "Cosine-similarity search; supply either query_text (auto-embedded) or query_vector",
  683. "operationId": "searchVectors",
  684. "requestBody": {
  685. "required": true,
  686. "content": {
  687. "application/json": {
  688. "schema": {
  689. "type": "object",
  690. "properties": {
  691. "query_text": {
  692. "type": "string",
  693. "description": "Query text; embedded with the collection's model"
  694. },
  695. "query_vector": {
  696. "type": "array",
  697. "items": { "type": "number" },
  698. "description": "Pre-computed query embedding"
  699. },
  700. "top_k": {
  701. "type": "integer",
  702. "minimum": 1,
  703. "description": "Maximum number of results to return"
  704. },
  705. "min_score": {
  706. "type": "number",
  707. "description": "Minimum cosine similarity score (0–1)"
  708. },
  709. "filters": {
  710. "type": "array",
  711. "items": { "type": "string" },
  712. "description": "Metadata filters in field:op:value grammar (e.g. src:eq:n8n)"
  713. }
  714. },
  715. "required": ["top_k"]
  716. }
  717. }
  718. }
  719. },
  720. "responses": {
  721. "200": {
  722. "description": "Search results",
  723. "content": {
  724. "application/json": {
  725. "schema": {
  726. "type": "object",
  727. "properties": {
  728. "results": {
  729. "type": "array",
  730. "items": {
  731. "type": "object",
  732. "properties": {
  733. "id": { "type": "string" },
  734. "score": { "type": "number" },
  735. "metadata": { "type": "object" }
  736. }
  737. }
  738. }
  739. }
  740. }
  741. }
  742. }
  743. },
  744. "401": { "description": "Unauthorized" },
  745. "403": { "description": "Forbidden" },
  746. "404": { "description": "Collection not found" },
  747. "422": { "description": "Validation error" }
  748. }
  749. }
  750. },
  751. "/api/v1/projects/{project}/stats": {
  752. "parameters": [
  753. {
  754. "name": "project",
  755. "in": "path",
  756. "required": true,
  757. "schema": { "type": "string" },
  758. "description": "Project name"
  759. }
  760. ],
  761. "get": {
  762. "summary": "Per-project stats (accessible by any key granted the project)",
  763. "operationId": "projectStats",
  764. "responses": {
  765. "200": {
  766. "description": "Project stats",
  767. "content": {
  768. "application/json": {
  769. "schema": {
  770. "type": "object",
  771. "properties": {
  772. "project": { "type": "string" },
  773. "collections": { "type": "integer" },
  774. "documents": { "type": "integer" }
  775. }
  776. }
  777. }
  778. }
  779. },
  780. "401": { "description": "Unauthorized" },
  781. "403": { "description": "Forbidden" }
  782. }
  783. }
  784. },
  785. "/api/v1/settings": {
  786. "get": {
  787. "summary": "Get current settings (admin only); openai_api_key is masked to a boolean openai_api_key_set",
  788. "operationId": "getSettings",
  789. "responses": {
  790. "200": {
  791. "description": "Settings (with secret masked)",
  792. "content": {
  793. "application/json": {
  794. "schema": {
  795. "type": "object",
  796. "properties": {
  797. "openai_api_base": { "type": "string" },
  798. "openai_api_key_set": { "type": "boolean" },
  799. "default_embedding_model": { "type": "string" },
  800. "cors_origins": { "type": "array", "items": { "type": "string" } },
  801. "session_ttl_minutes": { "type": "integer" },
  802. "webui_enabled": { "type": "boolean" },
  803. "default_project": { "type": "string" }
  804. }
  805. }
  806. }
  807. }
  808. },
  809. "401": { "description": "Unauthorized" },
  810. "403": { "description": "Forbidden — admin required" }
  811. }
  812. },
  813. "put": {
  814. "summary": "Update settings (admin only); omit openai_api_key to keep the existing secret",
  815. "operationId": "updateSettings",
  816. "requestBody": {
  817. "required": true,
  818. "content": {
  819. "application/json": {
  820. "schema": {
  821. "type": "object",
  822. "properties": {
  823. "openai_api_base": { "type": "string" },
  824. "openai_api_key": { "type": "string", "description": "Omit or pass empty string to preserve the existing key" },
  825. "default_embedding_model": { "type": "string" },
  826. "cors_origins": { "type": "array", "items": { "type": "string" } },
  827. "session_ttl_minutes": { "type": "integer", "minimum": 1 },
  828. "webui_enabled": { "type": "boolean" },
  829. "default_project": { "type": "string" }
  830. }
  831. }
  832. }
  833. }
  834. },
  835. "responses": {
  836. "200": { "description": "Settings updated", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" } } } } } },
  837. "401": { "description": "Unauthorized" },
  838. "403": { "description": "Forbidden — admin required" }
  839. }
  840. }
  841. },
  842. "/api/v1/stats": {
  843. "get": {
  844. "summary": "Server-wide stats (admin only)",
  845. "operationId": "globalStats",
  846. "responses": {
  847. "200": {
  848. "description": "Global stats",
  849. "content": {
  850. "application/json": {
  851. "schema": {
  852. "type": "object",
  853. "properties": {
  854. "projects": { "type": "integer" },
  855. "memory_pressure_level": { "type": "integer" },
  856. "collections": { "type": "integer" },
  857. "documents": { "type": "integer" }
  858. }
  859. }
  860. }
  861. }
  862. },
  863. "401": { "description": "Unauthorized" },
  864. "403": { "description": "Forbidden — admin required" }
  865. }
  866. }
  867. }
  868. }
  869. }