openapi.json 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  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. "sessionID": {
  361. "type": "string"
  362. },
  363. "messageID": {
  364. "type": "string"
  365. }
  366. },
  367. "required": [
  368. "sessionID",
  369. "messageID"
  370. ]
  371. }
  372. },
  373. "required": [
  374. "type",
  375. "properties"
  376. ]
  377. },
  378. "Event.session.updated": {
  379. "type": "object",
  380. "properties": {
  381. "type": {
  382. "type": "string",
  383. "const": "session.updated"
  384. },
  385. "properties": {
  386. "type": "object",
  387. "properties": {
  388. "sessionID": {
  389. "type": "string"
  390. }
  391. },
  392. "required": [
  393. "sessionID"
  394. ]
  395. }
  396. },
  397. "required": [
  398. "type",
  399. "properties"
  400. ]
  401. },
  402. "Session.Info": {
  403. "type": "object",
  404. "properties": {
  405. "id": {
  406. "type": "string",
  407. "pattern": "^ses"
  408. },
  409. "shareID": {
  410. "type": "string"
  411. },
  412. "title": {
  413. "type": "string"
  414. }
  415. },
  416. "required": [
  417. "id",
  418. "title"
  419. ]
  420. },
  421. "Message.Info": {
  422. "type": "object",
  423. "properties": {
  424. "id": {
  425. "type": "string"
  426. },
  427. "role": {
  428. "type": "string",
  429. "enum": [
  430. "system",
  431. "user",
  432. "assistant"
  433. ]
  434. },
  435. "parts": {
  436. "type": "array",
  437. "items": {
  438. "$ref": "#/components/schemas/Message.Part"
  439. }
  440. },
  441. "metadata": {
  442. "type": "object",
  443. "properties": {
  444. "time": {
  445. "type": "object",
  446. "properties": {
  447. "created": {
  448. "type": "number"
  449. },
  450. "completed": {
  451. "type": "number"
  452. }
  453. },
  454. "required": [
  455. "created"
  456. ]
  457. },
  458. "sessionID": {
  459. "type": "string"
  460. },
  461. "tool": {
  462. "type": "object",
  463. "additionalProperties": {}
  464. },
  465. "assistant": {
  466. "type": "object",
  467. "properties": {
  468. "modelID": {
  469. "type": "string"
  470. },
  471. "providerID": {
  472. "type": "string"
  473. },
  474. "cost": {
  475. "type": "number"
  476. },
  477. "tokens": {
  478. "type": "object",
  479. "properties": {
  480. "input": {
  481. "type": "number"
  482. },
  483. "output": {
  484. "type": "number"
  485. },
  486. "reasoning": {
  487. "type": "number"
  488. }
  489. },
  490. "required": [
  491. "input",
  492. "output",
  493. "reasoning"
  494. ]
  495. }
  496. },
  497. "required": [
  498. "modelID",
  499. "providerID",
  500. "cost",
  501. "tokens"
  502. ]
  503. }
  504. },
  505. "required": [
  506. "time",
  507. "sessionID",
  508. "tool"
  509. ]
  510. }
  511. },
  512. "required": [
  513. "id",
  514. "role",
  515. "parts",
  516. "metadata"
  517. ]
  518. },
  519. "Message.Part": {
  520. "oneOf": [
  521. {
  522. "$ref": "#/components/schemas/Message.Part.Text"
  523. },
  524. {
  525. "$ref": "#/components/schemas/Message.Part.Reasoning"
  526. },
  527. {
  528. "$ref": "#/components/schemas/Message.Part.ToolInvocation"
  529. },
  530. {
  531. "$ref": "#/components/schemas/Message.Part.SourceUrl"
  532. },
  533. {
  534. "$ref": "#/components/schemas/Message.Part.File"
  535. },
  536. {
  537. "$ref": "#/components/schemas/Message.Part.StepStart"
  538. }
  539. ],
  540. "discriminator": {
  541. "propertyName": "type",
  542. "mapping": {
  543. "text": "#/components/schemas/Message.Part.Text",
  544. "reasoning": "#/components/schemas/Message.Part.Reasoning",
  545. "tool-invocation": "#/components/schemas/Message.Part.ToolInvocation",
  546. "source-url": "#/components/schemas/Message.Part.SourceUrl",
  547. "file": "#/components/schemas/Message.Part.File",
  548. "step-start": "#/components/schemas/Message.Part.StepStart"
  549. }
  550. }
  551. },
  552. "Message.Part.Text": {
  553. "type": "object",
  554. "properties": {
  555. "type": {
  556. "type": "string",
  557. "const": "text"
  558. },
  559. "text": {
  560. "type": "string"
  561. }
  562. },
  563. "required": [
  564. "type",
  565. "text"
  566. ]
  567. },
  568. "Message.Part.Reasoning": {
  569. "type": "object",
  570. "properties": {
  571. "type": {
  572. "type": "string",
  573. "const": "reasoning"
  574. },
  575. "text": {
  576. "type": "string"
  577. },
  578. "providerMetadata": {
  579. "type": "object",
  580. "additionalProperties": {}
  581. }
  582. },
  583. "required": [
  584. "type",
  585. "text"
  586. ]
  587. },
  588. "Message.Part.ToolInvocation": {
  589. "type": "object",
  590. "properties": {
  591. "type": {
  592. "type": "string",
  593. "const": "tool-invocation"
  594. },
  595. "toolInvocation": {
  596. "$ref": "#/components/schemas/Message.ToolInvocation"
  597. }
  598. },
  599. "required": [
  600. "type",
  601. "toolInvocation"
  602. ]
  603. },
  604. "Message.ToolInvocation": {
  605. "oneOf": [
  606. {
  607. "$ref": "#/components/schemas/Message.ToolInvocation.ToolCall"
  608. },
  609. {
  610. "$ref": "#/components/schemas/Message.ToolInvocation.ToolPartialCall"
  611. },
  612. {
  613. "$ref": "#/components/schemas/Message.ToolInvocation.ToolResult"
  614. }
  615. ],
  616. "discriminator": {
  617. "propertyName": "state",
  618. "mapping": {
  619. "call": "#/components/schemas/Message.ToolInvocation.ToolCall",
  620. "partial-call": "#/components/schemas/Message.ToolInvocation.ToolPartialCall",
  621. "result": "#/components/schemas/Message.ToolInvocation.ToolResult"
  622. }
  623. }
  624. },
  625. "Message.ToolInvocation.ToolCall": {
  626. "type": "object",
  627. "properties": {
  628. "state": {
  629. "type": "string",
  630. "const": "call"
  631. },
  632. "step": {
  633. "type": "number"
  634. },
  635. "toolCallId": {
  636. "type": "string"
  637. },
  638. "toolName": {
  639. "type": "string"
  640. },
  641. "args": {}
  642. },
  643. "required": [
  644. "state",
  645. "toolCallId",
  646. "toolName"
  647. ]
  648. },
  649. "Message.ToolInvocation.ToolPartialCall": {
  650. "type": "object",
  651. "properties": {
  652. "state": {
  653. "type": "string",
  654. "const": "partial-call"
  655. },
  656. "step": {
  657. "type": "number"
  658. },
  659. "toolCallId": {
  660. "type": "string"
  661. },
  662. "toolName": {
  663. "type": "string"
  664. },
  665. "args": {}
  666. },
  667. "required": [
  668. "state",
  669. "toolCallId",
  670. "toolName"
  671. ]
  672. },
  673. "Message.ToolInvocation.ToolResult": {
  674. "type": "object",
  675. "properties": {
  676. "state": {
  677. "type": "string",
  678. "const": "result"
  679. },
  680. "step": {
  681. "type": "number"
  682. },
  683. "toolCallId": {
  684. "type": "string"
  685. },
  686. "toolName": {
  687. "type": "string"
  688. },
  689. "args": {},
  690. "result": {
  691. "type": "string"
  692. }
  693. },
  694. "required": [
  695. "state",
  696. "toolCallId",
  697. "toolName",
  698. "result"
  699. ]
  700. },
  701. "Message.Part.SourceUrl": {
  702. "type": "object",
  703. "properties": {
  704. "type": {
  705. "type": "string",
  706. "const": "source-url"
  707. },
  708. "sourceId": {
  709. "type": "string"
  710. },
  711. "url": {
  712. "type": "string"
  713. },
  714. "title": {
  715. "type": "string"
  716. },
  717. "providerMetadata": {
  718. "type": "object",
  719. "additionalProperties": {}
  720. }
  721. },
  722. "required": [
  723. "type",
  724. "sourceId",
  725. "url"
  726. ]
  727. },
  728. "Message.Part.File": {
  729. "type": "object",
  730. "properties": {
  731. "type": {
  732. "type": "string",
  733. "const": "file"
  734. },
  735. "mediaType": {
  736. "type": "string"
  737. },
  738. "filename": {
  739. "type": "string"
  740. },
  741. "url": {
  742. "type": "string"
  743. }
  744. },
  745. "required": [
  746. "type",
  747. "mediaType",
  748. "url"
  749. ]
  750. },
  751. "Message.Part.StepStart": {
  752. "type": "object",
  753. "properties": {
  754. "type": {
  755. "type": "string",
  756. "const": "step-start"
  757. }
  758. },
  759. "required": [
  760. "type"
  761. ]
  762. },
  763. "Provider.Info": {
  764. "type": "object",
  765. "properties": {
  766. "options": {
  767. "type": "object",
  768. "additionalProperties": {}
  769. },
  770. "models": {
  771. "type": "object",
  772. "additionalProperties": {
  773. "type": "object",
  774. "properties": {
  775. "name": {
  776. "type": "string"
  777. },
  778. "cost": {
  779. "type": "object",
  780. "properties": {
  781. "input": {
  782. "type": "number"
  783. },
  784. "inputCached": {
  785. "type": "number"
  786. },
  787. "output": {
  788. "type": "number"
  789. },
  790. "outputCached": {
  791. "type": "number"
  792. }
  793. },
  794. "required": [
  795. "input",
  796. "inputCached",
  797. "output",
  798. "outputCached"
  799. ]
  800. },
  801. "contextWindow": {
  802. "type": "number"
  803. },
  804. "maxTokens": {
  805. "type": "number"
  806. },
  807. "attachment": {
  808. "type": "boolean"
  809. },
  810. "reasoning": {
  811. "type": "boolean"
  812. }
  813. },
  814. "required": [
  815. "cost",
  816. "contextWindow",
  817. "attachment"
  818. ]
  819. }
  820. }
  821. },
  822. "required": [
  823. "models"
  824. ]
  825. }
  826. }
  827. }
  828. }