@@ -14,11 +14,24 @@ public sealed partial class Api : global::G.IApi, global::System.IDisposable
1414 /// <summary>
1515 ///
1616 /// </summary>
17- public const string BaseUrl = "https://api.together.xyz/v1" ;
17+ public const string DefaultBaseUrl = "https://api.together.xyz/v1" ;
1818
19- private readonly global ::System . Net . Http . HttpClient _httpClient ;
20- private global ::System . Collections . Generic . List < global ::G . EndPointAuthorization > _authorizations ;
19+ private bool _disposeHttpClient = true ;
2120
21+ /// <inheritdoc/>
22+ public global ::System . Net . Http . HttpClient HttpClient { get ; }
23+
24+ /// <inheritdoc/>
25+ public System . Uri ? BaseUri => HttpClient . BaseAddress ;
26+
27+ /// <inheritdoc/>
28+ public global ::System . Collections . Generic . List < global ::G . EndPointAuthorization > Authorizations { get ; }
29+
30+ /// <inheritdoc/>
31+ public bool ReadResponseAsString { get ; set ; }
32+ #if DEBUG
33+ = true;
34+ #endif
2235 /// <summary>
2336 ///
2437 /// </summary>
@@ -28,64 +41,72 @@ public sealed partial class Api : global::G.IApi, global::System.IDisposable
2841 /// <summary>
2942 ///
3043 /// </summary>
31- public ChatClient Chat => new ChatClient ( _httpClient , authorizations : _authorizations )
44+ public ChatClient Chat => new ChatClient ( HttpClient , authorizations : Authorizations )
3245 {
46+ ReadResponseAsString = ReadResponseAsString ,
3347 JsonSerializerOptions = JsonSerializerOptions ,
3448 } ;
3549
3650 /// <summary>
3751 ///
3852 /// </summary>
39- public CompletionClient Completion => new CompletionClient ( _httpClient , authorizations : _authorizations )
53+ public CompletionClient Completion => new CompletionClient ( HttpClient , authorizations : Authorizations )
4054 {
55+ ReadResponseAsString = ReadResponseAsString ,
4156 JsonSerializerOptions = JsonSerializerOptions ,
4257 } ;
4358
4459 /// <summary>
4560 ///
4661 /// </summary>
47- public EmbeddingsClient Embeddings => new EmbeddingsClient ( _httpClient , authorizations : _authorizations )
62+ public EmbeddingsClient Embeddings => new EmbeddingsClient ( HttpClient , authorizations : Authorizations )
4863 {
64+ ReadResponseAsString = ReadResponseAsString ,
4965 JsonSerializerOptions = JsonSerializerOptions ,
5066 } ;
5167
5268 /// <summary>
5369 ///
5470 /// </summary>
55- public FilesClient Files => new FilesClient ( _httpClient , authorizations : _authorizations )
71+ public FilesClient Files => new FilesClient ( HttpClient , authorizations : Authorizations )
5672 {
73+ ReadResponseAsString = ReadResponseAsString ,
5774 JsonSerializerOptions = JsonSerializerOptions ,
5875 } ;
5976
6077 /// <summary>
6178 ///
6279 /// </summary>
63- public FineTuningClient FineTuning => new FineTuningClient ( _httpClient , authorizations : _authorizations )
80+ public FineTuningClient FineTuning => new FineTuningClient ( HttpClient , authorizations : Authorizations )
6481 {
82+ ReadResponseAsString = ReadResponseAsString ,
6583 JsonSerializerOptions = JsonSerializerOptions ,
6684 } ;
6785
6886 /// <summary>
6987 ///
7088 /// </summary>
71- public ImagesClient Images => new ImagesClient ( _httpClient , authorizations : _authorizations )
89+ public ImagesClient Images => new ImagesClient ( HttpClient , authorizations : Authorizations )
7290 {
91+ ReadResponseAsString = ReadResponseAsString ,
7392 JsonSerializerOptions = JsonSerializerOptions ,
7493 } ;
7594
7695 /// <summary>
7796 ///
7897 /// </summary>
79- public ModelsClient Models => new ModelsClient ( _httpClient , authorizations : _authorizations )
98+ public ModelsClient Models => new ModelsClient ( HttpClient , authorizations : Authorizations )
8099 {
100+ ReadResponseAsString = ReadResponseAsString ,
81101 JsonSerializerOptions = JsonSerializerOptions ,
82102 } ;
83103
84104 /// <summary>
85105 ///
86106 /// </summary>
87- public RerankClient Rerank => new RerankClient ( _httpClient , authorizations : _authorizations )
107+ public RerankClient Rerank => new RerankClient ( HttpClient , authorizations : Authorizations )
88108 {
109+ ReadResponseAsString = ReadResponseAsString ,
89110 JsonSerializerOptions = JsonSerializerOptions ,
90111 } ;
91112
@@ -94,25 +115,31 @@ public sealed partial class Api : global::G.IApi, global::System.IDisposable
94115 /// If no httpClient is provided, a new one will be created.
95116 /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
96117 /// </summary>
97- /// <param name="httpClient"></param>
98- /// <param name="baseUri"></param>
99- /// <param name="authorizations"></param>
118+ /// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
119+ /// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
120+ /// <param name="authorizations">The authorizations to use for the requests.</param>
121+ /// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
100122 public Api (
101123 global ::System . Net . Http . HttpClient ? httpClient = null ,
102124 global ::System . Uri ? baseUri = null ,
103- global ::System . Collections . Generic . List < global ::G . EndPointAuthorization > ? authorizations = null )
125+ global ::System . Collections . Generic . List < global ::G . EndPointAuthorization > ? authorizations = null ,
126+ bool disposeHttpClient = true )
104127 {
105- _httpClient = httpClient ?? new global ::System . Net . Http . HttpClient ( ) ;
106- _httpClient . BaseAddress ??= baseUri ?? new global ::System . Uri ( BaseUrl ) ;
107- _authorizations = authorizations ?? new global ::System . Collections . Generic . List < global ::G . EndPointAuthorization > ( ) ;
128+ HttpClient = httpClient ?? new global ::System . Net . Http . HttpClient ( ) ;
129+ HttpClient . BaseAddress ??= baseUri ?? new global ::System . Uri ( DefaultBaseUrl ) ;
130+ Authorizations = authorizations ?? new global ::System . Collections . Generic . List < global ::G . EndPointAuthorization > ( ) ;
131+ _disposeHttpClient = disposeHttpClient ;
108132
109- Initialized ( _httpClient ) ;
133+ Initialized ( HttpClient ) ;
110134 }
111135
112136 /// <inheritdoc/>
113137 public void Dispose ( )
114138 {
115- _httpClient . Dispose ( ) ;
139+ if ( _disposeHttpClient )
140+ {
141+ HttpClient . Dispose ( ) ;
142+ }
116143 }
117144
118145 partial void Initialized (
0 commit comments