config.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. package opencode
  3. import (
  4. "context"
  5. "net/http"
  6. "reflect"
  7. "github.com/sst/opencode-sdk-go/internal/apijson"
  8. "github.com/sst/opencode-sdk-go/internal/requestconfig"
  9. "github.com/sst/opencode-sdk-go/option"
  10. "github.com/tidwall/gjson"
  11. )
  12. // ConfigService contains methods and other services that help with interacting
  13. // with the opencode API.
  14. //
  15. // Note, unlike clients, this service does not read variables from the environment
  16. // automatically. You should not instantiate this service directly, and instead use
  17. // the [NewConfigService] method instead.
  18. type ConfigService struct {
  19. Options []option.RequestOption
  20. }
  21. // NewConfigService generates a new service that applies the given options to each
  22. // request. These options are applied after the parent client's options (if there
  23. // is one), and before any request-specific options.
  24. func NewConfigService(opts ...option.RequestOption) (r *ConfigService) {
  25. r = &ConfigService{}
  26. r.Options = opts
  27. return
  28. }
  29. // Get config info
  30. func (r *ConfigService) Get(ctx context.Context, opts ...option.RequestOption) (res *Config, err error) {
  31. opts = append(r.Options[:], opts...)
  32. path := "config"
  33. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  34. return
  35. }
  36. // List all providers
  37. func (r *ConfigService) Providers(ctx context.Context, opts ...option.RequestOption) (res *ConfigProvidersResponse, err error) {
  38. opts = append(r.Options[:], opts...)
  39. path := "config/providers"
  40. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  41. return
  42. }
  43. type Config struct {
  44. // JSON schema reference for configuration validation
  45. Schema string `json:"$schema"`
  46. // Share newly created sessions automatically
  47. Autoshare bool `json:"autoshare"`
  48. // Automatically update to the latest version
  49. Autoupdate bool `json:"autoupdate"`
  50. // Disable providers that are loaded automatically
  51. DisabledProviders []string `json:"disabled_providers"`
  52. Experimental ConfigExperimental `json:"experimental"`
  53. // Additional instruction files or patterns to include
  54. Instructions []string `json:"instructions"`
  55. // Custom keybind configurations
  56. Keybinds Keybinds `json:"keybinds"`
  57. // Minimum log level to write to log files
  58. LogLevel LogLevel `json:"log_level"`
  59. // MCP (Model Context Protocol) server configurations
  60. Mcp map[string]ConfigMcp `json:"mcp"`
  61. // Model to use in the format of provider/model, eg anthropic/claude-2
  62. Model string `json:"model"`
  63. // Custom provider configurations and model overrides
  64. Provider map[string]ConfigProvider `json:"provider"`
  65. // Theme name to use for the interface
  66. Theme string `json:"theme"`
  67. JSON configJSON `json:"-"`
  68. }
  69. // configJSON contains the JSON metadata for the struct [Config]
  70. type configJSON struct {
  71. Schema apijson.Field
  72. Autoshare apijson.Field
  73. Autoupdate apijson.Field
  74. DisabledProviders apijson.Field
  75. Experimental apijson.Field
  76. Instructions apijson.Field
  77. Keybinds apijson.Field
  78. LogLevel apijson.Field
  79. Mcp apijson.Field
  80. Model apijson.Field
  81. Provider apijson.Field
  82. Theme apijson.Field
  83. raw string
  84. ExtraFields map[string]apijson.Field
  85. }
  86. func (r *Config) UnmarshalJSON(data []byte) (err error) {
  87. return apijson.UnmarshalRoot(data, r)
  88. }
  89. func (r configJSON) RawJSON() string {
  90. return r.raw
  91. }
  92. type ConfigExperimental struct {
  93. Hook ConfigExperimentalHook `json:"hook"`
  94. JSON configExperimentalJSON `json:"-"`
  95. }
  96. // configExperimentalJSON contains the JSON metadata for the struct
  97. // [ConfigExperimental]
  98. type configExperimentalJSON struct {
  99. Hook apijson.Field
  100. raw string
  101. ExtraFields map[string]apijson.Field
  102. }
  103. func (r *ConfigExperimental) UnmarshalJSON(data []byte) (err error) {
  104. return apijson.UnmarshalRoot(data, r)
  105. }
  106. func (r configExperimentalJSON) RawJSON() string {
  107. return r.raw
  108. }
  109. type ConfigExperimentalHook struct {
  110. FileEdited map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"`
  111. SessionCompleted []ConfigExperimentalHookSessionCompleted `json:"session_completed"`
  112. JSON configExperimentalHookJSON `json:"-"`
  113. }
  114. // configExperimentalHookJSON contains the JSON metadata for the struct
  115. // [ConfigExperimentalHook]
  116. type configExperimentalHookJSON struct {
  117. FileEdited apijson.Field
  118. SessionCompleted apijson.Field
  119. raw string
  120. ExtraFields map[string]apijson.Field
  121. }
  122. func (r *ConfigExperimentalHook) UnmarshalJSON(data []byte) (err error) {
  123. return apijson.UnmarshalRoot(data, r)
  124. }
  125. func (r configExperimentalHookJSON) RawJSON() string {
  126. return r.raw
  127. }
  128. type ConfigExperimentalHookFileEdited struct {
  129. Command []string `json:"command,required"`
  130. Environment map[string]string `json:"environment"`
  131. JSON configExperimentalHookFileEditedJSON `json:"-"`
  132. }
  133. // configExperimentalHookFileEditedJSON contains the JSON metadata for the struct
  134. // [ConfigExperimentalHookFileEdited]
  135. type configExperimentalHookFileEditedJSON struct {
  136. Command apijson.Field
  137. Environment apijson.Field
  138. raw string
  139. ExtraFields map[string]apijson.Field
  140. }
  141. func (r *ConfigExperimentalHookFileEdited) UnmarshalJSON(data []byte) (err error) {
  142. return apijson.UnmarshalRoot(data, r)
  143. }
  144. func (r configExperimentalHookFileEditedJSON) RawJSON() string {
  145. return r.raw
  146. }
  147. type ConfigExperimentalHookSessionCompleted struct {
  148. Command []string `json:"command,required"`
  149. Environment map[string]string `json:"environment"`
  150. JSON configExperimentalHookSessionCompletedJSON `json:"-"`
  151. }
  152. // configExperimentalHookSessionCompletedJSON contains the JSON metadata for the
  153. // struct [ConfigExperimentalHookSessionCompleted]
  154. type configExperimentalHookSessionCompletedJSON struct {
  155. Command apijson.Field
  156. Environment apijson.Field
  157. raw string
  158. ExtraFields map[string]apijson.Field
  159. }
  160. func (r *ConfigExperimentalHookSessionCompleted) UnmarshalJSON(data []byte) (err error) {
  161. return apijson.UnmarshalRoot(data, r)
  162. }
  163. func (r configExperimentalHookSessionCompletedJSON) RawJSON() string {
  164. return r.raw
  165. }
  166. type ConfigMcp struct {
  167. // Type of MCP server connection
  168. Type ConfigMcpType `json:"type,required"`
  169. // This field can have the runtime type of [[]string].
  170. Command interface{} `json:"command"`
  171. // Enable or disable the MCP server on startup
  172. Enabled bool `json:"enabled"`
  173. // This field can have the runtime type of [map[string]string].
  174. Environment interface{} `json:"environment"`
  175. // URL of the remote MCP server
  176. URL string `json:"url"`
  177. JSON configMcpJSON `json:"-"`
  178. union ConfigMcpUnion
  179. }
  180. // configMcpJSON contains the JSON metadata for the struct [ConfigMcp]
  181. type configMcpJSON struct {
  182. Type apijson.Field
  183. Command apijson.Field
  184. Enabled apijson.Field
  185. Environment apijson.Field
  186. URL apijson.Field
  187. raw string
  188. ExtraFields map[string]apijson.Field
  189. }
  190. func (r configMcpJSON) RawJSON() string {
  191. return r.raw
  192. }
  193. func (r *ConfigMcp) UnmarshalJSON(data []byte) (err error) {
  194. *r = ConfigMcp{}
  195. err = apijson.UnmarshalRoot(data, &r.union)
  196. if err != nil {
  197. return err
  198. }
  199. return apijson.Port(r.union, &r)
  200. }
  201. // AsUnion returns a [ConfigMcpUnion] interface which you can cast to the specific
  202. // types for more type safety.
  203. //
  204. // Possible runtime types of the union are [McpLocal], [McpRemote].
  205. func (r ConfigMcp) AsUnion() ConfigMcpUnion {
  206. return r.union
  207. }
  208. // Union satisfied by [McpLocal] or [McpRemote].
  209. type ConfigMcpUnion interface {
  210. implementsConfigMcp()
  211. }
  212. func init() {
  213. apijson.RegisterUnion(
  214. reflect.TypeOf((*ConfigMcpUnion)(nil)).Elem(),
  215. "type",
  216. apijson.UnionVariant{
  217. TypeFilter: gjson.JSON,
  218. Type: reflect.TypeOf(McpLocal{}),
  219. DiscriminatorValue: "local",
  220. },
  221. apijson.UnionVariant{
  222. TypeFilter: gjson.JSON,
  223. Type: reflect.TypeOf(McpRemote{}),
  224. DiscriminatorValue: "remote",
  225. },
  226. )
  227. }
  228. // Type of MCP server connection
  229. type ConfigMcpType string
  230. const (
  231. ConfigMcpTypeLocal ConfigMcpType = "local"
  232. ConfigMcpTypeRemote ConfigMcpType = "remote"
  233. )
  234. func (r ConfigMcpType) IsKnown() bool {
  235. switch r {
  236. case ConfigMcpTypeLocal, ConfigMcpTypeRemote:
  237. return true
  238. }
  239. return false
  240. }
  241. type ConfigProvider struct {
  242. Models map[string]ConfigProviderModel `json:"models,required"`
  243. ID string `json:"id"`
  244. API string `json:"api"`
  245. Env []string `json:"env"`
  246. Name string `json:"name"`
  247. Npm string `json:"npm"`
  248. Options map[string]interface{} `json:"options"`
  249. JSON configProviderJSON `json:"-"`
  250. }
  251. // configProviderJSON contains the JSON metadata for the struct [ConfigProvider]
  252. type configProviderJSON struct {
  253. Models apijson.Field
  254. ID apijson.Field
  255. API apijson.Field
  256. Env apijson.Field
  257. Name apijson.Field
  258. Npm apijson.Field
  259. Options apijson.Field
  260. raw string
  261. ExtraFields map[string]apijson.Field
  262. }
  263. func (r *ConfigProvider) UnmarshalJSON(data []byte) (err error) {
  264. return apijson.UnmarshalRoot(data, r)
  265. }
  266. func (r configProviderJSON) RawJSON() string {
  267. return r.raw
  268. }
  269. type ConfigProviderModel struct {
  270. ID string `json:"id"`
  271. Attachment bool `json:"attachment"`
  272. Cost ConfigProviderModelsCost `json:"cost"`
  273. Limit ConfigProviderModelsLimit `json:"limit"`
  274. Name string `json:"name"`
  275. Options map[string]interface{} `json:"options"`
  276. Reasoning bool `json:"reasoning"`
  277. ReleaseDate string `json:"release_date"`
  278. Temperature bool `json:"temperature"`
  279. ToolCall bool `json:"tool_call"`
  280. JSON configProviderModelJSON `json:"-"`
  281. }
  282. // configProviderModelJSON contains the JSON metadata for the struct
  283. // [ConfigProviderModel]
  284. type configProviderModelJSON struct {
  285. ID apijson.Field
  286. Attachment apijson.Field
  287. Cost apijson.Field
  288. Limit apijson.Field
  289. Name apijson.Field
  290. Options apijson.Field
  291. Reasoning apijson.Field
  292. ReleaseDate apijson.Field
  293. Temperature apijson.Field
  294. ToolCall apijson.Field
  295. raw string
  296. ExtraFields map[string]apijson.Field
  297. }
  298. func (r *ConfigProviderModel) UnmarshalJSON(data []byte) (err error) {
  299. return apijson.UnmarshalRoot(data, r)
  300. }
  301. func (r configProviderModelJSON) RawJSON() string {
  302. return r.raw
  303. }
  304. type ConfigProviderModelsCost struct {
  305. Input float64 `json:"input,required"`
  306. Output float64 `json:"output,required"`
  307. CacheRead float64 `json:"cache_read"`
  308. CacheWrite float64 `json:"cache_write"`
  309. JSON configProviderModelsCostJSON `json:"-"`
  310. }
  311. // configProviderModelsCostJSON contains the JSON metadata for the struct
  312. // [ConfigProviderModelsCost]
  313. type configProviderModelsCostJSON struct {
  314. Input apijson.Field
  315. Output apijson.Field
  316. CacheRead apijson.Field
  317. CacheWrite apijson.Field
  318. raw string
  319. ExtraFields map[string]apijson.Field
  320. }
  321. func (r *ConfigProviderModelsCost) UnmarshalJSON(data []byte) (err error) {
  322. return apijson.UnmarshalRoot(data, r)
  323. }
  324. func (r configProviderModelsCostJSON) RawJSON() string {
  325. return r.raw
  326. }
  327. type ConfigProviderModelsLimit struct {
  328. Context float64 `json:"context,required"`
  329. Output float64 `json:"output,required"`
  330. JSON configProviderModelsLimitJSON `json:"-"`
  331. }
  332. // configProviderModelsLimitJSON contains the JSON metadata for the struct
  333. // [ConfigProviderModelsLimit]
  334. type configProviderModelsLimitJSON struct {
  335. Context apijson.Field
  336. Output apijson.Field
  337. raw string
  338. ExtraFields map[string]apijson.Field
  339. }
  340. func (r *ConfigProviderModelsLimit) UnmarshalJSON(data []byte) (err error) {
  341. return apijson.UnmarshalRoot(data, r)
  342. }
  343. func (r configProviderModelsLimitJSON) RawJSON() string {
  344. return r.raw
  345. }
  346. type Keybinds struct {
  347. // Exit the application
  348. AppExit string `json:"app_exit,required"`
  349. // Show help dialog
  350. AppHelp string `json:"app_help,required"`
  351. // Open external editor
  352. EditorOpen string `json:"editor_open,required"`
  353. // Close file
  354. FileClose string `json:"file_close,required"`
  355. // Split/unified diff
  356. FileDiffToggle string `json:"file_diff_toggle,required"`
  357. // List files
  358. FileList string `json:"file_list,required"`
  359. // Search file
  360. FileSearch string `json:"file_search,required"`
  361. // Clear input field
  362. InputClear string `json:"input_clear,required"`
  363. // Insert newline in input
  364. InputNewline string `json:"input_newline,required"`
  365. // Paste from clipboard
  366. InputPaste string `json:"input_paste,required"`
  367. // Submit input
  368. InputSubmit string `json:"input_submit,required"`
  369. // Leader key for keybind combinations
  370. Leader string `json:"leader,required"`
  371. // Copy message
  372. MessagesCopy string `json:"messages_copy,required"`
  373. // Navigate to first message
  374. MessagesFirst string `json:"messages_first,required"`
  375. // Scroll messages down by half page
  376. MessagesHalfPageDown string `json:"messages_half_page_down,required"`
  377. // Scroll messages up by half page
  378. MessagesHalfPageUp string `json:"messages_half_page_up,required"`
  379. // Navigate to last message
  380. MessagesLast string `json:"messages_last,required"`
  381. // Toggle layout
  382. MessagesLayoutToggle string `json:"messages_layout_toggle,required"`
  383. // Navigate to next message
  384. MessagesNext string `json:"messages_next,required"`
  385. // Scroll messages down by one page
  386. MessagesPageDown string `json:"messages_page_down,required"`
  387. // Scroll messages up by one page
  388. MessagesPageUp string `json:"messages_page_up,required"`
  389. // Navigate to previous message
  390. MessagesPrevious string `json:"messages_previous,required"`
  391. // Revert message
  392. MessagesRevert string `json:"messages_revert,required"`
  393. // List available models
  394. ModelList string `json:"model_list,required"`
  395. // Create/update AGENTS.md
  396. ProjectInit string `json:"project_init,required"`
  397. // Compact the session
  398. SessionCompact string `json:"session_compact,required"`
  399. // Interrupt current session
  400. SessionInterrupt string `json:"session_interrupt,required"`
  401. // List all sessions
  402. SessionList string `json:"session_list,required"`
  403. // Create a new session
  404. SessionNew string `json:"session_new,required"`
  405. // Share current session
  406. SessionShare string `json:"session_share,required"`
  407. // Unshare current session
  408. SessionUnshare string `json:"session_unshare,required"`
  409. // List available themes
  410. ThemeList string `json:"theme_list,required"`
  411. // Toggle tool details
  412. ToolDetails string `json:"tool_details,required"`
  413. JSON keybindsJSON `json:"-"`
  414. }
  415. // keybindsJSON contains the JSON metadata for the struct [Keybinds]
  416. type keybindsJSON struct {
  417. AppExit apijson.Field
  418. AppHelp apijson.Field
  419. EditorOpen apijson.Field
  420. FileClose apijson.Field
  421. FileDiffToggle apijson.Field
  422. FileList apijson.Field
  423. FileSearch apijson.Field
  424. InputClear apijson.Field
  425. InputNewline apijson.Field
  426. InputPaste apijson.Field
  427. InputSubmit apijson.Field
  428. Leader apijson.Field
  429. MessagesCopy apijson.Field
  430. MessagesFirst apijson.Field
  431. MessagesHalfPageDown apijson.Field
  432. MessagesHalfPageUp apijson.Field
  433. MessagesLast apijson.Field
  434. MessagesLayoutToggle apijson.Field
  435. MessagesNext apijson.Field
  436. MessagesPageDown apijson.Field
  437. MessagesPageUp apijson.Field
  438. MessagesPrevious apijson.Field
  439. MessagesRevert apijson.Field
  440. ModelList apijson.Field
  441. ProjectInit apijson.Field
  442. SessionCompact apijson.Field
  443. SessionInterrupt apijson.Field
  444. SessionList apijson.Field
  445. SessionNew apijson.Field
  446. SessionShare apijson.Field
  447. SessionUnshare apijson.Field
  448. ThemeList apijson.Field
  449. ToolDetails apijson.Field
  450. raw string
  451. ExtraFields map[string]apijson.Field
  452. }
  453. func (r *Keybinds) UnmarshalJSON(data []byte) (err error) {
  454. return apijson.UnmarshalRoot(data, r)
  455. }
  456. func (r keybindsJSON) RawJSON() string {
  457. return r.raw
  458. }
  459. type McpLocal struct {
  460. // Command and arguments to run the MCP server
  461. Command []string `json:"command,required"`
  462. // Type of MCP server connection
  463. Type McpLocalType `json:"type,required"`
  464. // Enable or disable the MCP server on startup
  465. Enabled bool `json:"enabled"`
  466. // Environment variables to set when running the MCP server
  467. Environment map[string]string `json:"environment"`
  468. JSON mcpLocalJSON `json:"-"`
  469. }
  470. // mcpLocalJSON contains the JSON metadata for the struct [McpLocal]
  471. type mcpLocalJSON struct {
  472. Command apijson.Field
  473. Type apijson.Field
  474. Enabled apijson.Field
  475. Environment apijson.Field
  476. raw string
  477. ExtraFields map[string]apijson.Field
  478. }
  479. func (r *McpLocal) UnmarshalJSON(data []byte) (err error) {
  480. return apijson.UnmarshalRoot(data, r)
  481. }
  482. func (r mcpLocalJSON) RawJSON() string {
  483. return r.raw
  484. }
  485. func (r McpLocal) implementsConfigMcp() {}
  486. // Type of MCP server connection
  487. type McpLocalType string
  488. const (
  489. McpLocalTypeLocal McpLocalType = "local"
  490. )
  491. func (r McpLocalType) IsKnown() bool {
  492. switch r {
  493. case McpLocalTypeLocal:
  494. return true
  495. }
  496. return false
  497. }
  498. type McpRemote struct {
  499. // Type of MCP server connection
  500. Type McpRemoteType `json:"type,required"`
  501. // URL of the remote MCP server
  502. URL string `json:"url,required"`
  503. // Enable or disable the MCP server on startup
  504. Enabled bool `json:"enabled"`
  505. JSON mcpRemoteJSON `json:"-"`
  506. }
  507. // mcpRemoteJSON contains the JSON metadata for the struct [McpRemote]
  508. type mcpRemoteJSON struct {
  509. Type apijson.Field
  510. URL apijson.Field
  511. Enabled apijson.Field
  512. raw string
  513. ExtraFields map[string]apijson.Field
  514. }
  515. func (r *McpRemote) UnmarshalJSON(data []byte) (err error) {
  516. return apijson.UnmarshalRoot(data, r)
  517. }
  518. func (r mcpRemoteJSON) RawJSON() string {
  519. return r.raw
  520. }
  521. func (r McpRemote) implementsConfigMcp() {}
  522. // Type of MCP server connection
  523. type McpRemoteType string
  524. const (
  525. McpRemoteTypeRemote McpRemoteType = "remote"
  526. )
  527. func (r McpRemoteType) IsKnown() bool {
  528. switch r {
  529. case McpRemoteTypeRemote:
  530. return true
  531. }
  532. return false
  533. }
  534. type Model struct {
  535. ID string `json:"id,required"`
  536. Attachment bool `json:"attachment,required"`
  537. Cost ModelCost `json:"cost,required"`
  538. Limit ModelLimit `json:"limit,required"`
  539. Name string `json:"name,required"`
  540. Options map[string]interface{} `json:"options,required"`
  541. Reasoning bool `json:"reasoning,required"`
  542. ReleaseDate string `json:"release_date,required"`
  543. Temperature bool `json:"temperature,required"`
  544. ToolCall bool `json:"tool_call,required"`
  545. JSON modelJSON `json:"-"`
  546. }
  547. // modelJSON contains the JSON metadata for the struct [Model]
  548. type modelJSON struct {
  549. ID apijson.Field
  550. Attachment apijson.Field
  551. Cost apijson.Field
  552. Limit apijson.Field
  553. Name apijson.Field
  554. Options apijson.Field
  555. Reasoning apijson.Field
  556. ReleaseDate apijson.Field
  557. Temperature apijson.Field
  558. ToolCall apijson.Field
  559. raw string
  560. ExtraFields map[string]apijson.Field
  561. }
  562. func (r *Model) UnmarshalJSON(data []byte) (err error) {
  563. return apijson.UnmarshalRoot(data, r)
  564. }
  565. func (r modelJSON) RawJSON() string {
  566. return r.raw
  567. }
  568. type ModelCost struct {
  569. Input float64 `json:"input,required"`
  570. Output float64 `json:"output,required"`
  571. CacheRead float64 `json:"cache_read"`
  572. CacheWrite float64 `json:"cache_write"`
  573. JSON modelCostJSON `json:"-"`
  574. }
  575. // modelCostJSON contains the JSON metadata for the struct [ModelCost]
  576. type modelCostJSON struct {
  577. Input apijson.Field
  578. Output apijson.Field
  579. CacheRead apijson.Field
  580. CacheWrite apijson.Field
  581. raw string
  582. ExtraFields map[string]apijson.Field
  583. }
  584. func (r *ModelCost) UnmarshalJSON(data []byte) (err error) {
  585. return apijson.UnmarshalRoot(data, r)
  586. }
  587. func (r modelCostJSON) RawJSON() string {
  588. return r.raw
  589. }
  590. type ModelLimit struct {
  591. Context float64 `json:"context,required"`
  592. Output float64 `json:"output,required"`
  593. JSON modelLimitJSON `json:"-"`
  594. }
  595. // modelLimitJSON contains the JSON metadata for the struct [ModelLimit]
  596. type modelLimitJSON struct {
  597. Context apijson.Field
  598. Output apijson.Field
  599. raw string
  600. ExtraFields map[string]apijson.Field
  601. }
  602. func (r *ModelLimit) UnmarshalJSON(data []byte) (err error) {
  603. return apijson.UnmarshalRoot(data, r)
  604. }
  605. func (r modelLimitJSON) RawJSON() string {
  606. return r.raw
  607. }
  608. type Provider struct {
  609. ID string `json:"id,required"`
  610. Env []string `json:"env,required"`
  611. Models map[string]Model `json:"models,required"`
  612. Name string `json:"name,required"`
  613. API string `json:"api"`
  614. Npm string `json:"npm"`
  615. JSON providerJSON `json:"-"`
  616. }
  617. // providerJSON contains the JSON metadata for the struct [Provider]
  618. type providerJSON struct {
  619. ID apijson.Field
  620. Env apijson.Field
  621. Models apijson.Field
  622. Name apijson.Field
  623. API apijson.Field
  624. Npm apijson.Field
  625. raw string
  626. ExtraFields map[string]apijson.Field
  627. }
  628. func (r *Provider) UnmarshalJSON(data []byte) (err error) {
  629. return apijson.UnmarshalRoot(data, r)
  630. }
  631. func (r providerJSON) RawJSON() string {
  632. return r.raw
  633. }
  634. type ConfigProvidersResponse struct {
  635. Default map[string]string `json:"default,required"`
  636. Providers []Provider `json:"providers,required"`
  637. JSON configProvidersResponseJSON `json:"-"`
  638. }
  639. // configProvidersResponseJSON contains the JSON metadata for the struct
  640. // [ConfigProvidersResponse]
  641. type configProvidersResponseJSON struct {
  642. Default apijson.Field
  643. Providers apijson.Field
  644. raw string
  645. ExtraFields map[string]apijson.Field
  646. }
  647. func (r *ConfigProvidersResponse) UnmarshalJSON(data []byte) (err error) {
  648. return apijson.UnmarshalRoot(data, r)
  649. }
  650. func (r configProvidersResponseJSON) RawJSON() string {
  651. return r.raw
  652. }