openapi.json 21 KB

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