1+ //HintName: G.Api.BetaModelsGet.g.cs
2+
3+ #nullable enable
4+
5+ namespace G
6+ {
7+ public partial class Api
8+ {
9+ partial void PrepareBetaModelsGetArguments (
10+ global ::System . Net . Http . HttpClient httpClient ,
11+ ref string modelId ,
12+ ref string ? anthropicVersion ,
13+ ref string ? xApiKey ) ;
14+ partial void PrepareBetaModelsGetRequest (
15+ global ::System . Net . Http . HttpClient httpClient ,
16+ global ::System . Net . Http . HttpRequestMessage httpRequestMessage ,
17+ string modelId ,
18+ string ? anthropicVersion ,
19+ string ? xApiKey ) ;
20+ partial void ProcessBetaModelsGetResponse (
21+ global ::System . Net . Http . HttpClient httpClient ,
22+ global ::System . Net . Http . HttpResponseMessage httpResponseMessage ) ;
23+
24+ partial void ProcessBetaModelsGetResponseContent (
25+ global ::System . Net . Http . HttpClient httpClient ,
26+ global ::System . Net . Http . HttpResponseMessage httpResponseMessage ,
27+ ref string content ) ;
28+
29+ /// <summary>
30+ /// Get a Model<br/>
31+ /// Get a specific model.<br/>
32+ /// The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID.
33+ /// </summary>
34+ /// <param name="modelId">
35+ /// Model identifier or alias.
36+ /// </param>
37+ /// <param name="anthropicVersion">
38+ /// The version of the Anthropic API you want to use.<br/>
39+ /// Read more about versioning and our version history [here](https://docs.anthropic.com/en/api/versioning).
40+ /// </param>
41+ /// <param name="xApiKey">
42+ /// Your unique API key for authentication. <br/>
43+ /// This key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace.
44+ /// </param>
45+ /// <param name="cancellationToken">The token to cancel the operation with</param>
46+ /// <exception cref="global::G.ApiException"></exception>
47+ public async global ::System . Threading . Tasks . Task < global ::G . BetaModelInfo > BetaModelsGetAsync (
48+ string modelId ,
49+ string ? anthropicVersion = default ,
50+ string ? xApiKey = default ,
51+ global ::System . Threading . CancellationToken cancellationToken = default )
52+ {
53+ PrepareArguments (
54+ client : HttpClient ) ;
55+ PrepareBetaModelsGetArguments (
56+ httpClient : HttpClient ,
57+ modelId : ref modelId ,
58+ anthropicVersion : ref anthropicVersion ,
59+ xApiKey : ref xApiKey ) ;
60+
61+ var __pathBuilder = new PathBuilder (
62+ path : $ "/v1/models/{ modelId } ?beta=true",
63+ baseUri : HttpClient . BaseAddress ) ;
64+ var __path = __pathBuilder . ToString ( ) ;
65+ using var __httpRequest = new global ::System . Net . Http . HttpRequestMessage (
66+ method : global ::System . Net . Http . HttpMethod . Get ,
67+ requestUri : new global ::System . Uri ( __path , global ::System . UriKind . RelativeOrAbsolute ) ) ;
68+ #if NET6_0_OR_GREATER
69+ __httpRequest . Version = global ::System . Net . HttpVersion . Version11 ;
70+ __httpRequest . VersionPolicy = global ::System . Net . Http . HttpVersionPolicy . RequestVersionOrHigher ;
71+ #endif
72+
73+ if ( anthropicVersion != default )
74+ {
75+ __httpRequest . Headers . TryAddWithoutValidation ( "anthropic-version" , anthropicVersion . ToString ( ) ) ;
76+ }
77+ if ( xApiKey != default )
78+ {
79+ __httpRequest . Headers . TryAddWithoutValidation ( "x-api-key" , xApiKey . ToString ( ) ) ;
80+ }
81+
82+
83+ PrepareRequest (
84+ client : HttpClient ,
85+ request : __httpRequest ) ;
86+ PrepareBetaModelsGetRequest (
87+ httpClient : HttpClient ,
88+ httpRequestMessage : __httpRequest ,
89+ modelId : modelId ,
90+ anthropicVersion : anthropicVersion ,
91+ xApiKey : xApiKey ) ;
92+
93+ using var __response = await HttpClient . SendAsync (
94+ request : __httpRequest ,
95+ completionOption : global ::System . Net . Http . HttpCompletionOption . ResponseContentRead ,
96+ cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
97+
98+ ProcessResponse (
99+ client : HttpClient ,
100+ response : __response ) ;
101+ ProcessBetaModelsGetResponse (
102+ httpClient : HttpClient ,
103+ httpResponseMessage : __response ) ;
104+ // Error response. See our [errors documentation](https://docs.anthropic.com/en/api/errors) for more details.
105+ if ( ( int ) __response . StatusCode >= 400 && ( int ) __response . StatusCode <= 499 )
106+ {
107+ string ? __content_4XX = null ;
108+ global ::G . BetaErrorResponse ? __value_4XX = null ;
109+ if ( ReadResponseAsString )
110+ {
111+ __content_4XX = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
112+ __value_4XX = global ::G . BetaErrorResponse . FromJson ( __content_4XX , JsonSerializerOptions ) ;
113+ }
114+ else
115+ {
116+ var __contentStream_4XX = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
117+ __value_4XX = await global ::G . BetaErrorResponse . FromJsonStreamAsync ( __contentStream_4XX , JsonSerializerOptions ) . ConfigureAwait ( false ) ;
118+ }
119+
120+ throw new global ::G . ApiException < global ::G . BetaErrorResponse > (
121+ message : __response . ReasonPhrase ?? string . Empty ,
122+ statusCode : __response . StatusCode )
123+ {
124+ ResponseBody = __content_4XX ,
125+ ResponseObject = __value_4XX ,
126+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
127+ __response . Headers ,
128+ h => h . Key ,
129+ h => h . Value ) ,
130+ } ;
131+ }
132+
133+ if ( ReadResponseAsString )
134+ {
135+ var __content = await __response . Content . ReadAsStringAsync (
136+ #if NET5_0_OR_GREATER
137+ cancellationToken
138+ #endif
139+ ) . ConfigureAwait ( false ) ;
140+
141+ ProcessResponseContent (
142+ client : HttpClient ,
143+ response : __response ,
144+ content : ref __content ) ;
145+ ProcessBetaModelsGetResponseContent (
146+ httpClient : HttpClient ,
147+ httpResponseMessage : __response ,
148+ content : ref __content ) ;
149+
150+ try
151+ {
152+ __response . EnsureSuccessStatusCode ( ) ;
153+ }
154+ catch ( global ::System . Net . Http . HttpRequestException __ex )
155+ {
156+ throw new global ::G . ApiException (
157+ message : __content ?? __response . ReasonPhrase ?? string . Empty ,
158+ innerException : __ex ,
159+ statusCode : __response . StatusCode )
160+ {
161+ ResponseBody = __content ,
162+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
163+ __response . Headers ,
164+ h => h . Key ,
165+ h => h . Value ) ,
166+ } ;
167+ }
168+
169+ return
170+ global ::G . BetaModelInfo . FromJson ( __content , JsonSerializerOptions ) ??
171+ throw new global ::System . InvalidOperationException ( $ "Response deserialization failed for \" { __content } \" ") ;
172+ }
173+ else
174+ {
175+ try
176+ {
177+ __response . EnsureSuccessStatusCode ( ) ;
178+ }
179+ catch ( global ::System . Net . Http . HttpRequestException __ex )
180+ {
181+ throw new global ::G . ApiException (
182+ message : __response . ReasonPhrase ?? string . Empty ,
183+ innerException : __ex ,
184+ statusCode : __response . StatusCode )
185+ {
186+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
187+ __response . Headers ,
188+ h => h . Key ,
189+ h => h . Value ) ,
190+ } ;
191+ }
192+
193+ using var __content = await __response . Content . ReadAsStreamAsync (
194+ #if NET5_0_OR_GREATER
195+ cancellationToken
196+ #endif
197+ ) . ConfigureAwait ( false ) ;
198+
199+ return
200+ await global ::G . BetaModelInfo . FromJsonStreamAsync ( __content , JsonSerializerOptions ) . ConfigureAwait ( false ) ??
201+ throw new global ::System . InvalidOperationException ( "Response deserialization failed." ) ;
202+ }
203+ }
204+ }
205+ }
0 commit comments