Vercel AI SDK for .NET
Unofficial community port of the Vercel AI SDK for server applications. It is an independent reimplementation of the public AI SDK behavior and provider HTTP APIs. It is not an official Vercel product.
Quickstart
Section titled “Quickstart”Install Vercel.AI and the provider package you call. OpenAIProvider.Create() reads OPENAI_API_KEY. GatewayProvider.Create() reads AI_GATEWAY_API_KEY.
using Vercel.AI;using Vercel.AI.OpenAI;
var model = OpenAIProvider.Create().LanguageModel("gpt-4.1-mini");var client = new AiClient(Vercel.AI.Gateway.GatewayProvider.Create(new() { ApiKey = "unused" }));var result = await client.GenerateTextAsync(new GenerateTextOptions{ Model = model, Instructions = "Answer in one sentence.", Prompt = "What is a language model specification?",});Console.WriteLine(result.Text);AiClient is only required for the high-level helpers. Pass Model when you already have an ILanguageModel. Pass ModelId (openai/gpt-4.1-mini) when the Gateway should resolve it.
In ASP.NET Core, services.AddAiSdk() registers IAiClient and a named HttpClient.
Guides
Section titled “Guides”QuickstartInstall the package and generate text.
ToolsLet the model call tools and read the results.
StreamingStream text, tool calls, and UI messages.
ProvidersGateway and direct provider calls.
SpeechStreaming speech.
TypeSafeTypeSafe decision models.
CompatibilityWhat this port includes.
API referenceGenerated from the Vercel.AI library.
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product