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 @@ -50,7 +50,7 @@ public partial interface ISubpackageVideoGenerationClient
/// Whether to generate audio alongside the video. Defaults to the endpoint's generate_audio capability flag, false if not set.
/// </param>
/// <param name="inputReferences">
/// Reference images to guide video generation
/// Reference assets to guide video generation. Accepts image, audio, and video references. Audio and video references are only honored by providers that support them (currently BytePlus Seedance 2.0); other providers use image references and ignore the rest.
/// </param>
/// <param name="model"></param>
/// <param name="prompt"></param>
Expand All @@ -77,7 +77,7 @@ public partial interface ISubpackageVideoGenerationClient
int? duration = default,
global::System.Collections.Generic.IList<global::OpenRouter.FrameImage>? frameImages = default,
bool? generateAudio = default,
global::System.Collections.Generic.IList<global::OpenRouter.ContentPartImage>? inputReferences = default,
global::System.Collections.Generic.IList<global::OpenRouter.InputReference>? inputReferences = default,
global::OpenRouter.VideoGenerationRequestProvider? provider = default,
global::OpenRouter.VideoGenerationRequestResolution? resolution = default,
int? seed = default,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#nullable enable
#pragma warning disable CS0618 // Type or member is obsolete

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public class InputReferenceJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.InputReference>
{
/// <inheritdoc />
public override global::OpenRouter.InputReference Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");


var readerCopy = reader;
var discriminatorTypeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.InputReferenceDiscriminator), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.InputReferenceDiscriminator> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::OpenRouter.InputReferenceDiscriminator)}");
var discriminator = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, discriminatorTypeInfo);

global::OpenRouter.InputReferenceVariant1? audioUrl = default;
if (discriminator?.Type == global::OpenRouter.InputReferenceDiscriminatorType.AudioUrl)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.InputReferenceVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.InputReferenceVariant1> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::OpenRouter.InputReferenceVariant1)}");
audioUrl = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
global::OpenRouter.InputReferenceVariant2? imageUrl = default;
if (discriminator?.Type == global::OpenRouter.InputReferenceDiscriminatorType.ImageUrl)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.InputReferenceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.InputReferenceVariant2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::OpenRouter.InputReferenceVariant2)}");
imageUrl = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
global::OpenRouter.InputReferenceVariant3? videoUrl = default;
if (discriminator?.Type == global::OpenRouter.InputReferenceDiscriminatorType.VideoUrl)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.InputReferenceVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.InputReferenceVariant3> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::OpenRouter.InputReferenceVariant3)}");
videoUrl = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}

var __value = new global::OpenRouter.InputReference(
discriminator?.Type,
audioUrl,

imageUrl,

videoUrl
);

return __value;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.InputReference value,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");

if (value.IsAudioUrl)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.InputReferenceVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.InputReferenceVariant1?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.InputReferenceVariant1).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.AudioUrl!, typeInfo);
}
else if (value.IsImageUrl)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.InputReferenceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.InputReferenceVariant2?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.InputReferenceVariant2).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.ImageUrl!, typeInfo);
}
else if (value.IsVideoUrl)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.InputReferenceVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.InputReferenceVariant3?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.InputReferenceVariant3).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.VideoUrl!, typeInfo);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class InputReferenceDiscriminatorTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.InputReferenceDiscriminatorType>
{
/// <inheritdoc />
public override global::OpenRouter.InputReferenceDiscriminatorType 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.InputReferenceDiscriminatorTypeExtensions.ToEnum(stringValue) ?? default;
}

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

return default;
}

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

writer.WriteStringValue(global::OpenRouter.InputReferenceDiscriminatorTypeExtensions.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 InputReferenceDiscriminatorTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.InputReferenceDiscriminatorType?>
{
/// <inheritdoc />
public override global::OpenRouter.InputReferenceDiscriminatorType? 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.InputReferenceDiscriminatorTypeExtensions.ToEnum(stringValue);
}

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

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.InputReferenceDiscriminatorType? 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.InputReferenceDiscriminatorTypeExtensions.ToValueString(value.Value));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class ContentPartImageTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.ContentPartImageType>
public sealed class InputReferenceVariant1TypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.InputReferenceVariant1Type>
{
/// <inheritdoc />
public override global::OpenRouter.ContentPartImageType Read(
public override global::OpenRouter.InputReferenceVariant1Type Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand All @@ -18,19 +18,19 @@ public sealed class ContentPartImageTypeJsonConverter : global::System.Text.Json
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::OpenRouter.ContentPartImageTypeExtensions.ToEnum(stringValue) ?? default;
return global::OpenRouter.InputReferenceVariant1TypeExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::OpenRouter.ContentPartImageType)numValue;
return (global::OpenRouter.InputReferenceVariant1Type)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::OpenRouter.ContentPartImageType);
return default(global::OpenRouter.InputReferenceVariant1Type);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
Expand All @@ -42,12 +42,12 @@ public sealed class ContentPartImageTypeJsonConverter : global::System.Text.Json
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.ContentPartImageType value,
global::OpenRouter.InputReferenceVariant1Type value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::OpenRouter.ContentPartImageTypeExtensions.ToValueString(value));
writer.WriteStringValue(global::OpenRouter.InputReferenceVariant1TypeExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class ContentPartImageTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.ContentPartImageType?>
public sealed class InputReferenceVariant1TypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.InputReferenceVariant1Type?>
{
/// <inheritdoc />
public override global::OpenRouter.ContentPartImageType? Read(
public override global::OpenRouter.InputReferenceVariant1Type? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand All @@ -18,19 +18,19 @@ public sealed class ContentPartImageTypeNullableJsonConverter : global::System.T
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::OpenRouter.ContentPartImageTypeExtensions.ToEnum(stringValue);
return global::OpenRouter.InputReferenceVariant1TypeExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::OpenRouter.ContentPartImageType)numValue;
return (global::OpenRouter.InputReferenceVariant1Type)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::OpenRouter.ContentPartImageType?);
return default(global::OpenRouter.InputReferenceVariant1Type?);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
Expand All @@ -42,7 +42,7 @@ public sealed class ContentPartImageTypeNullableJsonConverter : global::System.T
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.ContentPartImageType? value,
global::OpenRouter.InputReferenceVariant1Type? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));
Expand All @@ -53,7 +53,7 @@ public override void Write(
}
else
{
writer.WriteStringValue(global::OpenRouter.ContentPartImageTypeExtensions.ToValueString(value.Value));
writer.WriteStringValue(global::OpenRouter.InputReferenceVariant1TypeExtensions.ToValueString(value.Value));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class InputReferenceVariant2TypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.InputReferenceVariant2Type>
{
/// <inheritdoc />
public override global::OpenRouter.InputReferenceVariant2Type 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.InputReferenceVariant2TypeExtensions.ToEnum(stringValue) ?? default;
}

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

return default;
}

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

writer.WriteStringValue(global::OpenRouter.InputReferenceVariant2TypeExtensions.ToValueString(value));
}
}
}
Loading