![]() |
VOOZH | about |
dotnet add package MarketAlly.Replicate.Maui --version 1.5.0
NuGet\Install-Package MarketAlly.Replicate.Maui -Version 1.5.0
<PackageReference Include="MarketAlly.Replicate.Maui" Version="1.5.0" />
<PackageVersion Include="MarketAlly.Replicate.Maui" Version="1.5.0" />Directory.Packages.props
<PackageReference Include="MarketAlly.Replicate.Maui" />Project file
paket add MarketAlly.Replicate.Maui --version 1.5.0
#r "nuget: MarketAlly.Replicate.Maui, 1.5.0"
#:package MarketAlly.Replicate.Maui@1.5.0
#addin nuget:?package=MarketAlly.Replicate.Maui&version=1.5.0Install as a Cake Addin
#tool nuget:?package=MarketAlly.Replicate.Maui&version=1.5.0Install as a Cake Tool
π NuGet Version
π NuGet Downloads
π License: MIT
π .NET
π Platform
A production-ready .NET library for Replicate AI API integration. Generate AI images and videos using popular models like Stable Diffusion XL, HiDream, Google Veo 3, Kling, Luma Ray, and more.
| Model | Description |
|---|---|
| HiDream E1.1 | Fast high-quality image generation/editing |
| Stable Diffusion XL | Popular open-source image generation |
| Ideogram V3 Turbo | Best for images with realistic, legible text |
| Recraft V3 SVG | High-quality SVG images, logos, and icons |
| Model | Description |
|---|---|
| Google Veo 3 Fast | State-of-the-art video generation from Google |
| Kling 2.5 Turbo Pro | Latest high-quality video generation |
| Kling 1.6 Pro | Professional video generation |
| Seedance 1 Pro | High-quality video with image-to-video support |
| Luma Ray Flash 2 | Fast video generation with camera control |
| Wan 2.1 | Image-to-video with 480p/720p support |
| MiniMax Video 01 | Text and image to video generation |
dotnet add package MarketAlly.Replicate.Maui
Or via Package Manager:
Install-Package MarketAlly.Replicate.Maui
1. Configure in MauiProgram.cs:
using MarketAlly.Replicate.Maui;
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseReplicateMaui(settings =>
{
settings.ApiToken = "your-replicate-api-token";
});
return builder.Build();
}
2. Add the control to your XAML:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:replicate="clr-namespace:MarketAlly.Replicate.Maui.Controls;assembly=MarketAlly.Replicate.Maui">
<replicate:ReplicateTransformerView
x:Name="TransformerView"
LayoutMode="SideBySide"
TransformationCompleted="OnTransformationCompleted" />
</ContentPage>
3. Initialize and handle events:
using MarketAlly.Replicate.Maui;
using MarketAlly.Replicate.Maui.Controls;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
// Use a preset model
TransformerView.SetImagePreset(ModelPresets.HiDreamE1);
}
private void OnTransformationCompleted(object sender, TransformationCompletedEventArgs e)
{
// e.Result.Output contains the URL to the generated image/video
Console.WriteLine($"Result: {e.Result.Output}");
}
}
using MarketAlly.Replicate.Maui;
using Microsoft.Extensions.Options;
// Create transformer directly
var settings = Options.Create(new ReplicateSettings
{
ApiToken = "your-replicate-api-token"
});
using var httpClient = new HttpClient();
var transformer = new ReplicateTransformer(httpClient, settings);
// Use a model preset
var preset = ModelPresets.HiDreamE1;
var imageBytes = File.ReadAllBytes("input.jpg");
var result = await transformer.RunPresetAsync(
preset,
imageBytes,
customPrompt: "anime style portrait, studio ghibli inspired"
);
Console.WriteLine($"Status: {result.Status}");
Console.WriteLine($"Output: {result.Output}");
// In Program.cs or Startup.cs
services.Configure<ReplicateSettings>(options =>
{
options.ApiToken = Configuration["Replicate:ApiToken"];
});
services.AddHttpClient<IReplicateTransformer, ReplicateTransformer>();
// In your controller or service
public class ImageController : ControllerBase
{
private readonly IReplicateTransformer _transformer;
public ImageController(IReplicateTransformer transformer)
{
_transformer = transformer;
}
[HttpPost("generate")]
public async Task<IActionResult> Generate([FromBody] GenerateRequest request)
{
var result = await _transformer.RunPresetAsync(
ModelPresets.StableDiffusionXL,
Convert.FromBase64String(request.ImageBase64),
request.Prompt
);
return Ok(new { result.Output, result.Status });
}
}
Model presets provide pre-configured settings for popular models:
// Image Models
var hidream = ModelPresets.HiDreamE1;
var sdxl = ModelPresets.StableDiffusionXL;
var ideogram = ModelPresets.IdeogramV3Turbo;
var recraft = ModelPresets.RecraftV3Svg;
// Video Models
var veo = ModelPresets.GoogleVeo3Fast;
var kling = ModelPresets.Kling25TurboPro;
var seedance = ModelPresets.SeedancePro;
var luma = ModelPresets.LumaRayFlash;
// Get all presets
var allPresets = ModelPresets.All;
var imageModels = ModelPresets.ImageModels;
var videoModels = ModelPresets.VideoModels;
// Find by name
var preset = ModelPresets.FindByName("HiDream E1.1");
Override default preset parameters:
var customParams = new Dictionary<string, object>
{
{ "guidance_scale", 7.5 },
{ "num_inference_steps", 30 },
{ "seed", 42 }
};
var result = await transformer.RunPresetAsync(
ModelPresets.StableDiffusionXL,
imageBytes,
customPrompt: "cyberpunk cityscape",
customParameters: customParams
);
// Image only - no buttons (for custom UI)
TransformerView.LayoutMode = TransformerLayoutMode.ImageOnly;
// Buttons below the image (default)
TransformerView.LayoutMode = TransformerLayoutMode.ButtonsBelow;
// Overlay buttons on the image
TransformerView.LayoutMode = TransformerLayoutMode.ButtonsOverlay;
// Side-by-side source and result
TransformerView.LayoutMode = TransformerLayoutMode.SideBySide;
// Position overlay buttons at top or bottom
TransformerView.OverlayButtonPosition = OverlayButtonPosition.Top;
TransformerView.OverlayButtonPosition = OverlayButtonPosition.Bottom; // default
Built-in support for 8 languages:
// Enable localization
TransformerView.UseLocalization = true;
// Set language
ReplicateStrings.CurrentCulture = "es"; // Spanish
// Custom translations
ReplicateStrings.RegisterTranslations("es", new Dictionary<string, string>
{
[ReplicateStrings.Keys.Transform] = "Convertir",
[ReplicateStrings.Keys.GenerateVideo] = "Crear vΓdeo"
});
Supported languages: English (en), Spanish (es), French (fr), German (de), Chinese (zh), Japanese (ja), Portuguese (pt), Italian (it)
Customize button appearance:
// Configure individual buttons
TransformerView.ButtonConfigs.OverlaySelect.Text = "Choose Image";
TransformerView.ButtonConfigs.OverlaySelect.IconText = "π·";
TransformerView.ButtonConfigs.OverlayTransform.BackgroundColor = Colors.Purple;
// Set display mode
TransformerView.ButtonConfigs.DefaultDisplayMode = ButtonDisplayMode.Icon; // Icon only
TransformerView.ButtonConfigs.DefaultDisplayMode = ButtonDisplayMode.Label; // Text only
TransformerView.ButtonConfigs.DefaultDisplayMode = ButtonDisplayMode.Both; // Both (default)
Track prediction status in real-time:
// Enable tracking (enabled by default)
var tracker = new PredictionTracker(transformer);
// Subscribe to events
tracker.PredictionStatusChanged += (s, e) =>
{
Console.WriteLine($"Prediction {e.Prediction.Id}: {e.PreviousStatus} -> {e.NewStatus}");
};
tracker.PredictionCompleted += (s, e) =>
{
if (e.Succeeded)
Console.WriteLine($"Completed: {e.Prediction.Output}");
else
Console.WriteLine($"Failed: {e.Prediction.Error}");
};
// Access history
var history = tracker.History;
var pending = tracker.PendingPredictions;
Support multi-tenant scenarios where users provide their own API keys:
// Inject the factory
public class MyService
{
private readonly IReplicateTransformerFactory _factory;
public MyService(IReplicateTransformerFactory factory)
{
_factory = factory;
}
public async Task<string> GenerateForUser(string userApiKey, byte[] image)
{
// Create transformer with user's API key
var transformer = _factory.CreateWithToken(userApiKey);
var result = await transformer.RunPresetAsync(
ModelPresets.HiDreamE1,
image
);
return result.Output;
}
}
Use webhooks for long-running predictions:
var options = new PredictionOptions
{
WebhookUrl = "https://your-server.com/webhook/replicate",
WebhookEventsFilter = new[] { "completed" },
WebhookOnly = true // Don't poll, just return immediately
};
var result = await transformer.RunPresetAsync(
ModelPresets.GoogleVeo3Fast,
imageBytes,
options: options
);
// result.Id can be used to track the prediction
// Your webhook will receive the completion notification
| Event | Description |
|---|---|
ImageSelected |
Fired when user selects an image |
TransformationStarted |
Fired when transformation begins |
TransformationCompleted |
Fired when transformation succeeds |
TransformationError |
Fired when transformation fails |
PredictionTracked |
Fired when prediction status changes |
PredictionCompleted |
Fired when prediction completes |
FileSaved |
Fired when result is saved to file |
FileSaveError |
Fired when file save fails |
StateChanged |
Fired when control state changes |
ImageTapped |
Fired when image is tapped |
| Event | Description |
|---|---|
PredictionCreated |
Fired immediately when prediction is created (before polling) |
try
{
var result = await transformer.RunPresetAsync(preset, imageBytes);
if (result.IsFailed)
{
Console.WriteLine($"Prediction failed: {result.Error}");
}
else if (result.IsCanceled)
{
Console.WriteLine("Prediction was canceled");
}
else if (result.IsSucceeded)
{
Console.WriteLine($"Success: {result.Output}");
}
}
catch (ReplicateApiException ex)
{
Console.WriteLine($"API Error {ex.StatusCode}: {ex.Message}");
Console.WriteLine($"Response: {ex.ResponseBody}");
}
catch (ReplicateTransformationException ex)
{
Console.WriteLine($"Transformation Error: {ex.Message}");
}
This project is licensed under the MIT License - see the file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and feature requests, please use the GitHub Issues page.
Made with care by MarketAlly
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-android35.0 net9.0-android35.0 is compatible. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-ios18.0 net9.0-ios18.0 is compatible. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-maccatalyst18.0 net9.0-maccatalyst18.0 is compatible. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net9.0-windows10.0.19041 net9.0-windows10.0.19041 is compatible. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.5.0 | 594 | 12/11/2025 |
Version 1.5.0:
- Added net9.0 target for API-only usage (console apps, ASP.NET Core, Blazor)
- Changed namespace to MarketAlly.Replicate.Maui
- Added localization support for 8 languages (en, es, fr, de, zh, ja, pt, it)
- Added overlay button position control (Top/Bottom)
- Added PredictionCreated event for immediate prediction tracking
- Added Google Veo 3 Fast model preset
- Improved prediction history with real-time status updates