openapi.json 17 KB

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