r/moderndotnet • u/denizirgin • 23d ago
OpenCode .NET SDK reached 1.0
A few months ago, I shared an early version of my unofficial OpenCode .NET SDK here:
https://www.reddit.com/r/moderndotnet/comments/1wg1r6g/net_sdk_for_opencodes_server_api/
For anyone unfamiliar with OpenCode, it's an open-source coding agent/harness with a server API underneath its TUI, desktop, and web clients. That API lets you use OpenCode more like an agent runtime from another application.
That was why I started working on the .NET SDK.
Today I finally released 1.0.
The SDK currently covers 166 of the 169 operations in the pinned OpenCode 2.x API.
It supports modern .NET as well as .NET Framework 4.7.2, with packages targeting netstandard2.0, net472, net10.0, and net11.0. The modern targets also support Native AOT.
There are a few small applications under playground showing different ways of using it, including a minimal QuickStart, a Worker using the Generic Host, a Blazor/Aspire example, and a Native AOT CLI.
A basic example is roughly:
await using var server = await OpenCodeServer.StartAsync();
using var client = server.CreateClient();
var created = await client.Sessions.CreateSessionAsync(
new SessionCreateRequest { Title = "hello from .NET" });
Console.WriteLine($"session {created.Session.Id}");The SDK can start its own private OpenCode server like above, connect to one you already run, or discover the background service registered by the OpenCode CLI.
NuGet:
dotnet add package OpenCodeDotNet.Sdk
2
u/Anon4573 23d ago
How is this useful compared to using the agent client protocol?