MarshalJSON serializes the named provider config, deriving the wire-only `hasBearerTokenProvider` flag from the presence of [NamedProviderConfig.BearerTokenProvider]. The non-serializable callback never crosses the RPC boundary; the runtime only learns that a token provider exists and forwards the p
()
| 1848 | // crosses the RPC boundary; the runtime only learns that a token provider exists |
| 1849 | // and forwards the provider name back when it needs a token. |
| 1850 | func (p NamedProviderConfig) MarshalJSON() ([]byte, error) { |
| 1851 | type wire NamedProviderConfig |
| 1852 | aux := struct { |
| 1853 | wire |
| 1854 | HasBearerTokenProvider *bool `json:"hasBearerTokenProvider,omitempty"` |
| 1855 | }{wire: wire(p)} |
| 1856 | if p.BearerTokenProvider != nil { |
| 1857 | aux.HasBearerTokenProvider = Bool(true) |
| 1858 | } |
| 1859 | return json.Marshal(aux) |
| 1860 | } |
| 1861 | |
| 1862 | // ProviderModelConfig is a BYOK model definition that references a |
| 1863 | // NamedProviderConfig by name and is added to the session's selectable model |