openapi.json 16 KB

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