Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public partial interface IOpenRouterClient : global::System.IDisposable
/// </summary>
public SubpackageOrganizationClient SubpackageOrganization { get; }

/// <summary>
///
/// </summary>
public SubpackagePresetsClient SubpackagePresets { get; }

/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#nullable enable

namespace OpenRouter
{
public partial interface ISubpackagePresetsClient
{
/// <summary>
/// Create a preset from a chat-completions request body<br/>
/// 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.
/// </summary>
/// <param name="slug"></param>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::OpenRouter.ApiException"></exception>
global::System.Threading.Tasks.Task<global::OpenRouter.CreatePresetFromInferenceResponse> CreatePresetsChatCompletionsAsync(
string slug,

global::OpenRouter.ChatRequest request,
global::OpenRouter.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Create a preset from a chat-completions request body<br/>
/// 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.
/// </summary>
/// <param name="slug"></param>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::OpenRouter.ApiException"></exception>
global::System.Threading.Tasks.Task<global::OpenRouter.AutoSDKHttpResponse<global::OpenRouter.CreatePresetFromInferenceResponse>> CreatePresetsChatCompletionsAsResponseAsync(
string slug,

global::OpenRouter.ChatRequest request,
global::OpenRouter.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Create a preset from a chat-completions request body<br/>
/// 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.
/// </summary>
/// <param name="slug"></param>
/// <param name="cacheControl">
/// 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.
/// </param>
/// <param name="debug">
/// Debug options for inspecting request transformations (streaming only)
/// </param>
/// <param name="frequencyPenalty">
/// Frequency penalty (-2.0 to 2.0)
/// </param>
/// <param name="imageConfig"></param>
/// <param name="logitBias">
/// Token logit bias adjustments
/// </param>
/// <param name="logprobs">
/// Return log probabilities
/// </param>
/// <param name="maxCompletionTokens">
/// Maximum tokens in completion
/// </param>
/// <param name="maxTokens">
/// Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.
/// </param>
/// <param name="messages">
/// List of messages for the conversation
/// </param>
/// <param name="metadata">
/// Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)
/// </param>
/// <param name="modalities">
/// Output modalities for the response. Supported values are "text", "image", and "audio".
/// </param>
/// <param name="model">
/// Model to use for completion
/// </param>
/// <param name="models">
/// Models to use for completion
/// </param>
/// <param name="parallelToolCalls">
/// Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response.
/// </param>
/// <param name="plugins">
/// Plugins you want to enable for this request, including their settings.
/// </param>
/// <param name="presencePenalty">
/// Presence penalty (-2.0 to 2.0)
/// </param>
/// <param name="provider">
/// When multiple model providers are available, optionally indicate your routing preference.
/// </param>
/// <param name="reasoning">
/// Configuration options for reasoning models
/// </param>
/// <param name="responseFormat">
/// Response format configuration
/// </param>
/// <param name="route">
/// Any type
/// </param>
/// <param name="seed">
/// Random seed for deterministic outputs
/// </param>
/// <param name="serviceTier">
/// The service tier to use for processing this request.
/// </param>
/// <param name="sessionId">
/// 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.
/// </param>
/// <param name="stop">
/// Stop sequences (up to 4)
/// </param>
/// <param name="stopServerToolsWhen">
/// Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`.
/// </param>
/// <param name="stream">
/// Enable streaming response<br/>
/// Default Value: false
/// </param>
/// <param name="streamOptions">
/// Streaming configuration options
/// </param>
/// <param name="temperature">
/// Sampling temperature (0-2)
/// </param>
/// <param name="toolChoice">
/// Tool choice configuration
/// </param>
/// <param name="tools">
/// Available tools for function calling
/// </param>
/// <param name="topLogprobs">
/// Number of top log probabilities to return (0-20)
/// </param>
/// <param name="topP">
/// Nucleus sampling parameter (0-1)
/// </param>
/// <param name="trace">
/// 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.
/// </param>
/// <param name="user">
/// Unique user identifier
/// </param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::OpenRouter.CreatePresetFromInferenceResponse> CreatePresetsChatCompletionsAsync(
string slug,
global::System.Collections.Generic.IList<global::OpenRouter.ChatMessages> messages,
global::OpenRouter.AnthropicCacheControlDirective? cacheControl = default,
global::OpenRouter.ChatDebugOptions? debug = default,
double? frequencyPenalty = default,
global::OpenRouter.ImageConfig? imageConfig = default,
global::System.Collections.Generic.Dictionary<string, double>? logitBias = default,
bool? logprobs = default,
int? maxCompletionTokens = default,
int? maxTokens = default,
global::System.Collections.Generic.Dictionary<string, string>? metadata = default,
global::System.Collections.Generic.IList<global::OpenRouter.ChatRequestModalitiesItems>? modalities = default,
string? model = default,
global::System.Collections.Generic.IList<string>? models = default,
bool? parallelToolCalls = default,
global::System.Collections.Generic.IList<global::OpenRouter.ChatRequestPluginsItems>? plugins = default,
double? presencePenalty = default,
global::OpenRouter.ProviderPreferences? provider = default,
global::OpenRouter.ChatRequestReasoning? reasoning = default,
global::OpenRouter.ChatRequestResponseFormat? responseFormat = default,
object? route = default,
int? seed = default,
global::OpenRouter.OneOf<global::OpenRouter.ChatRequestServiceTier?, object>? serviceTier = default,
string? sessionId = default,
global::OpenRouter.ChatRequestStop? stop = default,
global::System.Collections.Generic.IList<global::OpenRouter.StopServerToolsWhenCondition>? stopServerToolsWhen = default,
bool? stream = default,
global::OpenRouter.ChatStreamOptions? streamOptions = default,
double? temperature = default,
global::OpenRouter.ChatToolChoice? toolChoice = default,
global::System.Collections.Generic.IList<global::OpenRouter.ChatFunctionTool>? tools = default,
int? topLogprobs = default,
double? topP = default,
global::OpenRouter.TraceConfig? trace = default,
string? user = default,
global::OpenRouter.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

#nullable enable

namespace OpenRouter
{
/// <summary>
/// If no httpClient is provided, a new one will be created.<br/>
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
public partial interface ISubpackagePresetsClient : global::System.IDisposable
{
/// <summary>
/// The HttpClient instance.
/// </summary>
public global::System.Net.Http.HttpClient HttpClient { get; }

/// <summary>
/// The base URL for the API.
/// </summary>
public System.Uri? BaseUri { get; }

/// <summary>
/// The authorizations to use for the requests.
/// </summary>
public global::System.Collections.Generic.List<global::OpenRouter.EndPointAuthorization> Authorizations { get; }

/// <summary>
/// Gets or sets a value indicating whether the response content should be read as a string.
/// True by default in debug builds, false otherwise.
/// When false, successful responses are deserialized directly from the response stream for better performance.
/// Error responses are always read as strings regardless of this setting,
/// ensuring <see cref="ApiException.ResponseBody"/> is populated.
/// </summary>
public bool ReadResponseAsString { get; set; }
/// <summary>
/// Client-wide request defaults such as headers, query parameters, retries, and timeout.
/// </summary>
public global::OpenRouter.AutoSDKClientOptions Options { get; }


/// <summary>
///
/// </summary>
global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; }


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class PresetWithDesignatedVersionStatusJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.PresetWithDesignatedVersionStatus>
{
/// <inheritdoc />
public override global::OpenRouter.PresetWithDesignatedVersionStatus Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::OpenRouter.PresetWithDesignatedVersionStatusExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::OpenRouter.PresetWithDesignatedVersionStatus)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::OpenRouter.PresetWithDesignatedVersionStatus);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.PresetWithDesignatedVersionStatus value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::OpenRouter.PresetWithDesignatedVersionStatusExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#nullable enable

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class PresetWithDesignatedVersionStatusNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.PresetWithDesignatedVersionStatus?>
{
/// <inheritdoc />
public override global::OpenRouter.PresetWithDesignatedVersionStatus? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::OpenRouter.PresetWithDesignatedVersionStatusExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::OpenRouter.PresetWithDesignatedVersionStatus)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::OpenRouter.PresetWithDesignatedVersionStatus?);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.PresetWithDesignatedVersionStatus? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::OpenRouter.PresetWithDesignatedVersionStatusExtensions.ToValueString(value.Value));
}
}
}
}
Loading