Skip to main content
You can use the Openlayer C# / .NET SDK to interact with the Openlayer platform. It supports .NET 8+ and any netstandard2.0 runtime, including .NET Framework 4.6.2+.

Install

You can install the Openlayer package from NuGet:

Usage

The client reads your API key from the OPENLAYER_API_KEY environment variable. The methods follow the REST paths of the API reference.
To use a self-hosted deployment, set the OPENLAYER_BASE_URL environment variable or pass OpenlayerClientOptions.BaseUrl.

Tracing

The Openlayer.Tracing namespace traces your LLM app. Each request becomes a trace in your inference pipeline, with the same columns as the Python and TypeScript SDKs. Set OPENLAYER_API_KEY and OPENLAYER_INFERENCE_PIPELINE_ID, then:
  • Wrap your functions with Tracer.TraceAsync(name, inputs, fn). Steps nest by async flow, so concurrent requests are separate traces.
  • Call .WithOpenlayerTracing() on any Microsoft.Extensions.AI IChatClient (OpenAI, Azure OpenAI, Ollama, …) to record each LLM call with its model, tokens and parameters.
  • Call await Tracer.FlushAsync() before a short-lived process exits.
See Instrument your code for a full example.

Learn more

To learn more about the Openlayer C# / .NET SDK, check out the GitHub repository:

SDK GitHub repository

Check out the source code of the C# / .NET SDK.