openapi.json 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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. "tokens": {
  126. "type": "object",
  127. "properties": {
  128. "input": {
  129. "type": "number"
  130. },
  131. "output": {
  132. "type": "number"
  133. },
  134. "reasoning": {
  135. "type": "number"
  136. }
  137. },
  138. "required": [
  139. "input",
  140. "output",
  141. "reasoning"
  142. ]
  143. }
  144. },
  145. "required": [
  146. "id",
  147. "title",
  148. "tokens"
  149. ]
  150. }
  151. }
  152. }
  153. }
  154. }
  155. },
  156. "operationId": "postSession_list",
  157. "parameters": [],
  158. "description": "List all sessions"
  159. }
  160. },
  161. "/session_chat": {
  162. "post": {
  163. "responses": {},
  164. "operationId": "postSession_chat",
  165. "parameters": [],
  166. "requestBody": {
  167. "content": {
  168. "application/json": {
  169. "schema": {
  170. "type": "object",
  171. "properties": {
  172. "sessionID": {
  173. "type": "string"
  174. },
  175. "providerID": {
  176. "type": "string"
  177. },
  178. "modelID": {
  179. "type": "string"
  180. },
  181. "parts": {
  182. "type": "array",
  183. "items": {
  184. "$ref": "#/components/schemas/Session.Message.Part"
  185. }
  186. }
  187. },
  188. "required": [
  189. "sessionID",
  190. "providerID",
  191. "modelID",
  192. "parts"
  193. ]
  194. }
  195. }
  196. }
  197. }
  198. }
  199. },
  200. "/provider_list": {
  201. "post": {
  202. "responses": {
  203. "200": {
  204. "description": "List of providers",
  205. "content": {
  206. "application/json": {
  207. "schema": {
  208. "type": "object",
  209. "additionalProperties": {
  210. "$ref": "#/components/schemas/Provider.Info"
  211. }
  212. }
  213. }
  214. }
  215. }
  216. },
  217. "operationId": "postProvider_list",
  218. "parameters": [],
  219. "description": "List all providers"
  220. }
  221. }
  222. },
  223. "components": {
  224. "schemas": {
  225. "Session.Info": {
  226. "type": "object",
  227. "properties": {
  228. "id": {
  229. "type": "string",
  230. "pattern": "^ses"
  231. },
  232. "shareID": {
  233. "type": "string"
  234. },
  235. "title": {
  236. "type": "string"
  237. },
  238. "tokens": {
  239. "type": "object",
  240. "properties": {
  241. "input": {
  242. "type": "number"
  243. },
  244. "output": {
  245. "type": "number"
  246. },
  247. "reasoning": {
  248. "type": "number"
  249. }
  250. },
  251. "required": [
  252. "input",
  253. "output",
  254. "reasoning"
  255. ]
  256. }
  257. },
  258. "required": [
  259. "id",
  260. "title",
  261. "tokens"
  262. ]
  263. },
  264. "Session.Message": {
  265. "type": "object",
  266. "properties": {
  267. "id": {
  268. "type": "string"
  269. },
  270. "role": {
  271. "type": "string",
  272. "enum": [
  273. "system",
  274. "user",
  275. "assistant"
  276. ]
  277. },
  278. "parts": {
  279. "type": "array",
  280. "items": {
  281. "$ref": "#/components/schemas/Session.Message.Part"
  282. }
  283. },
  284. "metadata": {
  285. "type": "object",
  286. "properties": {
  287. "time": {
  288. "type": "object",
  289. "properties": {
  290. "created": {
  291. "type": "number"
  292. },
  293. "completed": {
  294. "type": "number"
  295. }
  296. },
  297. "required": [
  298. "created"
  299. ]
  300. },
  301. "sessionID": {
  302. "type": "string"
  303. },
  304. "tool": {
  305. "type": "object",
  306. "additionalProperties": {}
  307. }
  308. },
  309. "required": [
  310. "time",
  311. "sessionID",
  312. "tool"
  313. ]
  314. }
  315. },
  316. "required": [
  317. "id",
  318. "role",
  319. "parts",
  320. "metadata"
  321. ]
  322. },
  323. "Session.Message.Part": {
  324. "anyOf": [
  325. {
  326. "$ref": "#/components/schemas/Session.Message.Part.Text"
  327. },
  328. {
  329. "$ref": "#/components/schemas/Session.Message.Part.Reasoning"
  330. },
  331. {
  332. "$ref": "#/components/schemas/Session.Message.Part.ToolInvocation"
  333. },
  334. {
  335. "$ref": "#/components/schemas/Session.Message.Part.SourceUrl"
  336. },
  337. {
  338. "$ref": "#/components/schemas/Session.Message.Part.File"
  339. },
  340. {
  341. "$ref": "#/components/schemas/Session.Message.Part.StepStart"
  342. },
  343. {
  344. "$ref": "#/components/schemas/Session.Message.Part.Data"
  345. }
  346. ]
  347. },
  348. "Session.Message.Part.Text": {
  349. "type": "object",
  350. "properties": {
  351. "type": {
  352. "type": "string",
  353. "const": "text"
  354. },
  355. "text": {
  356. "type": "string"
  357. }
  358. },
  359. "required": [
  360. "type",
  361. "text"
  362. ]
  363. },
  364. "Session.Message.Part.Reasoning": {
  365. "type": "object",
  366. "properties": {
  367. "type": {
  368. "type": "string",
  369. "const": "reasoning"
  370. },
  371. "text": {
  372. "type": "string"
  373. },
  374. "providerMetadata": {
  375. "type": "object",
  376. "additionalProperties": {}
  377. }
  378. },
  379. "required": [
  380. "type",
  381. "text"
  382. ]
  383. },
  384. "Session.Message.Part.ToolInvocation": {
  385. "type": "object",
  386. "properties": {
  387. "type": {
  388. "type": "string",
  389. "const": "tool-invocation"
  390. },
  391. "toolInvocation": {
  392. "$ref": "#/components/schemas/Session.Message.ToolInvocation"
  393. }
  394. },
  395. "required": [
  396. "type",
  397. "toolInvocation"
  398. ]
  399. },
  400. "Session.Message.ToolInvocation": {
  401. "anyOf": [
  402. {
  403. "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolCall"
  404. },
  405. {
  406. "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolPartialCall"
  407. },
  408. {
  409. "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolResult"
  410. }
  411. ]
  412. },
  413. "Session.Message.ToolInvocation.ToolCall": {
  414. "type": "object",
  415. "properties": {
  416. "state": {
  417. "type": "string",
  418. "const": "call"
  419. },
  420. "step": {
  421. "type": "number"
  422. },
  423. "toolCallId": {
  424. "type": "string"
  425. },
  426. "toolName": {
  427. "type": "string"
  428. },
  429. "args": {
  430. "type": "object",
  431. "additionalProperties": {}
  432. }
  433. },
  434. "required": [
  435. "state",
  436. "toolCallId",
  437. "toolName",
  438. "args"
  439. ]
  440. },
  441. "Session.Message.ToolInvocation.ToolPartialCall": {
  442. "type": "object",
  443. "properties": {
  444. "state": {
  445. "type": "string",
  446. "const": "partial-call"
  447. },
  448. "step": {
  449. "type": "number"
  450. },
  451. "toolCallId": {
  452. "type": "string"
  453. },
  454. "toolName": {
  455. "type": "string"
  456. },
  457. "args": {
  458. "type": "object",
  459. "additionalProperties": {}
  460. }
  461. },
  462. "required": [
  463. "state",
  464. "toolCallId",
  465. "toolName",
  466. "args"
  467. ]
  468. },
  469. "Session.Message.ToolInvocation.ToolResult": {
  470. "type": "object",
  471. "properties": {
  472. "state": {
  473. "type": "string",
  474. "const": "result"
  475. },
  476. "step": {
  477. "type": "number"
  478. },
  479. "toolCallId": {
  480. "type": "string"
  481. },
  482. "toolName": {
  483. "type": "string"
  484. },
  485. "args": {
  486. "type": "object",
  487. "additionalProperties": {}
  488. },
  489. "result": {
  490. "type": "string"
  491. }
  492. },
  493. "required": [
  494. "state",
  495. "toolCallId",
  496. "toolName",
  497. "args",
  498. "result"
  499. ]
  500. },
  501. "Session.Message.Part.SourceUrl": {
  502. "type": "object",
  503. "properties": {
  504. "type": {
  505. "type": "string",
  506. "const": "source-url"
  507. },
  508. "sourceId": {
  509. "type": "string"
  510. },
  511. "url": {
  512. "type": "string"
  513. },
  514. "title": {
  515. "type": "string"
  516. },
  517. "providerMetadata": {
  518. "type": "object",
  519. "additionalProperties": {}
  520. }
  521. },
  522. "required": [
  523. "type",
  524. "sourceId",
  525. "url"
  526. ]
  527. },
  528. "Session.Message.Part.File": {
  529. "type": "object",
  530. "properties": {
  531. "type": {
  532. "type": "string",
  533. "const": "file"
  534. },
  535. "mediaType": {
  536. "type": "string"
  537. },
  538. "filename": {
  539. "type": "string"
  540. },
  541. "url": {
  542. "type": "string"
  543. }
  544. },
  545. "required": [
  546. "type",
  547. "mediaType",
  548. "url"
  549. ]
  550. },
  551. "Session.Message.Part.StepStart": {
  552. "type": "object",
  553. "properties": {
  554. "type": {
  555. "type": "string",
  556. "const": "step-start"
  557. }
  558. },
  559. "required": [
  560. "type"
  561. ]
  562. },
  563. "Session.Message.Part.Data": {
  564. "type": "object",
  565. "properties": {
  566. "type": {},
  567. "id": {
  568. "type": "string"
  569. },
  570. "data": {}
  571. }
  572. },
  573. "Provider.Info": {
  574. "type": "object",
  575. "properties": {
  576. "options": {
  577. "type": "object",
  578. "additionalProperties": {}
  579. },
  580. "models": {
  581. "type": "object",
  582. "additionalProperties": {
  583. "type": "object",
  584. "properties": {
  585. "name": {
  586. "type": "string"
  587. },
  588. "cost": {
  589. "type": "object",
  590. "properties": {
  591. "input": {
  592. "type": "number"
  593. },
  594. "inputCached": {
  595. "type": "number"
  596. },
  597. "output": {
  598. "type": "number"
  599. },
  600. "outputCached": {
  601. "type": "number"
  602. }
  603. },
  604. "required": [
  605. "input",
  606. "inputCached",
  607. "output",
  608. "outputCached"
  609. ]
  610. },
  611. "contextWindow": {
  612. "type": "number"
  613. },
  614. "maxTokens": {
  615. "type": "number"
  616. },
  617. "attachment": {
  618. "type": "boolean"
  619. }
  620. },
  621. "required": [
  622. "cost",
  623. "contextWindow",
  624. "maxTokens",
  625. "attachment"
  626. ]
  627. }
  628. }
  629. }
  630. }
  631. }
  632. }
  633. }