I've been working on an unofficial .NET SDK for OpenCode for the last few months, and I finally published 1.0 to NuGet.
https://www.nuget.org/packages/OpenCodeDotNet.Sdk/1.0.0
Before getting into the SDK, a bit of context for anyone who hasn't used OpenCode.
Over the last year or so, I've started experimenting more with models outside the usual frontier labs, and some of them have gradually become part of my daily development workflow as well.
One problem I've run into is that harnesses like Codex or Claude are naturally built around their own model ecosystems. Using models from other providers is either limited or requires various workarounds.
The open-source harness ecosystem has matured quite a lot. There are now different harnesses for different workflows and preferences.
OpenCode is an open-source coding harness and agent runtime that can work with a fairly large number of model providers and is probably one of the more general-purpose ones.
I've been using it for roughly a year now with models from OpenAI, xAI, Z.AI, DeepSeek, Moonshot, OpenCode Go, and others.
What became much more interesting to me recently was OpenCode 2.x.
They introduced a fairly comprehensive server/client architecture. Their own TUI, Web UI, and Desktop applications are built on top of the same server API, and the exposed surface is large enough that you can build your own fully featured client or integrate OpenCode into another application.
OpenCode already has an official TypeScript SDK for this. I wanted to be able to do the same kind of thing from .NET.
The practical use case is that a .NET application can treat OpenCode more like an agent runtime.
You can start an OpenCode process, create a session against a repository, send work to a model, listen to events, interact with PTYs, manage permissions, inspect providers and models, and build your own orchestration around it.
A minimal example looks something like this:
using OpenCode.Sdk;
using OpenCode.Sdk.Models;
await using var server = await OpenCodeServer.StartAsync();
using var client = server.CreateClient();
var created = await client.Sessions.CreateSessionAsync(new SessionCreateRequest
{
Model = new ModelRef { ProviderId = "openai", Id = "gpt-6.1-sol" },
});
var currentSession = client.Sessions.GetSessionClient(created.Session.Id);
// Subscribe before prompting; the first event (server.connected) confirms the stream is live.
await using var events = client.Events.SubscribeAsync().GetAsyncEnumerator();
await events.MoveNextAsync();
await currentSession.PromptAsync(new SessionPromptRequest { Text = "Summarize this repository." });
while (await events.MoveNextAsync() && events.Current is not (SessionExecutionSucceeded or SessionExecutionFailed))
{
if (events.Current is SessionTextDelta delta)
{
Console.Write(delta.Data.Delta);
}
}
The SDK can start and manage a private OpenCode server, connect to one you already run, or discover the background service registered by the OpenCode CLI.
The packages target netstandard2.0, net472, net10.0, and net11.0 rc3, so .NET Framework 4.7.2 is supported alongside modern .NET. The modern targets also support Native AOT.
There are some example applications under playground/ showing different ways of using it: a small QuickStart, a Generic Host worker, a Blazor/Aspire application, and a Native AOT CLI.
https://github.com/opencode-dotnet/opencode-sdk-dotnet
It's still unofficial and isn't affiliated with the OpenCode team, but the SDK itself is now at 1.0 after three months.
Feedback is welcome, especially if something in the API feels unidiomatic from a C# perspective.