openapi.json 20 KB

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