⭐Gradio for .NET – a port of Gradio, an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitrary Python function. Gradio for .NET – 基于 Gradio 的 .NET 移植,Gradio 是一个开源 Python 包,允许你为机器学习模型、API 或任何任意 Python 函数快速构建演示或 Web 应用程序。
JavaScript
335
56 commits
updated Jul 19, 2026
For more information, see the Guides.
Gradio for .NET – a port of Gradio, an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitrary Python function. No JavaScript, CSS, or web hosting experience needed!

It just takes a few lines of .NET code to create a beautiful demo like the one above, so let's get started 💫
Program.cs:gr.Interface (quickest way)using Gradio.Net;
string Greet(string name, double intensity)
{
return "Hello, " + name + "!" + new string('!', (int)intensity - 1);
}
var demo = gr.Interface(
fn: Greet,
inputs: new object[] { "text", gr.Slider(value: 2, minimum: 1, maximum: 10, step: 1) },
outputs: new[] { "text" }
);
await demo.Launch();
gr.Interface wraps any C# function into a UI in seconds — no layout code required.
gr.Blocks (full layout control)using Gradio.Net;
await (await CreateBlocks()).Launch();
async Task<Blocks> CreateBlocks()
{
using (var blocks = gr.Blocks())
{
gr.Markdown("Start typing below and then click **Run** to see the output.");
Textbox input, output;
using (gr.Row())
{
input = gr.Textbox(placeholder: "What is your name?");
output = gr.Textbox();
}
var btn = gr.Button("Run");
btn.Click(
fn: new Func<string, (string, string)>(name => ($"Welcome to Gradio.Net, {name}!", "")),
inputs: new[] { input },
outputs: new[] { output, input });
return blocks;
}
}
That's All 🎉🎉🎉
Use the AddGradio and UseGradio extension methods:
using Gradio.Net;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGradio();
var app = builder.Build();
app.UseGradio(await CreateBlocks());
app.Run();
async Task<Blocks> CreateBlocks()
{
using (var blocks = gr.Blocks())
{
gr.Markdown("# My Gradio App");
Textbox input, output;
using (gr.Row())
{
input = gr.Textbox(placeholder: "What is your name?");
output = gr.Textbox();
}
var btn = gr.Button("Run");
btn.Click(
fn: new Func<string, (string, string)>(name => ($"Welcome to Gradio.Net, {name}!", "")),
inputs: new[] { input },
outputs: new[] { output, input });
return blocks;
}
}
You can also use gr.Interface with app.UseGradio:
using Gradio.Net;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGradio();
var app = builder.Build();
string Greet(string name, double intensity)
{
return "Hello, " + name + "!" + new string('!', (int)intensity - 1);
}
var demo = gr.Interface(
fn: Greet,
inputs: new object[] { "text", gr.Slider(value: 2, minimum: 1, maximum: 10, step: 1) },
outputs: new[] { "text" }
);
app.UseGradio(await demo.BuildBlocks());
app.Run();
45 followers · starred Mar 2025
JavaScript
75.9%
C#
24.0%
⭐Gradio for .NET – a port of Gradio, an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitrary Python function. Gradio for .NET – 基于 Gradio 的 .NET 移植,Gradio 是一个开源 Python 包,允许你为机器学习模型、API 或任何任意 Python 函数快速构建演示或 Web 应用程序。
JavaScript
335
56 commits
updated Jul 19, 2026
For more information, see the Guides.
Gradio for .NET – a port of Gradio, an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitrary Python function. No JavaScript, CSS, or web hosting experience needed!

It just takes a few lines of .NET code to create a beautiful demo like the one above, so let's get started 💫
Program.cs:gr.Interface (quickest way)using Gradio.Net;
string Greet(string name, double intensity)
{
return "Hello, " + name + "!" + new string('!', (int)intensity - 1);
}
var demo = gr.Interface(
fn: Greet,
inputs: new object[] { "text", gr.Slider(value: 2, minimum: 1, maximum: 10, step: 1) },
outputs: new[] { "text" }
);
await demo.Launch();
gr.Interface wraps any C# function into a UI in seconds — no layout code required.
gr.Blocks (full layout control)using Gradio.Net;
await (await CreateBlocks()).Launch();
async Task<Blocks> CreateBlocks()
{
using (var blocks = gr.Blocks())
{
gr.Markdown("Start typing below and then click **Run** to see the output.");
Textbox input, output;
using (gr.Row())
{
input = gr.Textbox(placeholder: "What is your name?");
output = gr.Textbox();
}
var btn = gr.Button("Run");
btn.Click(
fn: new Func<string, (string, string)>(name => ($"Welcome to Gradio.Net, {name}!", "")),
inputs: new[] { input },
outputs: new[] { output, input });
return blocks;
}
}
That's All 🎉🎉🎉
Use the AddGradio and UseGradio extension methods:
using Gradio.Net;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGradio();
var app = builder.Build();
app.UseGradio(await CreateBlocks());
app.Run();
async Task<Blocks> CreateBlocks()
{
using (var blocks = gr.Blocks())
{
gr.Markdown("# My Gradio App");
Textbox input, output;
using (gr.Row())
{
input = gr.Textbox(placeholder: "What is your name?");
output = gr.Textbox();
}
var btn = gr.Button("Run");
btn.Click(
fn: new Func<string, (string, string)>(name => ($"Welcome to Gradio.Net, {name}!", "")),
inputs: new[] { input },
outputs: new[] { output, input });
return blocks;
}
}
You can also use gr.Interface with app.UseGradio:
using Gradio.Net;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGradio();
var app = builder.Build();
string Greet(string name, double intensity)
{
return "Hello, " + name + "!" + new string('!', (int)intensity - 1);
}
var demo = gr.Interface(
fn: Greet,
inputs: new object[] { "text", gr.Slider(value: 2, minimum: 1, maximum: 10, step: 1) },
outputs: new[] { "text" }
);
app.UseGradio(await demo.BuildBlocks());
app.Run();
45 followers · starred Mar 2025
JavaScript
75.9%
C#
24.0%