config.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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. // MCP (Model Context Protocol) server configurations
  58. Mcp map[string]ConfigMcp `json:"mcp"`
  59. // Model to use in the format of provider/model, eg anthropic/claude-2
  60. Model string `json:"model"`
  61. // Custom provider configurations and model overrides
  62. Provider map[string]ConfigProvider `json:"provider"`
  63. // Theme name to use for the interface
  64. Theme string `json:"theme"`
  65. JSON configJSON `json:"-"`
  66. }
  67. // configJSON contains the JSON metadata for the struct [Config]
  68. type configJSON struct {
  69. Schema apijson.Field
  70. Autoshare apijson.Field
  71. Autoupdate apijson.Field
  72. DisabledProviders apijson.Field
  73. Experimental apijson.Field
  74. Instructions apijson.Field
  75. Keybinds apijson.Field
  76. Mcp apijson.Field
  77. Model apijson.Field
  78. Provider apijson.Field
  79. Theme apijson.Field
  80. raw string
  81. ExtraFields map[string]apijson.Field
  82. }
  83. func (r *Config) UnmarshalJSON(data []byte) (err error) {
  84. return apijson.UnmarshalRoot(data, r)
  85. }
  86. func (r configJSON) RawJSON() string {
  87. return r.raw
  88. }
  89. type ConfigExperimental struct {
  90. Hook ConfigExperimentalHook `json:"hook"`
  91. JSON configExperimentalJSON `json:"-"`
  92. }
  93. // configExperimentalJSON contains the JSON metadata for the struct
  94. // [ConfigExperimental]
  95. type configExperimentalJSON struct {
  96. Hook apijson.Field
  97. raw string
  98. ExtraFields map[string]apijson.Field
  99. }
  100. func (r *ConfigExperimental) UnmarshalJSON(data []byte) (err error) {
  101. return apijson.UnmarshalRoot(data, r)
  102. }
  103. func (r configExperimentalJSON) RawJSON() string {
  104. return r.raw
  105. }
  106. type ConfigExperimentalHook struct {
  107. FileEdited map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"`
  108. SessionCompleted []ConfigExperimentalHookSessionCompleted `json:"session_completed"`
  109. JSON configExperimentalHookJSON `json:"-"`
  110. }
  111. // configExperimentalHookJSON contains the JSON metadata for the struct
  112. // [ConfigExperimentalHook]
  113. type configExperimentalHookJSON struct {
  114. FileEdited apijson.Field
  115. SessionCompleted apijson.Field
  116. raw string
  117. ExtraFields map[string]apijson.Field
  118. }
  119. func (r *ConfigExperimentalHook) UnmarshalJSON(data []byte) (err error) {
  120. return apijson.UnmarshalRoot(data, r)
  121. }
  122. func (r configExperimentalHookJSON) RawJSON() string {
  123. return r.raw
  124. }
  125. type ConfigExperimentalHookFileEdited struct {
  126. Command []string `json:"command,required"`
  127. Environment map[string]string `json:"environment"`
  128. JSON configExperimentalHookFileEditedJSON `json:"-"`
  129. }
  130. // configExperimentalHookFileEditedJSON contains the JSON metadata for the struct
  131. // [ConfigExperimentalHookFileEdited]
  132. type configExperimentalHookFileEditedJSON struct {
  133. Command apijson.Field
  134. Environment apijson.Field
  135. raw string
  136. ExtraFields map[string]apijson.Field
  137. }
  138. func (r *ConfigExperimentalHookFileEdited) UnmarshalJSON(data []byte) (err error) {
  139. return apijson.UnmarshalRoot(data, r)
  140. }
  141. func (r configExperimentalHookFileEditedJSON) RawJSON() string {
  142. return r.raw
  143. }
  144. type ConfigExperimentalHookSessionCompleted struct {
  145. Command []string `json:"command,required"`
  146. Environment map[string]string `json:"environment"`
  147. JSON configExperimentalHookSessionCompletedJSON `json:"-"`
  148. }
  149. // configExperimentalHookSessionCompletedJSON contains the JSON metadata for the
  150. // struct [ConfigExperimentalHookSessionCompleted]
  151. type configExperimentalHookSessionCompletedJSON struct {
  152. Command apijson.Field
  153. Environment apijson.Field
  154. raw string
  155. ExtraFields map[string]apijson.Field
  156. }
  157. func (r *ConfigExperimentalHookSessionCompleted) UnmarshalJSON(data []byte) (err error) {
  158. return apijson.UnmarshalRoot(data, r)
  159. }
  160. func (r configExperimentalHookSessionCompletedJSON) RawJSON() string {
  161. return r.raw
  162. }
  163. type ConfigMcp struct {
  164. // Type of MCP server connection
  165. Type ConfigMcpType `json:"type,required"`
  166. // This field can have the runtime type of [[]string].
  167. Command interface{} `json:"command"`
  168. // Enable or disable the MCP server on startup
  169. Enabled bool `json:"enabled"`
  170. // This field can have the runtime type of [map[string]string].
  171. Environment interface{} `json:"environment"`
  172. // URL of the remote MCP server
  173. URL string `json:"url"`
  174. JSON configMcpJSON `json:"-"`
  175. union ConfigMcpUnion
  176. }
  177. // configMcpJSON contains the JSON metadata for the struct [ConfigMcp]
  178. type configMcpJSON struct {
  179. Type apijson.Field
  180. Command apijson.Field
  181. Enabled apijson.Field
  182. Environment apijson.Field
  183. URL apijson.Field
  184. raw string
  185. ExtraFields map[string]apijson.Field
  186. }
  187. func (r configMcpJSON) RawJSON() string {
  188. return r.raw
  189. }
  190. func (r *ConfigMcp) UnmarshalJSON(data []byte) (err error) {
  191. *r = ConfigMcp{}
  192. err = apijson.UnmarshalRoot(data, &r.union)
  193. if err != nil {
  194. return err
  195. }
  196. return apijson.Port(r.union, &r)
  197. }
  198. // AsUnion returns a [ConfigMcpUnion] interface which you can cast to the specific
  199. // types for more type safety.
  200. //
  201. // Possible runtime types of the union are [McpLocal], [McpRemote].
  202. func (r ConfigMcp) AsUnion() ConfigMcpUnion {
  203. return r.union
  204. }
  205. // Union satisfied by [McpLocal] or [McpRemote].
  206. type ConfigMcpUnion interface {
  207. implementsConfigMcp()
  208. }
  209. func init() {
  210. apijson.RegisterUnion(
  211. reflect.TypeOf((*ConfigMcpUnion)(nil)).Elem(),
  212. "type",
  213. apijson.UnionVariant{
  214. TypeFilter: gjson.JSON,
  215. Type: reflect.TypeOf(McpLocal{}),
  216. DiscriminatorValue: "local",
  217. },
  218. apijson.UnionVariant{
  219. TypeFilter: gjson.JSON,
  220. Type: reflect.TypeOf(McpRemote{}),
  221. DiscriminatorValue: "remote",
  222. },
  223. )
  224. }
  225. // Type of MCP server connection
  226. type ConfigMcpType string
  227. const (
  228. ConfigMcpTypeLocal ConfigMcpType = "local"
  229. ConfigMcpTypeRemote ConfigMcpType = "remote"
  230. )
  231. func (r ConfigMcpType) IsKnown() bool {
  232. switch r {
  233. case ConfigMcpTypeLocal, ConfigMcpTypeRemote:
  234. return true
  235. }
  236. return false
  237. }
  238. type ConfigProvider struct {
  239. Models map[string]ConfigProviderModel `json:"models,required"`
  240. ID string `json:"id"`
  241. API string `json:"api"`
  242. Env []string `json:"env"`
  243. Name string `json:"name"`
  244. Npm string `json:"npm"`
  245. Options map[string]interface{} `json:"options"`
  246. JSON configProviderJSON `json:"-"`
  247. }
  248. // configProviderJSON contains the JSON metadata for the struct [ConfigProvider]
  249. type configProviderJSON struct {
  250. Models apijson.Field
  251. ID apijson.Field
  252. API apijson.Field
  253. Env apijson.Field
  254. Name apijson.Field
  255. Npm apijson.Field
  256. Options apijson.Field
  257. raw string
  258. ExtraFields map[string]apijson.Field
  259. }
  260. func (r *ConfigProvider) UnmarshalJSON(data []byte) (err error) {
  261. return apijson.UnmarshalRoot(data, r)
  262. }
  263. func (r configProviderJSON) RawJSON() string {
  264. return r.raw
  265. }
  266. type ConfigProviderModel struct {
  267. ID string `json:"id"`
  268. Attachment bool `json:"attachment"`
  269. Cost ConfigProviderModelsCost `json:"cost"`
  270. Limit ConfigProviderModelsLimit `json:"limit"`
  271. Name string `json:"name"`
  272. Options map[string]interface{} `json:"options"`
  273. Reasoning bool `json:"reasoning"`
  274. ReleaseDate string `json:"release_date"`
  275. Temperature bool `json:"temperature"`
  276. ToolCall bool `json:"tool_call"`
  277. JSON configProviderModelJSON `json:"-"`
  278. }
  279. // configProviderModelJSON contains the JSON metadata for the struct
  280. // [ConfigProviderModel]
  281. type configProviderModelJSON struct {
  282. ID apijson.Field
  283. Attachment apijson.Field
  284. Cost apijson.Field
  285. Limit apijson.Field
  286. Name apijson.Field
  287. Options apijson.Field
  288. Reasoning apijson.Field
  289. ReleaseDate apijson.Field
  290. Temperature apijson.Field
  291. ToolCall apijson.Field
  292. raw string
  293. ExtraFields map[string]apijson.Field
  294. }
  295. func (r *ConfigProviderModel) UnmarshalJSON(data []byte) (err error) {
  296. return apijson.UnmarshalRoot(data, r)
  297. }
  298. func (r configProviderModelJSON) RawJSON() string {
  299. return r.raw
  300. }
  301. type ConfigProviderModelsCost struct {
  302. Input float64 `json:"input,required"`
  303. Output float64 `json:"output,required"`
  304. CacheRead float64 `json:"cache_read"`
  305. CacheWrite float64 `json:"cache_write"`
  306. JSON configProviderModelsCostJSON `json:"-"`
  307. }
  308. // configProviderModelsCostJSON contains the JSON metadata for the struct
  309. // [ConfigProviderModelsCost]
  310. type configProviderModelsCostJSON struct {
  311. Input apijson.Field
  312. Output apijson.Field
  313. CacheRead apijson.Field
  314. CacheWrite apijson.Field
  315. raw string
  316. ExtraFields map[string]apijson.Field
  317. }
  318. func (r *ConfigProviderModelsCost) UnmarshalJSON(data []byte) (err error) {
  319. return apijson.UnmarshalRoot(data, r)
  320. }
  321. func (r configProviderModelsCostJSON) RawJSON() string {
  322. return r.raw
  323. }
  324. type ConfigProviderModelsLimit struct {
  325. Context float64 `json:"context,required"`
  326. Output float64 `json:"output,required"`
  327. JSON configProviderModelsLimitJSON `json:"-"`
  328. }
  329. // configProviderModelsLimitJSON contains the JSON metadata for the struct
  330. // [ConfigProviderModelsLimit]
  331. type configProviderModelsLimitJSON struct {
  332. Context apijson.Field
  333. Output apijson.Field
  334. raw string
  335. ExtraFields map[string]apijson.Field
  336. }
  337. func (r *ConfigProviderModelsLimit) UnmarshalJSON(data []byte) (err error) {
  338. return apijson.UnmarshalRoot(data, r)
  339. }
  340. func (r configProviderModelsLimitJSON) RawJSON() string {
  341. return r.raw
  342. }
  343. type Keybinds struct {
  344. // Exit the application
  345. AppExit string `json:"app_exit"`
  346. // Open external editor
  347. EditorOpen string `json:"editor_open"`
  348. // Show help dialog
  349. Help string `json:"help"`
  350. // Navigate to next history item
  351. HistoryNext string `json:"history_next"`
  352. // Navigate to previous history item
  353. HistoryPrevious string `json:"history_previous"`
  354. // Clear input field
  355. InputClear string `json:"input_clear"`
  356. // Insert newline in input
  357. InputNewline string `json:"input_newline"`
  358. // Paste from clipboard
  359. InputPaste string `json:"input_paste"`
  360. // Submit input
  361. InputSubmit string `json:"input_submit"`
  362. // Leader key for keybind combinations
  363. Leader string `json:"leader"`
  364. // Navigate to first message
  365. MessagesFirst string `json:"messages_first"`
  366. // Scroll messages down by half page
  367. MessagesHalfPageDown string `json:"messages_half_page_down"`
  368. // Scroll messages up by half page
  369. MessagesHalfPageUp string `json:"messages_half_page_up"`
  370. // Navigate to last message
  371. MessagesLast string `json:"messages_last"`
  372. // Navigate to next message
  373. MessagesNext string `json:"messages_next"`
  374. // Scroll messages down by one page
  375. MessagesPageDown string `json:"messages_page_down"`
  376. // Scroll messages up by one page
  377. MessagesPageUp string `json:"messages_page_up"`
  378. // Navigate to previous message
  379. MessagesPrevious string `json:"messages_previous"`
  380. // List available models
  381. ModelList string `json:"model_list"`
  382. // Initialize project configuration
  383. ProjectInit string `json:"project_init"`
  384. // Toggle compact mode for session
  385. SessionCompact string `json:"session_compact"`
  386. // Interrupt current session
  387. SessionInterrupt string `json:"session_interrupt"`
  388. // List all sessions
  389. SessionList string `json:"session_list"`
  390. // Create a new session
  391. SessionNew string `json:"session_new"`
  392. // Share current session
  393. SessionShare string `json:"session_share"`
  394. // List available themes
  395. ThemeList string `json:"theme_list"`
  396. // Show tool details
  397. ToolDetails string `json:"tool_details"`
  398. JSON keybindsJSON `json:"-"`
  399. }
  400. // keybindsJSON contains the JSON metadata for the struct [Keybinds]
  401. type keybindsJSON struct {
  402. AppExit apijson.Field
  403. EditorOpen apijson.Field
  404. Help apijson.Field
  405. HistoryNext apijson.Field
  406. HistoryPrevious apijson.Field
  407. InputClear apijson.Field
  408. InputNewline apijson.Field
  409. InputPaste apijson.Field
  410. InputSubmit apijson.Field
  411. Leader apijson.Field
  412. MessagesFirst apijson.Field
  413. MessagesHalfPageDown apijson.Field
  414. MessagesHalfPageUp apijson.Field
  415. MessagesLast apijson.Field
  416. MessagesNext apijson.Field
  417. MessagesPageDown apijson.Field
  418. MessagesPageUp apijson.Field
  419. MessagesPrevious apijson.Field
  420. ModelList apijson.Field
  421. ProjectInit apijson.Field
  422. SessionCompact apijson.Field
  423. SessionInterrupt apijson.Field
  424. SessionList apijson.Field
  425. SessionNew apijson.Field
  426. SessionShare apijson.Field
  427. ThemeList apijson.Field
  428. ToolDetails apijson.Field
  429. raw string
  430. ExtraFields map[string]apijson.Field
  431. }
  432. func (r *Keybinds) UnmarshalJSON(data []byte) (err error) {
  433. return apijson.UnmarshalRoot(data, r)
  434. }
  435. func (r keybindsJSON) RawJSON() string {
  436. return r.raw
  437. }
  438. type McpLocal struct {
  439. // Command and arguments to run the MCP server
  440. Command []string `json:"command,required"`
  441. // Type of MCP server connection
  442. Type McpLocalType `json:"type,required"`
  443. // Enable or disable the MCP server on startup
  444. Enabled bool `json:"enabled"`
  445. // Environment variables to set when running the MCP server
  446. Environment map[string]string `json:"environment"`
  447. JSON mcpLocalJSON `json:"-"`
  448. }
  449. // mcpLocalJSON contains the JSON metadata for the struct [McpLocal]
  450. type mcpLocalJSON struct {
  451. Command apijson.Field
  452. Type apijson.Field
  453. Enabled apijson.Field
  454. Environment apijson.Field
  455. raw string
  456. ExtraFields map[string]apijson.Field
  457. }
  458. func (r *McpLocal) UnmarshalJSON(data []byte) (err error) {
  459. return apijson.UnmarshalRoot(data, r)
  460. }
  461. func (r mcpLocalJSON) RawJSON() string {
  462. return r.raw
  463. }
  464. func (r McpLocal) implementsConfigMcp() {}
  465. // Type of MCP server connection
  466. type McpLocalType string
  467. const (
  468. McpLocalTypeLocal McpLocalType = "local"
  469. )
  470. func (r McpLocalType) IsKnown() bool {
  471. switch r {
  472. case McpLocalTypeLocal:
  473. return true
  474. }
  475. return false
  476. }
  477. type McpRemote struct {
  478. // Type of MCP server connection
  479. Type McpRemoteType `json:"type,required"`
  480. // URL of the remote MCP server
  481. URL string `json:"url,required"`
  482. // Enable or disable the MCP server on startup
  483. Enabled bool `json:"enabled"`
  484. JSON mcpRemoteJSON `json:"-"`
  485. }
  486. // mcpRemoteJSON contains the JSON metadata for the struct [McpRemote]
  487. type mcpRemoteJSON struct {
  488. Type apijson.Field
  489. URL apijson.Field
  490. Enabled apijson.Field
  491. raw string
  492. ExtraFields map[string]apijson.Field
  493. }
  494. func (r *McpRemote) UnmarshalJSON(data []byte) (err error) {
  495. return apijson.UnmarshalRoot(data, r)
  496. }
  497. func (r mcpRemoteJSON) RawJSON() string {
  498. return r.raw
  499. }
  500. func (r McpRemote) implementsConfigMcp() {}
  501. // Type of MCP server connection
  502. type McpRemoteType string
  503. const (
  504. McpRemoteTypeRemote McpRemoteType = "remote"
  505. )
  506. func (r McpRemoteType) IsKnown() bool {
  507. switch r {
  508. case McpRemoteTypeRemote:
  509. return true
  510. }
  511. return false
  512. }
  513. type Model struct {
  514. ID string `json:"id,required"`
  515. Attachment bool `json:"attachment,required"`
  516. Cost ModelCost `json:"cost,required"`
  517. Limit ModelLimit `json:"limit,required"`
  518. Name string `json:"name,required"`
  519. Options map[string]interface{} `json:"options,required"`
  520. Reasoning bool `json:"reasoning,required"`
  521. ReleaseDate string `json:"release_date,required"`
  522. Temperature bool `json:"temperature,required"`
  523. ToolCall bool `json:"tool_call,required"`
  524. JSON modelJSON `json:"-"`
  525. }
  526. // modelJSON contains the JSON metadata for the struct [Model]
  527. type modelJSON struct {
  528. ID apijson.Field
  529. Attachment apijson.Field
  530. Cost apijson.Field
  531. Limit apijson.Field
  532. Name apijson.Field
  533. Options apijson.Field
  534. Reasoning apijson.Field
  535. ReleaseDate apijson.Field
  536. Temperature apijson.Field
  537. ToolCall apijson.Field
  538. raw string
  539. ExtraFields map[string]apijson.Field
  540. }
  541. func (r *Model) UnmarshalJSON(data []byte) (err error) {
  542. return apijson.UnmarshalRoot(data, r)
  543. }
  544. func (r modelJSON) RawJSON() string {
  545. return r.raw
  546. }
  547. type ModelCost struct {
  548. Input float64 `json:"input,required"`
  549. Output float64 `json:"output,required"`
  550. CacheRead float64 `json:"cache_read"`
  551. CacheWrite float64 `json:"cache_write"`
  552. JSON modelCostJSON `json:"-"`
  553. }
  554. // modelCostJSON contains the JSON metadata for the struct [ModelCost]
  555. type modelCostJSON struct {
  556. Input apijson.Field
  557. Output apijson.Field
  558. CacheRead apijson.Field
  559. CacheWrite apijson.Field
  560. raw string
  561. ExtraFields map[string]apijson.Field
  562. }
  563. func (r *ModelCost) UnmarshalJSON(data []byte) (err error) {
  564. return apijson.UnmarshalRoot(data, r)
  565. }
  566. func (r modelCostJSON) RawJSON() string {
  567. return r.raw
  568. }
  569. type ModelLimit struct {
  570. Context float64 `json:"context,required"`
  571. Output float64 `json:"output,required"`
  572. JSON modelLimitJSON `json:"-"`
  573. }
  574. // modelLimitJSON contains the JSON metadata for the struct [ModelLimit]
  575. type modelLimitJSON struct {
  576. Context apijson.Field
  577. Output apijson.Field
  578. raw string
  579. ExtraFields map[string]apijson.Field
  580. }
  581. func (r *ModelLimit) UnmarshalJSON(data []byte) (err error) {
  582. return apijson.UnmarshalRoot(data, r)
  583. }
  584. func (r modelLimitJSON) RawJSON() string {
  585. return r.raw
  586. }
  587. type Provider struct {
  588. ID string `json:"id,required"`
  589. Env []string `json:"env,required"`
  590. Models map[string]Model `json:"models,required"`
  591. Name string `json:"name,required"`
  592. API string `json:"api"`
  593. Npm string `json:"npm"`
  594. JSON providerJSON `json:"-"`
  595. }
  596. // providerJSON contains the JSON metadata for the struct [Provider]
  597. type providerJSON struct {
  598. ID apijson.Field
  599. Env apijson.Field
  600. Models apijson.Field
  601. Name apijson.Field
  602. API apijson.Field
  603. Npm apijson.Field
  604. raw string
  605. ExtraFields map[string]apijson.Field
  606. }
  607. func (r *Provider) UnmarshalJSON(data []byte) (err error) {
  608. return apijson.UnmarshalRoot(data, r)
  609. }
  610. func (r providerJSON) RawJSON() string {
  611. return r.raw
  612. }
  613. type ConfigProvidersResponse struct {
  614. Default map[string]string `json:"default,required"`
  615. Providers []Provider `json:"providers,required"`
  616. JSON configProvidersResponseJSON `json:"-"`
  617. }
  618. // configProvidersResponseJSON contains the JSON metadata for the struct
  619. // [ConfigProvidersResponse]
  620. type configProvidersResponseJSON struct {
  621. Default apijson.Field
  622. Providers apijson.Field
  623. raw string
  624. ExtraFields map[string]apijson.Field
  625. }
  626. func (r *ConfigProvidersResponse) UnmarshalJSON(data []byte) (err error) {
  627. return apijson.UnmarshalRoot(data, r)
  628. }
  629. func (r configProvidersResponseJSON) RawJSON() string {
  630. return r.raw
  631. }