openapi.json 16 KB

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