openapi.json 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. {
  2. "openapi": "3.1.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/Session.Message"
  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/Session.Message"
  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/Session.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. "Session.Message": {
  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/Session.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. },
  317. "required": [
  318. "time",
  319. "sessionID",
  320. "tool"
  321. ]
  322. }
  323. },
  324. "required": [
  325. "id",
  326. "role",
  327. "parts",
  328. "metadata"
  329. ]
  330. },
  331. "Session.Message.Part": {
  332. "oneOf": [
  333. {
  334. "$ref": "#/components/schemas/Session.Message.Part.Text"
  335. },
  336. {
  337. "$ref": "#/components/schemas/Session.Message.Part.Reasoning"
  338. },
  339. {
  340. "$ref": "#/components/schemas/Session.Message.Part.ToolInvocation"
  341. },
  342. {
  343. "$ref": "#/components/schemas/Session.Message.Part.SourceUrl"
  344. },
  345. {
  346. "$ref": "#/components/schemas/Session.Message.Part.File"
  347. },
  348. {
  349. "$ref": "#/components/schemas/Session.Message.Part.StepStart"
  350. }
  351. ],
  352. "discriminator": {
  353. "propertyName": "type",
  354. "mapping": {
  355. "text": "#/components/schemas/Session.Message.Part.Text",
  356. "reasoning": "#/components/schemas/Session.Message.Part.Reasoning",
  357. "tool-invocation": "#/components/schemas/Session.Message.Part.ToolInvocation",
  358. "source-url": "#/components/schemas/Session.Message.Part.SourceUrl",
  359. "file": "#/components/schemas/Session.Message.Part.File",
  360. "step-start": "#/components/schemas/Session.Message.Part.StepStart"
  361. }
  362. }
  363. },
  364. "Session.Message.Part.Text": {
  365. "type": "object",
  366. "properties": {
  367. "type": {
  368. "type": "string",
  369. "const": "text"
  370. },
  371. "text": {
  372. "type": "string"
  373. }
  374. },
  375. "required": [
  376. "type",
  377. "text"
  378. ]
  379. },
  380. "Session.Message.Part.Reasoning": {
  381. "type": "object",
  382. "properties": {
  383. "type": {
  384. "type": "string",
  385. "const": "reasoning"
  386. },
  387. "text": {
  388. "type": "string"
  389. },
  390. "providerMetadata": {
  391. "type": "object",
  392. "additionalProperties": {}
  393. }
  394. },
  395. "required": [
  396. "type",
  397. "text"
  398. ]
  399. },
  400. "Session.Message.Part.ToolInvocation": {
  401. "type": "object",
  402. "properties": {
  403. "type": {
  404. "type": "string",
  405. "const": "tool-invocation"
  406. },
  407. "toolInvocation": {
  408. "$ref": "#/components/schemas/Session.Message.ToolInvocation"
  409. }
  410. },
  411. "required": [
  412. "type",
  413. "toolInvocation"
  414. ]
  415. },
  416. "Session.Message.ToolInvocation": {
  417. "oneOf": [
  418. {
  419. "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolCall"
  420. },
  421. {
  422. "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolPartialCall"
  423. },
  424. {
  425. "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolResult"
  426. }
  427. ],
  428. "discriminator": {
  429. "propertyName": "state",
  430. "mapping": {
  431. "call": "#/components/schemas/Session.Message.ToolInvocation.ToolCall",
  432. "partial-call": "#/components/schemas/Session.Message.ToolInvocation.ToolPartialCall",
  433. "result": "#/components/schemas/Session.Message.ToolInvocation.ToolResult"
  434. }
  435. }
  436. },
  437. "Session.Message.ToolInvocation.ToolCall": {
  438. "type": "object",
  439. "properties": {
  440. "state": {
  441. "type": "string",
  442. "const": "call"
  443. },
  444. "step": {
  445. "type": "number"
  446. },
  447. "toolCallId": {
  448. "type": "string"
  449. },
  450. "toolName": {
  451. "type": "string"
  452. },
  453. "args": {
  454. "type": "object",
  455. "additionalProperties": {}
  456. }
  457. },
  458. "required": [
  459. "state",
  460. "toolCallId",
  461. "toolName",
  462. "args"
  463. ]
  464. },
  465. "Session.Message.ToolInvocation.ToolPartialCall": {
  466. "type": "object",
  467. "properties": {
  468. "state": {
  469. "type": "string",
  470. "const": "partial-call"
  471. },
  472. "step": {
  473. "type": "number"
  474. },
  475. "toolCallId": {
  476. "type": "string"
  477. },
  478. "toolName": {
  479. "type": "string"
  480. },
  481. "args": {
  482. "type": "object",
  483. "additionalProperties": {}
  484. }
  485. },
  486. "required": [
  487. "state",
  488. "toolCallId",
  489. "toolName",
  490. "args"
  491. ]
  492. },
  493. "Session.Message.ToolInvocation.ToolResult": {
  494. "type": "object",
  495. "properties": {
  496. "state": {
  497. "type": "string",
  498. "const": "result"
  499. },
  500. "step": {
  501. "type": "number"
  502. },
  503. "toolCallId": {
  504. "type": "string"
  505. },
  506. "toolName": {
  507. "type": "string"
  508. },
  509. "args": {
  510. "type": "object",
  511. "additionalProperties": {}
  512. },
  513. "result": {
  514. "type": "string"
  515. }
  516. },
  517. "required": [
  518. "state",
  519. "toolCallId",
  520. "toolName",
  521. "args",
  522. "result"
  523. ]
  524. },
  525. "Session.Message.Part.SourceUrl": {
  526. "type": "object",
  527. "properties": {
  528. "type": {
  529. "type": "string",
  530. "const": "source-url"
  531. },
  532. "sourceId": {
  533. "type": "string"
  534. },
  535. "url": {
  536. "type": "string"
  537. },
  538. "title": {
  539. "type": "string"
  540. },
  541. "providerMetadata": {
  542. "type": "object",
  543. "additionalProperties": {}
  544. }
  545. },
  546. "required": [
  547. "type",
  548. "sourceId",
  549. "url"
  550. ]
  551. },
  552. "Session.Message.Part.File": {
  553. "type": "object",
  554. "properties": {
  555. "type": {
  556. "type": "string",
  557. "const": "file"
  558. },
  559. "mediaType": {
  560. "type": "string"
  561. },
  562. "filename": {
  563. "type": "string"
  564. },
  565. "url": {
  566. "type": "string"
  567. }
  568. },
  569. "required": [
  570. "type",
  571. "mediaType",
  572. "url"
  573. ]
  574. },
  575. "Session.Message.Part.StepStart": {
  576. "type": "object",
  577. "properties": {
  578. "type": {
  579. "type": "string",
  580. "const": "step-start"
  581. }
  582. },
  583. "required": [
  584. "type"
  585. ]
  586. },
  587. "Provider.Info": {
  588. "type": "object",
  589. "properties": {
  590. "options": {
  591. "type": "object",
  592. "additionalProperties": {}
  593. },
  594. "models": {
  595. "type": "object",
  596. "additionalProperties": {
  597. "type": "object",
  598. "properties": {
  599. "name": {
  600. "type": "string"
  601. },
  602. "cost": {
  603. "type": "object",
  604. "properties": {
  605. "input": {
  606. "type": "number"
  607. },
  608. "inputCached": {
  609. "type": "number"
  610. },
  611. "output": {
  612. "type": "number"
  613. },
  614. "outputCached": {
  615. "type": "number"
  616. }
  617. },
  618. "required": [
  619. "input",
  620. "inputCached",
  621. "output",
  622. "outputCached"
  623. ]
  624. },
  625. "contextWindow": {
  626. "type": "number"
  627. },
  628. "maxTokens": {
  629. "type": "number"
  630. },
  631. "attachment": {
  632. "type": "boolean"
  633. },
  634. "reasoning": {
  635. "type": "boolean"
  636. }
  637. },
  638. "required": [
  639. "cost",
  640. "contextWindow",
  641. "attachment"
  642. ]
  643. }
  644. }
  645. },
  646. "required": [
  647. "models"
  648. ]
  649. }
  650. }
  651. }
  652. }