openapi.json 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. {
  2. "openapi": "3.0.0",
  3. "info": {
  4. "title": "opencode",
  5. "description": "opencode api",
  6. "version": "1.0.0"
  7. },
  8. "paths": {
  9. "/session_create": {
  10. "post": {
  11. "responses": {
  12. "200": {
  13. "description": "Successfully created session",
  14. "content": {
  15. "application/json": {
  16. "schema": {
  17. "$ref": "#/components/schemas/Session.Info"
  18. }
  19. }
  20. }
  21. }
  22. },
  23. "operationId": "postSession_create",
  24. "parameters": [],
  25. "description": "Create a new session"
  26. }
  27. },
  28. "/session_share": {
  29. "post": {
  30. "responses": {
  31. "200": {
  32. "description": "Successfully shared session",
  33. "content": {
  34. "application/json": {
  35. "schema": {
  36. "$ref": "#/components/schemas/Session.Info"
  37. }
  38. }
  39. }
  40. }
  41. },
  42. "operationId": "postSession_share",
  43. "parameters": [],
  44. "description": "Share the session",
  45. "requestBody": {
  46. "content": {
  47. "application/json": {
  48. "schema": {
  49. "type": "object",
  50. "properties": {
  51. "sessionID": {
  52. "type": "string"
  53. }
  54. },
  55. "required": [
  56. "sessionID"
  57. ]
  58. }
  59. }
  60. }
  61. }
  62. }
  63. },
  64. "/session_messages": {
  65. "post": {
  66. "responses": {
  67. "200": {
  68. "description": "Successfully created session",
  69. "content": {
  70. "application/json": {
  71. "schema": {
  72. "type": "array",
  73. "items": {
  74. "$ref": "#/components/schemas/Message.Info"
  75. }
  76. }
  77. }
  78. }
  79. }
  80. },
  81. "operationId": "postSession_messages",
  82. "parameters": [],
  83. "description": "Get messages for a session",
  84. "requestBody": {
  85. "content": {
  86. "application/json": {
  87. "schema": {
  88. "type": "object",
  89. "properties": {
  90. "sessionID": {
  91. "type": "string"
  92. }
  93. },
  94. "required": [
  95. "sessionID"
  96. ]
  97. }
  98. }
  99. }
  100. }
  101. }
  102. },
  103. "/session_list": {
  104. "post": {
  105. "responses": {
  106. "200": {
  107. "description": "List of sessions",
  108. "content": {
  109. "application/json": {
  110. "schema": {
  111. "type": "array",
  112. "items": {
  113. "type": "object",
  114. "properties": {
  115. "id": {
  116. "type": "string",
  117. "pattern": "^ses"
  118. },
  119. "shareID": {
  120. "type": "string"
  121. },
  122. "title": {
  123. "type": "string"
  124. }
  125. },
  126. "required": [
  127. "id",
  128. "title"
  129. ]
  130. }
  131. }
  132. }
  133. }
  134. }
  135. },
  136. "operationId": "postSession_list",
  137. "parameters": [],
  138. "description": "List all sessions"
  139. }
  140. },
  141. "/session_abort": {
  142. "post": {
  143. "responses": {
  144. "200": {
  145. "description": "Aborted session",
  146. "content": {
  147. "application/json": {
  148. "schema": {
  149. "type": "boolean"
  150. }
  151. }
  152. }
  153. }
  154. },
  155. "operationId": "postSession_abort",
  156. "parameters": [],
  157. "description": "Abort a session",
  158. "requestBody": {
  159. "content": {
  160. "application/json": {
  161. "schema": {
  162. "type": "object",
  163. "properties": {
  164. "sessionID": {
  165. "type": "string"
  166. }
  167. },
  168. "required": [
  169. "sessionID"
  170. ]
  171. }
  172. }
  173. }
  174. }
  175. }
  176. },
  177. "/session_chat": {
  178. "post": {
  179. "responses": {
  180. "200": {
  181. "description": "Chat with a model",
  182. "content": {
  183. "application/json": {
  184. "schema": {
  185. "$ref": "#/components/schemas/Message.Info"
  186. }
  187. }
  188. }
  189. }
  190. },
  191. "operationId": "postSession_chat",
  192. "parameters": [],
  193. "description": "Chat with a model",
  194. "requestBody": {
  195. "content": {
  196. "application/json": {
  197. "schema": {
  198. "type": "object",
  199. "properties": {
  200. "sessionID": {
  201. "type": "string"
  202. },
  203. "providerID": {
  204. "type": "string"
  205. },
  206. "modelID": {
  207. "type": "string"
  208. },
  209. "parts": {
  210. "type": "array",
  211. "items": {
  212. "$ref": "#/components/schemas/Message.Part"
  213. }
  214. }
  215. },
  216. "required": [
  217. "sessionID",
  218. "providerID",
  219. "modelID",
  220. "parts"
  221. ]
  222. }
  223. }
  224. }
  225. }
  226. }
  227. },
  228. "/provider_list": {
  229. "post": {
  230. "responses": {
  231. "200": {
  232. "description": "List of providers",
  233. "content": {
  234. "application/json": {
  235. "schema": {
  236. "type": "object",
  237. "additionalProperties": {
  238. "$ref": "#/components/schemas/Provider.Info"
  239. }
  240. }
  241. }
  242. }
  243. }
  244. },
  245. "operationId": "postProvider_list",
  246. "parameters": [],
  247. "description": "List all providers"
  248. }
  249. }
  250. },
  251. "components": {
  252. "schemas": {
  253. "Session.Info": {
  254. "type": "object",
  255. "properties": {
  256. "id": {
  257. "type": "string",
  258. "pattern": "^ses"
  259. },
  260. "shareID": {
  261. "type": "string"
  262. },
  263. "title": {
  264. "type": "string"
  265. }
  266. },
  267. "required": [
  268. "id",
  269. "title"
  270. ]
  271. },
  272. "Message.Info": {
  273. "type": "object",
  274. "properties": {
  275. "id": {
  276. "type": "string"
  277. },
  278. "role": {
  279. "type": "string",
  280. "enum": [
  281. "system",
  282. "user",
  283. "assistant"
  284. ]
  285. },
  286. "parts": {
  287. "type": "array",
  288. "items": {
  289. "$ref": "#/components/schemas/Message.Part"
  290. }
  291. },
  292. "metadata": {
  293. "type": "object",
  294. "properties": {
  295. "time": {
  296. "type": "object",
  297. "properties": {
  298. "created": {
  299. "type": "number"
  300. },
  301. "completed": {
  302. "type": "number"
  303. }
  304. },
  305. "required": [
  306. "created"
  307. ]
  308. },
  309. "sessionID": {
  310. "type": "string"
  311. },
  312. "tool": {
  313. "type": "object",
  314. "additionalProperties": {}
  315. },
  316. "assistant": {
  317. "type": "object",
  318. "properties": {
  319. "modelID": {
  320. "type": "string"
  321. },
  322. "providerID": {
  323. "type": "string"
  324. },
  325. "cost": {
  326. "type": "number"
  327. },
  328. "tokens": {
  329. "type": "object",
  330. "properties": {
  331. "input": {
  332. "type": "number"
  333. },
  334. "output": {
  335. "type": "number"
  336. },
  337. "reasoning": {
  338. "type": "number"
  339. }
  340. },
  341. "required": [
  342. "input",
  343. "output",
  344. "reasoning"
  345. ]
  346. }
  347. },
  348. "required": [
  349. "modelID",
  350. "providerID",
  351. "cost",
  352. "tokens"
  353. ]
  354. }
  355. },
  356. "required": [
  357. "time",
  358. "sessionID",
  359. "tool"
  360. ]
  361. }
  362. },
  363. "required": [
  364. "id",
  365. "role",
  366. "parts",
  367. "metadata"
  368. ]
  369. },
  370. "Message.Part": {
  371. "oneOf": [
  372. {
  373. "$ref": "#/components/schemas/Message.Part.Text"
  374. },
  375. {
  376. "$ref": "#/components/schemas/Message.Part.Reasoning"
  377. },
  378. {
  379. "$ref": "#/components/schemas/Message.Part.ToolInvocation"
  380. },
  381. {
  382. "$ref": "#/components/schemas/Message.Part.SourceUrl"
  383. },
  384. {
  385. "$ref": "#/components/schemas/Message.Part.File"
  386. },
  387. {
  388. "$ref": "#/components/schemas/Message.Part.StepStart"
  389. }
  390. ],
  391. "discriminator": {
  392. "propertyName": "type",
  393. "mapping": {
  394. "text": "#/components/schemas/Message.Part.Text",
  395. "reasoning": "#/components/schemas/Message.Part.Reasoning",
  396. "tool-invocation": "#/components/schemas/Message.Part.ToolInvocation",
  397. "source-url": "#/components/schemas/Message.Part.SourceUrl",
  398. "file": "#/components/schemas/Message.Part.File",
  399. "step-start": "#/components/schemas/Message.Part.StepStart"
  400. }
  401. }
  402. },
  403. "Message.Part.Text": {
  404. "type": "object",
  405. "properties": {
  406. "type": {
  407. "type": "string",
  408. "const": "text"
  409. },
  410. "text": {
  411. "type": "string"
  412. }
  413. },
  414. "required": [
  415. "type",
  416. "text"
  417. ]
  418. },
  419. "Message.Part.Reasoning": {
  420. "type": "object",
  421. "properties": {
  422. "type": {
  423. "type": "string",
  424. "const": "reasoning"
  425. },
  426. "text": {
  427. "type": "string"
  428. },
  429. "providerMetadata": {
  430. "type": "object",
  431. "additionalProperties": {}
  432. }
  433. },
  434. "required": [
  435. "type",
  436. "text"
  437. ]
  438. },
  439. "Message.Part.ToolInvocation": {
  440. "type": "object",
  441. "properties": {
  442. "type": {
  443. "type": "string",
  444. "const": "tool-invocation"
  445. },
  446. "toolInvocation": {
  447. "$ref": "#/components/schemas/Message.ToolInvocation"
  448. }
  449. },
  450. "required": [
  451. "type",
  452. "toolInvocation"
  453. ]
  454. },
  455. "Message.ToolInvocation": {
  456. "oneOf": [
  457. {
  458. "$ref": "#/components/schemas/Message.ToolInvocation.ToolCall"
  459. },
  460. {
  461. "$ref": "#/components/schemas/Message.ToolInvocation.ToolPartialCall"
  462. },
  463. {
  464. "$ref": "#/components/schemas/Message.ToolInvocation.ToolResult"
  465. }
  466. ],
  467. "discriminator": {
  468. "propertyName": "state",
  469. "mapping": {
  470. "call": "#/components/schemas/Message.ToolInvocation.ToolCall",
  471. "partial-call": "#/components/schemas/Message.ToolInvocation.ToolPartialCall",
  472. "result": "#/components/schemas/Message.ToolInvocation.ToolResult"
  473. }
  474. }
  475. },
  476. "Message.ToolInvocation.ToolCall": {
  477. "type": "object",
  478. "properties": {
  479. "state": {
  480. "type": "string",
  481. "const": "call"
  482. },
  483. "step": {
  484. "type": "number"
  485. },
  486. "toolCallId": {
  487. "type": "string"
  488. },
  489. "toolName": {
  490. "type": "string"
  491. },
  492. "args": {}
  493. },
  494. "required": [
  495. "state",
  496. "toolCallId",
  497. "toolName"
  498. ]
  499. },
  500. "Message.ToolInvocation.ToolPartialCall": {
  501. "type": "object",
  502. "properties": {
  503. "state": {
  504. "type": "string",
  505. "const": "partial-call"
  506. },
  507. "step": {
  508. "type": "number"
  509. },
  510. "toolCallId": {
  511. "type": "string"
  512. },
  513. "toolName": {
  514. "type": "string"
  515. },
  516. "args": {}
  517. },
  518. "required": [
  519. "state",
  520. "toolCallId",
  521. "toolName"
  522. ]
  523. },
  524. "Message.ToolInvocation.ToolResult": {
  525. "type": "object",
  526. "properties": {
  527. "state": {
  528. "type": "string",
  529. "const": "result"
  530. },
  531. "step": {
  532. "type": "number"
  533. },
  534. "toolCallId": {
  535. "type": "string"
  536. },
  537. "toolName": {
  538. "type": "string"
  539. },
  540. "args": {},
  541. "result": {
  542. "type": "string"
  543. }
  544. },
  545. "required": [
  546. "state",
  547. "toolCallId",
  548. "toolName",
  549. "result"
  550. ]
  551. },
  552. "Message.Part.SourceUrl": {
  553. "type": "object",
  554. "properties": {
  555. "type": {
  556. "type": "string",
  557. "const": "source-url"
  558. },
  559. "sourceId": {
  560. "type": "string"
  561. },
  562. "url": {
  563. "type": "string"
  564. },
  565. "title": {
  566. "type": "string"
  567. },
  568. "providerMetadata": {
  569. "type": "object",
  570. "additionalProperties": {}
  571. }
  572. },
  573. "required": [
  574. "type",
  575. "sourceId",
  576. "url"
  577. ]
  578. },
  579. "Message.Part.File": {
  580. "type": "object",
  581. "properties": {
  582. "type": {
  583. "type": "string",
  584. "const": "file"
  585. },
  586. "mediaType": {
  587. "type": "string"
  588. },
  589. "filename": {
  590. "type": "string"
  591. },
  592. "url": {
  593. "type": "string"
  594. }
  595. },
  596. "required": [
  597. "type",
  598. "mediaType",
  599. "url"
  600. ]
  601. },
  602. "Message.Part.StepStart": {
  603. "type": "object",
  604. "properties": {
  605. "type": {
  606. "type": "string",
  607. "const": "step-start"
  608. }
  609. },
  610. "required": [
  611. "type"
  612. ]
  613. },
  614. "Provider.Info": {
  615. "type": "object",
  616. "properties": {
  617. "options": {
  618. "type": "object",
  619. "additionalProperties": {}
  620. },
  621. "models": {
  622. "type": "object",
  623. "additionalProperties": {
  624. "type": "object",
  625. "properties": {
  626. "name": {
  627. "type": "string"
  628. },
  629. "cost": {
  630. "type": "object",
  631. "properties": {
  632. "input": {
  633. "type": "number"
  634. },
  635. "inputCached": {
  636. "type": "number"
  637. },
  638. "output": {
  639. "type": "number"
  640. },
  641. "outputCached": {
  642. "type": "number"
  643. }
  644. },
  645. "required": [
  646. "input",
  647. "inputCached",
  648. "output",
  649. "outputCached"
  650. ]
  651. },
  652. "contextWindow": {
  653. "type": "number"
  654. },
  655. "maxTokens": {
  656. "type": "number"
  657. },
  658. "attachment": {
  659. "type": "boolean"
  660. },
  661. "reasoning": {
  662. "type": "boolean"
  663. }
  664. },
  665. "required": [
  666. "cost",
  667. "contextWindow",
  668. "attachment"
  669. ]
  670. }
  671. }
  672. },
  673. "required": [
  674. "models"
  675. ]
  676. }
  677. }
  678. }
  679. }