openapi.json 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. {
  2. "openapi": "3.0.0",
  3. "info": {
  4. "title": "opencode",
  5. "description": "opencode api",
  6. "version": "1.0.0"
  7. },
  8. "paths": {
  9. "/event": {
  10. "get": {
  11. "responses": {
  12. "200": {
  13. "description": "Event stream",
  14. "content": {
  15. "application/json": {
  16. "schema": {
  17. "$ref": "#/components/schemas/Event"
  18. }
  19. }
  20. }
  21. }
  22. },
  23. "operationId": "getEvent",
  24. "parameters": [],
  25. "description": "Get events"
  26. }
  27. },
  28. "/path_get": {
  29. "post": {
  30. "responses": {
  31. "200": {
  32. "description": "200",
  33. "content": {
  34. "application/json": {
  35. "schema": {
  36. "type": "object",
  37. "properties": {
  38. "root": {
  39. "type": "string"
  40. },
  41. "data": {
  42. "type": "string"
  43. },
  44. "cwd": {
  45. "type": "string"
  46. },
  47. "config": {
  48. "type": "string"
  49. }
  50. },
  51. "required": [
  52. "root",
  53. "data",
  54. "cwd",
  55. "config"
  56. ]
  57. }
  58. }
  59. }
  60. }
  61. },
  62. "operationId": "postPath_get",
  63. "parameters": [],
  64. "description": "Get paths"
  65. }
  66. },
  67. "/session_create": {
  68. "post": {
  69. "responses": {
  70. "200": {
  71. "description": "Successfully created session",
  72. "content": {
  73. "application/json": {
  74. "schema": {
  75. "$ref": "#/components/schemas/session.info"
  76. }
  77. }
  78. }
  79. }
  80. },
  81. "operationId": "postSession_create",
  82. "parameters": [],
  83. "description": "Create a new session"
  84. }
  85. },
  86. "/session_share": {
  87. "post": {
  88. "responses": {
  89. "200": {
  90. "description": "Successfully shared session",
  91. "content": {
  92. "application/json": {
  93. "schema": {
  94. "$ref": "#/components/schemas/session.info"
  95. }
  96. }
  97. }
  98. }
  99. },
  100. "operationId": "postSession_share",
  101. "parameters": [],
  102. "description": "Share the session",
  103. "requestBody": {
  104. "content": {
  105. "application/json": {
  106. "schema": {
  107. "type": "object",
  108. "properties": {
  109. "sessionID": {
  110. "type": "string"
  111. }
  112. },
  113. "required": [
  114. "sessionID"
  115. ]
  116. }
  117. }
  118. }
  119. }
  120. }
  121. },
  122. "/session_messages": {
  123. "post": {
  124. "responses": {
  125. "200": {
  126. "description": "Successfully created session",
  127. "content": {
  128. "application/json": {
  129. "schema": {
  130. "type": "array",
  131. "items": {
  132. "$ref": "#/components/schemas/Message.Info"
  133. }
  134. }
  135. }
  136. }
  137. }
  138. },
  139. "operationId": "postSession_messages",
  140. "parameters": [],
  141. "description": "Get messages for a session",
  142. "requestBody": {
  143. "content": {
  144. "application/json": {
  145. "schema": {
  146. "type": "object",
  147. "properties": {
  148. "sessionID": {
  149. "type": "string"
  150. }
  151. },
  152. "required": [
  153. "sessionID"
  154. ]
  155. }
  156. }
  157. }
  158. }
  159. }
  160. },
  161. "/session_list": {
  162. "post": {
  163. "responses": {
  164. "200": {
  165. "description": "List of sessions",
  166. "content": {
  167. "application/json": {
  168. "schema": {
  169. "type": "array",
  170. "items": {
  171. "$ref": "#/components/schemas/session.info"
  172. }
  173. }
  174. }
  175. }
  176. }
  177. },
  178. "operationId": "postSession_list",
  179. "parameters": [],
  180. "description": "List all sessions"
  181. }
  182. },
  183. "/session_abort": {
  184. "post": {
  185. "responses": {
  186. "200": {
  187. "description": "Aborted session",
  188. "content": {
  189. "application/json": {
  190. "schema": {
  191. "type": "boolean"
  192. }
  193. }
  194. }
  195. }
  196. },
  197. "operationId": "postSession_abort",
  198. "parameters": [],
  199. "description": "Abort a session",
  200. "requestBody": {
  201. "content": {
  202. "application/json": {
  203. "schema": {
  204. "type": "object",
  205. "properties": {
  206. "sessionID": {
  207. "type": "string"
  208. }
  209. },
  210. "required": [
  211. "sessionID"
  212. ]
  213. }
  214. }
  215. }
  216. }
  217. }
  218. },
  219. "/session_summarize": {
  220. "post": {
  221. "responses": {
  222. "200": {
  223. "description": "Summarize the session",
  224. "content": {
  225. "application/json": {
  226. "schema": {
  227. "type": "boolean"
  228. }
  229. }
  230. }
  231. }
  232. },
  233. "operationId": "postSession_summarize",
  234. "parameters": [],
  235. "description": "Summarize the session",
  236. "requestBody": {
  237. "content": {
  238. "application/json": {
  239. "schema": {
  240. "type": "object",
  241. "properties": {
  242. "sessionID": {
  243. "type": "string"
  244. },
  245. "providerID": {
  246. "type": "string"
  247. },
  248. "modelID": {
  249. "type": "string"
  250. }
  251. },
  252. "required": [
  253. "sessionID",
  254. "providerID",
  255. "modelID"
  256. ]
  257. }
  258. }
  259. }
  260. }
  261. }
  262. },
  263. "/session_chat": {
  264. "post": {
  265. "responses": {
  266. "200": {
  267. "description": "Chat with a model",
  268. "content": {
  269. "application/json": {
  270. "schema": {
  271. "$ref": "#/components/schemas/Message.Info"
  272. }
  273. }
  274. }
  275. }
  276. },
  277. "operationId": "postSession_chat",
  278. "parameters": [],
  279. "description": "Chat with a model",
  280. "requestBody": {
  281. "content": {
  282. "application/json": {
  283. "schema": {
  284. "type": "object",
  285. "properties": {
  286. "sessionID": {
  287. "type": "string"
  288. },
  289. "providerID": {
  290. "type": "string"
  291. },
  292. "modelID": {
  293. "type": "string"
  294. },
  295. "parts": {
  296. "type": "array",
  297. "items": {
  298. "$ref": "#/components/schemas/Message.Part"
  299. }
  300. }
  301. },
  302. "required": [
  303. "sessionID",
  304. "providerID",
  305. "modelID",
  306. "parts"
  307. ]
  308. }
  309. }
  310. }
  311. }
  312. }
  313. },
  314. "/provider_list": {
  315. "post": {
  316. "responses": {
  317. "200": {
  318. "description": "List of providers",
  319. "content": {
  320. "application/json": {
  321. "schema": {
  322. "type": "array",
  323. "items": {
  324. "$ref": "#/components/schemas/Provider.Info"
  325. }
  326. }
  327. }
  328. }
  329. }
  330. },
  331. "operationId": "postProvider_list",
  332. "parameters": [],
  333. "description": "List all providers"
  334. }
  335. }
  336. },
  337. "components": {
  338. "schemas": {
  339. "Event": {
  340. "oneOf": [
  341. {
  342. "$ref": "#/components/schemas/Event.storage.write"
  343. },
  344. {
  345. "$ref": "#/components/schemas/Event.message.updated"
  346. },
  347. {
  348. "$ref": "#/components/schemas/Event.lsp.client.diagnostics"
  349. },
  350. {
  351. "$ref": "#/components/schemas/Event.permission.updated"
  352. },
  353. {
  354. "$ref": "#/components/schemas/Event.session.updated"
  355. }
  356. ],
  357. "discriminator": {
  358. "propertyName": "type",
  359. "mapping": {
  360. "storage.write": "#/components/schemas/Event.storage.write",
  361. "message.updated": "#/components/schemas/Event.message.updated",
  362. "lsp.client.diagnostics": "#/components/schemas/Event.lsp.client.diagnostics",
  363. "permission.updated": "#/components/schemas/Event.permission.updated",
  364. "session.updated": "#/components/schemas/Event.session.updated"
  365. }
  366. }
  367. },
  368. "Event.storage.write": {
  369. "type": "object",
  370. "properties": {
  371. "type": {
  372. "type": "string",
  373. "const": "storage.write"
  374. },
  375. "properties": {
  376. "type": "object",
  377. "properties": {
  378. "key": {
  379. "type": "string"
  380. },
  381. "content": {}
  382. },
  383. "required": [
  384. "key"
  385. ]
  386. }
  387. },
  388. "required": [
  389. "type",
  390. "properties"
  391. ]
  392. },
  393. "Event.message.updated": {
  394. "type": "object",
  395. "properties": {
  396. "type": {
  397. "type": "string",
  398. "const": "message.updated"
  399. },
  400. "properties": {
  401. "type": "object",
  402. "properties": {
  403. "info": {
  404. "$ref": "#/components/schemas/Message.Info"
  405. }
  406. },
  407. "required": [
  408. "info"
  409. ]
  410. }
  411. },
  412. "required": [
  413. "type",
  414. "properties"
  415. ]
  416. },
  417. "Message.Info": {
  418. "type": "object",
  419. "properties": {
  420. "id": {
  421. "type": "string"
  422. },
  423. "role": {
  424. "type": "string",
  425. "enum": [
  426. "system",
  427. "user",
  428. "assistant"
  429. ]
  430. },
  431. "parts": {
  432. "type": "array",
  433. "items": {
  434. "$ref": "#/components/schemas/Message.Part"
  435. }
  436. },
  437. "metadata": {
  438. "type": "object",
  439. "properties": {
  440. "time": {
  441. "type": "object",
  442. "properties": {
  443. "created": {
  444. "type": "number"
  445. },
  446. "completed": {
  447. "type": "number"
  448. }
  449. },
  450. "required": [
  451. "created"
  452. ]
  453. },
  454. "sessionID": {
  455. "type": "string"
  456. },
  457. "tool": {
  458. "type": "object",
  459. "additionalProperties": {}
  460. },
  461. "assistant": {
  462. "type": "object",
  463. "properties": {
  464. "modelID": {
  465. "type": "string"
  466. },
  467. "providerID": {
  468. "type": "string"
  469. },
  470. "cost": {
  471. "type": "number"
  472. },
  473. "summary": {
  474. "type": "boolean"
  475. },
  476. "tokens": {
  477. "type": "object",
  478. "properties": {
  479. "input": {
  480. "type": "number"
  481. },
  482. "output": {
  483. "type": "number"
  484. },
  485. "reasoning": {
  486. "type": "number"
  487. }
  488. },
  489. "required": [
  490. "input",
  491. "output",
  492. "reasoning"
  493. ]
  494. }
  495. },
  496. "required": [
  497. "modelID",
  498. "providerID",
  499. "cost",
  500. "tokens"
  501. ]
  502. }
  503. },
  504. "required": [
  505. "time",
  506. "sessionID",
  507. "tool"
  508. ]
  509. }
  510. },
  511. "required": [
  512. "id",
  513. "role",
  514. "parts",
  515. "metadata"
  516. ]
  517. },
  518. "Message.Part": {
  519. "oneOf": [
  520. {
  521. "$ref": "#/components/schemas/Message.Part.Text"
  522. },
  523. {
  524. "$ref": "#/components/schemas/Message.Part.Reasoning"
  525. },
  526. {
  527. "$ref": "#/components/schemas/Message.Part.ToolInvocation"
  528. },
  529. {
  530. "$ref": "#/components/schemas/Message.Part.SourceUrl"
  531. },
  532. {
  533. "$ref": "#/components/schemas/Message.Part.File"
  534. },
  535. {
  536. "$ref": "#/components/schemas/Message.Part.StepStart"
  537. }
  538. ],
  539. "discriminator": {
  540. "propertyName": "type",
  541. "mapping": {
  542. "text": "#/components/schemas/Message.Part.Text",
  543. "reasoning": "#/components/schemas/Message.Part.Reasoning",
  544. "tool-invocation": "#/components/schemas/Message.Part.ToolInvocation",
  545. "source-url": "#/components/schemas/Message.Part.SourceUrl",
  546. "file": "#/components/schemas/Message.Part.File",
  547. "step-start": "#/components/schemas/Message.Part.StepStart"
  548. }
  549. }
  550. },
  551. "Message.Part.Text": {
  552. "type": "object",
  553. "properties": {
  554. "type": {
  555. "type": "string",
  556. "const": "text"
  557. },
  558. "text": {
  559. "type": "string"
  560. }
  561. },
  562. "required": [
  563. "type",
  564. "text"
  565. ]
  566. },
  567. "Message.Part.Reasoning": {
  568. "type": "object",
  569. "properties": {
  570. "type": {
  571. "type": "string",
  572. "const": "reasoning"
  573. },
  574. "text": {
  575. "type": "string"
  576. },
  577. "providerMetadata": {
  578. "type": "object",
  579. "additionalProperties": {}
  580. }
  581. },
  582. "required": [
  583. "type",
  584. "text"
  585. ]
  586. },
  587. "Message.Part.ToolInvocation": {
  588. "type": "object",
  589. "properties": {
  590. "type": {
  591. "type": "string",
  592. "const": "tool-invocation"
  593. },
  594. "toolInvocation": {
  595. "$ref": "#/components/schemas/Message.ToolInvocation"
  596. }
  597. },
  598. "required": [
  599. "type",
  600. "toolInvocation"
  601. ]
  602. },
  603. "Message.ToolInvocation": {
  604. "oneOf": [
  605. {
  606. "$ref": "#/components/schemas/Message.ToolInvocation.ToolCall"
  607. },
  608. {
  609. "$ref": "#/components/schemas/Message.ToolInvocation.ToolPartialCall"
  610. },
  611. {
  612. "$ref": "#/components/schemas/Message.ToolInvocation.ToolResult"
  613. }
  614. ],
  615. "discriminator": {
  616. "propertyName": "state",
  617. "mapping": {
  618. "call": "#/components/schemas/Message.ToolInvocation.ToolCall",
  619. "partial-call": "#/components/schemas/Message.ToolInvocation.ToolPartialCall",
  620. "result": "#/components/schemas/Message.ToolInvocation.ToolResult"
  621. }
  622. }
  623. },
  624. "Message.ToolInvocation.ToolCall": {
  625. "type": "object",
  626. "properties": {
  627. "state": {
  628. "type": "string",
  629. "const": "call"
  630. },
  631. "step": {
  632. "type": "number"
  633. },
  634. "toolCallId": {
  635. "type": "string"
  636. },
  637. "toolName": {
  638. "type": "string"
  639. },
  640. "args": {}
  641. },
  642. "required": [
  643. "state",
  644. "toolCallId",
  645. "toolName"
  646. ]
  647. },
  648. "Message.ToolInvocation.ToolPartialCall": {
  649. "type": "object",
  650. "properties": {
  651. "state": {
  652. "type": "string",
  653. "const": "partial-call"
  654. },
  655. "step": {
  656. "type": "number"
  657. },
  658. "toolCallId": {
  659. "type": "string"
  660. },
  661. "toolName": {
  662. "type": "string"
  663. },
  664. "args": {}
  665. },
  666. "required": [
  667. "state",
  668. "toolCallId",
  669. "toolName"
  670. ]
  671. },
  672. "Message.ToolInvocation.ToolResult": {
  673. "type": "object",
  674. "properties": {
  675. "state": {
  676. "type": "string",
  677. "const": "result"
  678. },
  679. "step": {
  680. "type": "number"
  681. },
  682. "toolCallId": {
  683. "type": "string"
  684. },
  685. "toolName": {
  686. "type": "string"
  687. },
  688. "args": {},
  689. "result": {
  690. "type": "string"
  691. }
  692. },
  693. "required": [
  694. "state",
  695. "toolCallId",
  696. "toolName",
  697. "result"
  698. ]
  699. },
  700. "Message.Part.SourceUrl": {
  701. "type": "object",
  702. "properties": {
  703. "type": {
  704. "type": "string",
  705. "const": "source-url"
  706. },
  707. "sourceId": {
  708. "type": "string"
  709. },
  710. "url": {
  711. "type": "string"
  712. },
  713. "title": {
  714. "type": "string"
  715. },
  716. "providerMetadata": {
  717. "type": "object",
  718. "additionalProperties": {}
  719. }
  720. },
  721. "required": [
  722. "type",
  723. "sourceId",
  724. "url"
  725. ]
  726. },
  727. "Message.Part.File": {
  728. "type": "object",
  729. "properties": {
  730. "type": {
  731. "type": "string",
  732. "const": "file"
  733. },
  734. "mediaType": {
  735. "type": "string"
  736. },
  737. "filename": {
  738. "type": "string"
  739. },
  740. "url": {
  741. "type": "string"
  742. }
  743. },
  744. "required": [
  745. "type",
  746. "mediaType",
  747. "url"
  748. ]
  749. },
  750. "Message.Part.StepStart": {
  751. "type": "object",
  752. "properties": {
  753. "type": {
  754. "type": "string",
  755. "const": "step-start"
  756. }
  757. },
  758. "required": [
  759. "type"
  760. ]
  761. },
  762. "Event.lsp.client.diagnostics": {
  763. "type": "object",
  764. "properties": {
  765. "type": {
  766. "type": "string",
  767. "const": "lsp.client.diagnostics"
  768. },
  769. "properties": {
  770. "type": "object",
  771. "properties": {
  772. "serverID": {
  773. "type": "string"
  774. },
  775. "path": {
  776. "type": "string"
  777. }
  778. },
  779. "required": [
  780. "serverID",
  781. "path"
  782. ]
  783. }
  784. },
  785. "required": [
  786. "type",
  787. "properties"
  788. ]
  789. },
  790. "Event.permission.updated": {
  791. "type": "object",
  792. "properties": {
  793. "type": {
  794. "type": "string",
  795. "const": "permission.updated"
  796. },
  797. "properties": {
  798. "$ref": "#/components/schemas/permission.info"
  799. }
  800. },
  801. "required": [
  802. "type",
  803. "properties"
  804. ]
  805. },
  806. "permission.info": {
  807. "type": "object",
  808. "properties": {
  809. "id": {
  810. "type": "string"
  811. },
  812. "sessionID": {
  813. "type": "string"
  814. },
  815. "title": {
  816. "type": "string"
  817. },
  818. "metadata": {
  819. "type": "object",
  820. "additionalProperties": {}
  821. },
  822. "time": {
  823. "type": "object",
  824. "properties": {
  825. "created": {
  826. "type": "number"
  827. }
  828. },
  829. "required": [
  830. "created"
  831. ]
  832. }
  833. },
  834. "required": [
  835. "id",
  836. "sessionID",
  837. "title",
  838. "metadata",
  839. "time"
  840. ]
  841. },
  842. "Event.session.updated": {
  843. "type": "object",
  844. "properties": {
  845. "type": {
  846. "type": "string",
  847. "const": "session.updated"
  848. },
  849. "properties": {
  850. "type": "object",
  851. "properties": {
  852. "info": {
  853. "$ref": "#/components/schemas/session.info"
  854. }
  855. },
  856. "required": [
  857. "info"
  858. ]
  859. }
  860. },
  861. "required": [
  862. "type",
  863. "properties"
  864. ]
  865. },
  866. "session.info": {
  867. "type": "object",
  868. "properties": {
  869. "id": {
  870. "type": "string",
  871. "pattern": "^ses"
  872. },
  873. "share": {
  874. "type": "object",
  875. "properties": {
  876. "secret": {
  877. "type": "string"
  878. },
  879. "url": {
  880. "type": "string"
  881. }
  882. },
  883. "required": [
  884. "secret",
  885. "url"
  886. ]
  887. },
  888. "title": {
  889. "type": "string"
  890. },
  891. "time": {
  892. "type": "object",
  893. "properties": {
  894. "created": {
  895. "type": "number"
  896. },
  897. "updated": {
  898. "type": "number"
  899. }
  900. },
  901. "required": [
  902. "created",
  903. "updated"
  904. ]
  905. }
  906. },
  907. "required": [
  908. "id",
  909. "title",
  910. "time"
  911. ]
  912. },
  913. "Provider.Info": {
  914. "type": "object",
  915. "properties": {
  916. "id": {
  917. "type": "string"
  918. },
  919. "name": {
  920. "type": "string"
  921. },
  922. "options": {
  923. "type": "object",
  924. "additionalProperties": {}
  925. },
  926. "models": {
  927. "type": "array",
  928. "items": {
  929. "$ref": "#/components/schemas/Provider.Model"
  930. }
  931. }
  932. },
  933. "required": [
  934. "id",
  935. "name",
  936. "models"
  937. ]
  938. },
  939. "Provider.Model": {
  940. "type": "object",
  941. "properties": {
  942. "id": {
  943. "type": "string"
  944. },
  945. "name": {
  946. "type": "string"
  947. },
  948. "cost": {
  949. "type": "object",
  950. "properties": {
  951. "input": {
  952. "type": "number"
  953. },
  954. "inputCached": {
  955. "type": "number"
  956. },
  957. "output": {
  958. "type": "number"
  959. },
  960. "outputCached": {
  961. "type": "number"
  962. }
  963. },
  964. "required": [
  965. "input",
  966. "inputCached",
  967. "output",
  968. "outputCached"
  969. ]
  970. },
  971. "contextWindow": {
  972. "type": "number"
  973. },
  974. "maxOutputTokens": {
  975. "type": "number"
  976. },
  977. "attachment": {
  978. "type": "boolean"
  979. },
  980. "reasoning": {
  981. "type": "boolean"
  982. }
  983. },
  984. "required": [
  985. "id",
  986. "cost",
  987. "contextWindow",
  988. "attachment"
  989. ]
  990. }
  991. }
  992. }
  993. }