From f738a8c6efe0530ff1088fced9c6c2681ab4d99d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 28 May 2026 16:13:50 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- ...ePresetsClient.CreatePresetsResponses.g.cs | 154 ++++ ...outer.Models.MessagesMessageParamRole.g.cs | 6 + ...ePresetsClient.CreatePresetsResponses.g.cs | 833 ++++++++++++++++++ src/libs/OpenRouter/openapi.yaml | 105 ++- 4 files changed, 1097 insertions(+), 1 deletion(-) create mode 100644 src/libs/OpenRouter/Generated/OpenRouter.ISubpackagePresetsClient.CreatePresetsResponses.g.cs create mode 100644 src/libs/OpenRouter/Generated/OpenRouter.SubpackagePresetsClient.CreatePresetsResponses.g.cs diff --git a/src/libs/OpenRouter/Generated/OpenRouter.ISubpackagePresetsClient.CreatePresetsResponses.g.cs b/src/libs/OpenRouter/Generated/OpenRouter.ISubpackagePresetsClient.CreatePresetsResponses.g.cs new file mode 100644 index 00000000..9d60250d --- /dev/null +++ b/src/libs/OpenRouter/Generated/OpenRouter.ISubpackagePresetsClient.CreatePresetsResponses.g.cs @@ -0,0 +1,154 @@ +#nullable enable + +namespace OpenRouter +{ + public partial interface ISubpackagePresetsClient + { + /// + /// Create a preset from a responses request body
+ /// Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. + ///
+ /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreatePresetsResponsesAsync( + string slug, + + global::OpenRouter.ResponsesRequest request, + global::OpenRouter.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a preset from a responses request body
+ /// Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. + ///
+ /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePresetsResponsesAsResponseAsync( + string slug, + + global::OpenRouter.ResponsesRequest request, + global::OpenRouter.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a preset from a responses request body
+ /// Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. + ///
+ /// + /// + /// + /// Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models. + /// + /// + /// + /// + /// + /// Input for a response request - can be a string or array of items + /// + /// + /// + /// + /// + /// Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed. + /// + /// + /// Output modalities for the response. Supported values are "text" and "image". + /// + /// + /// + /// + /// + /// Plugins you want to enable for this request, including their settings. + /// + /// + /// + /// + /// + /// + /// When multiple model providers are available, optionally indicate your routing preference. + /// + /// + /// Configuration for reasoning mode in the response + /// + /// + /// Any type + /// + /// + /// + /// + /// A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. + /// + /// + /// Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. + /// + /// + /// + /// Default Value: false + /// + /// + /// + /// Text output configuration including format and verbosity + /// + /// + /// + /// + /// + /// + /// + /// Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. + /// + /// + /// + /// A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreatePresetsResponsesAsync( + string slug, + bool? background = default, + global::OpenRouter.AnthropicCacheControlDirective? cacheControl = default, + double? frequencyPenalty = default, + global::OpenRouter.ImageConfig? imageConfig = default, + global::System.Collections.Generic.IList? include = default, + global::OpenRouter.Inputs? input = default, + string? instructions = default, + int? maxOutputTokens = default, + int? maxToolCalls = default, + global::System.Collections.Generic.Dictionary? metadata = default, + global::System.Collections.Generic.IList? modalities = default, + string? model = default, + global::System.Collections.Generic.IList? models = default, + bool? parallelToolCalls = default, + global::System.Collections.Generic.IList? plugins = default, + double? presencePenalty = default, + string? previousResponseId = default, + global::OpenRouter.StoredPromptTemplate? prompt = default, + string? promptCacheKey = default, + global::OpenRouter.ProviderPreferences? provider = default, + global::OpenRouter.ReasoningConfig? reasoning = default, + object? route = default, + string? safetyIdentifier = default, + global::OpenRouter.OneOf? serviceTier = default, + string? sessionId = default, + global::System.Collections.Generic.IList? stopServerToolsWhen = default, + bool? store = default, + bool? stream = default, + double? temperature = default, + global::OpenRouter.TextExtendedConfig? text = default, + global::OpenRouter.OpenAIResponsesToolChoice? toolChoice = default, + global::System.Collections.Generic.IList? tools = default, + int? topK = default, + int? topLogprobs = default, + double? topP = default, + global::OpenRouter.TraceConfig? trace = default, + global::OpenRouter.OpenAIResponsesTruncation? truncation = default, + string? user = default, + global::OpenRouter.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/OpenRouter/Generated/OpenRouter.Models.MessagesMessageParamRole.g.cs b/src/libs/OpenRouter/Generated/OpenRouter.Models.MessagesMessageParamRole.g.cs index 6292d2fc..1e325bbd 100644 --- a/src/libs/OpenRouter/Generated/OpenRouter.Models.MessagesMessageParamRole.g.cs +++ b/src/libs/OpenRouter/Generated/OpenRouter.Models.MessagesMessageParamRole.g.cs @@ -15,6 +15,10 @@ public enum MessagesMessageParamRole /// /// /// + System, + /// + /// + /// User, } @@ -31,6 +35,7 @@ public static string ToValueString(this MessagesMessageParamRole value) return value switch { MessagesMessageParamRole.Assistant => "assistant", + MessagesMessageParamRole.System => "system", MessagesMessageParamRole.User => "user", _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), }; @@ -43,6 +48,7 @@ public static string ToValueString(this MessagesMessageParamRole value) return value switch { "assistant" => MessagesMessageParamRole.Assistant, + "system" => MessagesMessageParamRole.System, "user" => MessagesMessageParamRole.User, _ => null, }; diff --git a/src/libs/OpenRouter/Generated/OpenRouter.SubpackagePresetsClient.CreatePresetsResponses.g.cs b/src/libs/OpenRouter/Generated/OpenRouter.SubpackagePresetsClient.CreatePresetsResponses.g.cs new file mode 100644 index 00000000..d03015ef --- /dev/null +++ b/src/libs/OpenRouter/Generated/OpenRouter.SubpackagePresetsClient.CreatePresetsResponses.g.cs @@ -0,0 +1,833 @@ + +#nullable enable + +namespace OpenRouter +{ + public partial class SubpackagePresetsClient + { + + + private static readonly global::OpenRouter.EndPointSecurityRequirement s_CreatePresetsResponsesSecurityRequirement0 = + new global::OpenRouter.EndPointSecurityRequirement + { + Authorizations = new global::OpenRouter.EndPointAuthorizationRequirement[] + { new global::OpenRouter.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "Bearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::OpenRouter.EndPointSecurityRequirement[] s_CreatePresetsResponsesSecurityRequirements = + new global::OpenRouter.EndPointSecurityRequirement[] + { s_CreatePresetsResponsesSecurityRequirement0, + }; + partial void PrepareCreatePresetsResponsesArguments( + global::System.Net.Http.HttpClient httpClient, + ref string slug, + global::OpenRouter.ResponsesRequest request); + partial void PrepareCreatePresetsResponsesRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string slug, + global::OpenRouter.ResponsesRequest request); + partial void ProcessCreatePresetsResponsesResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessCreatePresetsResponsesResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Create a preset from a responses request body
+ /// Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. + ///
+ /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task CreatePresetsResponsesAsync( + string slug, + + global::OpenRouter.ResponsesRequest request, + global::OpenRouter.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePresetsResponsesAsResponseAsync( + slug: slug, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a preset from a responses request body
+ /// Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. + ///
+ /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePresetsResponsesAsResponseAsync( + string slug, + + global::OpenRouter.ResponsesRequest request, + global::OpenRouter.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + PrepareArguments( + client: HttpClient); + PrepareCreatePresetsResponsesArguments( + httpClient: HttpClient, + slug: ref slug, + request: request); + + + var __authorizations = global::OpenRouter.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreatePresetsResponsesSecurityRequirements, + operationName: "CreatePresetsResponsesAsync"); + + using var __timeoutCancellationTokenSource = global::OpenRouter.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::OpenRouter.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::OpenRouter.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::OpenRouter.PathBuilder( + path: $"/presets/{slug}/responses", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::OpenRouter.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::OpenRouter.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreatePresetsResponsesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + slug: slug!, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::OpenRouter.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::OpenRouter.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreatePresetsResponses", + methodName: "CreatePresetsResponsesAsync", + pathTemplate: "$\"/presets/{slug}/responses\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::OpenRouter.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::OpenRouter.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::OpenRouter.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreatePresetsResponses", + methodName: "CreatePresetsResponsesAsync", + pathTemplate: "$\"/presets/{slug}/responses\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::OpenRouter.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::OpenRouter.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::OpenRouter.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::OpenRouter.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::OpenRouter.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreatePresetsResponses", + methodName: "CreatePresetsResponsesAsync", + pathTemplate: "$\"/presets/{slug}/responses\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::OpenRouter.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreatePresetsResponsesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::OpenRouter.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::OpenRouter.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreatePresetsResponses", + methodName: "CreatePresetsResponsesAsync", + pathTemplate: "$\"/presets/{slug}/responses\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::OpenRouter.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::OpenRouter.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreatePresetsResponses", + methodName: "CreatePresetsResponsesAsync", + pathTemplate: "$\"/presets/{slug}/responses\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad Request - Invalid request parameters or malformed input + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::OpenRouter.BadRequestResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::OpenRouter.BadRequestResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::OpenRouter.BadRequestResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::OpenRouter.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - Authentication required or invalid credentials + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::OpenRouter.UnauthorizedResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::OpenRouter.UnauthorizedResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::OpenRouter.UnauthorizedResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::OpenRouter.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - Authentication successful but insufficient permissions + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::OpenRouter.ForbiddenResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::OpenRouter.ForbiddenResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::OpenRouter.ForbiddenResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::OpenRouter.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not Found - Resource does not exist + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::OpenRouter.NotFoundResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::OpenRouter.NotFoundResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::OpenRouter.NotFoundResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::OpenRouter.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Conflict - Resource conflict or concurrent modification + if ((int)__response.StatusCode == 409) + { + string? __content_409 = null; + global::System.Exception? __exception_409 = null; + global::OpenRouter.ConflictResponse? __value_409 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_409 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_409 = global::OpenRouter.ConflictResponse.FromJson(__content_409, JsonSerializerContext); + } + else + { + __content_409 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_409 = global::OpenRouter.ConflictResponse.FromJson(__content_409, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_409 = __ex; + } + + + throw global::OpenRouter.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_409 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_409, + responseBody: __content_409, + responseObject: __value_409, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal Server Error - Unexpected server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::OpenRouter.InternalServerResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::OpenRouter.InternalServerResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::OpenRouter.InternalServerResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::OpenRouter.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_500, + responseObject: __value_500, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreatePresetsResponsesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::OpenRouter.CreatePresetFromInferenceResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::OpenRouter.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::OpenRouter.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::OpenRouter.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::OpenRouter.CreatePresetFromInferenceResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::OpenRouter.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::OpenRouter.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::OpenRouter.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Create a preset from a responses request body
+ /// Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored. + ///
+ /// + /// + /// + /// Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models. + /// + /// + /// + /// + /// + /// Input for a response request - can be a string or array of items + /// + /// + /// + /// + /// + /// Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed. + /// + /// + /// Output modalities for the response. Supported values are "text" and "image". + /// + /// + /// + /// + /// + /// Plugins you want to enable for this request, including their settings. + /// + /// + /// + /// + /// + /// + /// When multiple model providers are available, optionally indicate your routing preference. + /// + /// + /// Configuration for reasoning mode in the response + /// + /// + /// Any type + /// + /// + /// + /// + /// A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. + /// + /// + /// Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. + /// + /// + /// + /// Default Value: false + /// + /// + /// + /// Text output configuration including format and verbosity + /// + /// + /// + /// + /// + /// + /// + /// Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. + /// + /// + /// + /// A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task CreatePresetsResponsesAsync( + string slug, + bool? background = default, + global::OpenRouter.AnthropicCacheControlDirective? cacheControl = default, + double? frequencyPenalty = default, + global::OpenRouter.ImageConfig? imageConfig = default, + global::System.Collections.Generic.IList? include = default, + global::OpenRouter.Inputs? input = default, + string? instructions = default, + int? maxOutputTokens = default, + int? maxToolCalls = default, + global::System.Collections.Generic.Dictionary? metadata = default, + global::System.Collections.Generic.IList? modalities = default, + string? model = default, + global::System.Collections.Generic.IList? models = default, + bool? parallelToolCalls = default, + global::System.Collections.Generic.IList? plugins = default, + double? presencePenalty = default, + string? previousResponseId = default, + global::OpenRouter.StoredPromptTemplate? prompt = default, + string? promptCacheKey = default, + global::OpenRouter.ProviderPreferences? provider = default, + global::OpenRouter.ReasoningConfig? reasoning = default, + object? route = default, + string? safetyIdentifier = default, + global::OpenRouter.OneOf? serviceTier = default, + string? sessionId = default, + global::System.Collections.Generic.IList? stopServerToolsWhen = default, + bool? store = default, + bool? stream = default, + double? temperature = default, + global::OpenRouter.TextExtendedConfig? text = default, + global::OpenRouter.OpenAIResponsesToolChoice? toolChoice = default, + global::System.Collections.Generic.IList? tools = default, + int? topK = default, + int? topLogprobs = default, + double? topP = default, + global::OpenRouter.TraceConfig? trace = default, + global::OpenRouter.OpenAIResponsesTruncation? truncation = default, + string? user = default, + global::OpenRouter.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::OpenRouter.ResponsesRequest + { + Background = background, + CacheControl = cacheControl, + FrequencyPenalty = frequencyPenalty, + ImageConfig = imageConfig, + Include = include, + Input = input, + Instructions = instructions, + MaxOutputTokens = maxOutputTokens, + MaxToolCalls = maxToolCalls, + Metadata = metadata, + Modalities = modalities, + Model = model, + Models = models, + ParallelToolCalls = parallelToolCalls, + Plugins = plugins, + PresencePenalty = presencePenalty, + PreviousResponseId = previousResponseId, + Prompt = prompt, + PromptCacheKey = promptCacheKey, + Provider = provider, + Reasoning = reasoning, + Route = route, + SafetyIdentifier = safetyIdentifier, + ServiceTier = serviceTier, + SessionId = sessionId, + StopServerToolsWhen = stopServerToolsWhen, + Store = store, + Stream = stream, + Temperature = temperature, + Text = text, + ToolChoice = toolChoice, + Tools = tools, + TopK = topK, + TopLogprobs = topLogprobs, + TopP = topP, + Trace = trace, + Truncation = truncation, + User = user, + }; + + return await CreatePresetsResponsesAsync( + slug: slug, + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/libs/OpenRouter/openapi.yaml b/src/libs/OpenRouter/openapi.yaml index 4f9ba383..ec9225b7 100644 --- a/src/libs/OpenRouter/openapi.yaml +++ b/src/libs/OpenRouter/openapi.yaml @@ -4250,6 +4250,108 @@ } } }, + "/presets/{slug}/responses": { + "post": { + "operationId": "create-presets-responses", + "summary": "Create a preset from a responses request body", + "description": "Creates a preset (or a new version of an existing one) from an inference request body. Only fields that overlap with the preset config are persisted; other fields (e.g. `messages`, `stream`, `prompt`) are silently ignored.", + "tags": [ + "subpackage_presets" + ], + "parameters": [ + { + "name": "slug", + "in": "path", + "description": "URL-safe slug identifying the preset. Created if it does not exist.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Preset created or updated successfully.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreatePresetFromInferenceResponse" + } + } + } + }, + "400": { + "description": "Bad Request - Invalid request parameters or malformed input", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestResponse" + } + } + } + }, + "401": { + "description": "Unauthorized - Authentication required or invalid credentials", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" + } + } + } + }, + "403": { + "description": "Forbidden - Authentication successful but insufficient permissions", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" + } + } + } + }, + "404": { + "description": "Not Found - Resource does not exist", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundResponse" + } + } + } + }, + "409": { + "description": "Conflict - Resource conflict or concurrent modification", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConflictResponse" + } + } + } + }, + "500": { + "description": "Internal Server Error - Unexpected server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerResponse" + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponsesRequest" + } + } + } + } + } + }, "/providers": { "get": { "operationId": "list-providers", @@ -24595,7 +24697,8 @@ "type": "string", "enum": [ "user", - "assistant" + "assistant", + "system" ], "title": "MessagesMessageParamRole" },