openapi.json 21 KB

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