Vercel AI SDK for .NET
Call any model
from C#.
A provider-agnostic toolkit for text, structured data, tools, and agents. A model id such as openai/gpt-6-astra goes to the Vercel AI Gateway. Or call OpenAI, Anthropic, and Google directly.
Unofficial community port of the Vercel AI SDK. Not an official Vercel product.
dotnet add package Vercel.AIOne package. It targets net10.0 and netstandard2.0.Vercel.AI on NuGet.
using Vercel.AI;
using Vercel.AI.Gateway;
var client = new AiClient(GatewayProvider.Create());
var result = await client.GenerateTextAsync(
new GenerateTextOptions
{
ModelId = "openai/gpt-6-astra",
// use Vercel AI Gateway
Prompt = "What is an agent?",
});
Console.WriteLine(result.Text);Package
Vercel.AI
Every provider, one package
Targets
net10.0
and netstandard2.0
Parity
AI SDK 7
Language Model spec V4
License
Apache-2.0
Free for commercial use
Why this SDK
The same ideas as the AI SDK, in the C# you already write.
Gateway or a provider
Pass
ProvidersModelIdand the Gateway resolves it. PassModelwhen you already have anILanguageModelfrom OpenAI, Anthropic, Google, and the other providers in this package.Tools and agents
ToolsTool.Functiongives the model a JSON schema and anExecutedelegate.Agentruns that loop with instructions and tools.Stream the reply
StreamingStreamTextAsyncreturns immediately. ReadTextStreamfor deltas.ToUIMessageStreamResultwrites the events a JavaScriptuseChatclient already reads.JSON that matches a schema
OutputSpecOutputSpec.Objecttakes a JSON schema.GenerateTextAsyncparses the reply intoresult.Output.
Get started
From an empty project to a first reply, in three steps.
Install the package, call a model, then stream the reply or hand the model a tool. Each step links to the page that has the rest.
Read the quickstartInstall the package
Add
Vercel.AIto a project that targetsnet10.0ornetstandard2.0. Every provider ships in this package.
Quickstartdotnet add package Vercel.AICall a model
GatewayProvider.Create()readsAI_GATEWAY_API_KEY. A string model id goes to the Gateway. PassModelto call a provider directly.
Generate textvar client = new AiClient(GatewayProvider.Create());