> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C# / .NET

> Use the Openlayer C# / .NET SDK to interact with the Openlayer platform

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**:

```bash theme={null}
dotnet add package Openlayer
```

## Usage

The client reads your API key from the `OPENLAYER_API_KEY` environment variable. The methods follow the REST paths of the [API reference](https://docs.openlayer.com/api-reference/rest/overview.md).

```csharp theme={null}
using Openlayer;
using Openlayer.Api.InferencePipelines.Item.DataStream;
using Openlayer.Api.Models;

var client = new OpenlayerClient(); // reads OPENLAYER_API_KEY

var response = await client.InferencePipelines[pipelineId].DataStream.PostAsync(new DataStreamPostRequestBody
{
    Config = new DataStreamPostRequestBody.DataStreamPostRequestBody_config
    {
        LLMData = new LLMData
        {
            InputVariableNames = new() { "user_query" },
            OutputColumnName = "output",
            NumOfTokenColumnName = "tokens",
            CostColumnName = "cost",
            TimestampColumnName = "timestamp",
        },
    },
    Rows = new()
    {
        new DataStreamPostRequestBody_rows
        {
            AdditionalData = new Dictionary<string, object>
            {
                ["user_query"] = "what is the meaning of life?",
                ["output"] = "42",
                ["tokens"] = 7,
                ["cost"] = 0.02,
                ["timestamp"] = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
            },
        },
    },
});
```

To use a self-hosted deployment, set the `OPENLAYER_BASE_URL` environment variable or pass `OpenlayerClientOptions.BaseUrl`.

## Learn more

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

> [card] [SDK GitHub repository](https://github.com/openlayer-ai/openlayer-csharp)
>
> Check out the source code of the C# / .NET SDK.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.