---
title: "Instrument .NET agents | Grafana Cloud documentation"
description: "Install the AI Observability .NET SDK and capture your first generation from a C# agent."
---

# Instrument .NET agents

This guide shows you how to install the AI Observability .NET SDK, instrument an LLM call, and verify that generation data reaches AI Observability.

> Note
> 
> AI Observability is referred to as “Sigil” in SDKs, package names, and configuration. For example, the NuGet package is `Grafana.Sigil`.

## Before you begin

- A running AI Observability instance or Grafana Cloud stack with AI Observability enabled.
- .NET 8 or later.
- Your AI Observability generation export endpoint URL.
- A Cloud Access Policy Token with the `sigil:write` scope. Refer to [Create an API key](/docs/grafana-cloud/machine-learning/ai-observability/get-started/grafana-cloud/#create-an-api-key) for step-by-step instructions.

## Install the SDK

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
dotnet add package Grafana.Sigil
```

Provider helpers are in separate packages:

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
dotnet add package Grafana.Sigil.OpenAI
dotnet add package Grafana.Sigil.Anthropic
dotnet add package Grafana.Sigil.Gemini
```

## Capture a generation

csharp ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```csharp
var sigil = new SigilClient(new SigilClientConfig
{
    GenerationExport = new GenerationExportConfig
    {
        Protocol = GenerationExportProtocol.Http,
        Endpoint = "<SIGIL_ENDPOINT>/api/v1/generations:export",
        Auth = new AuthConfig
        {
            Mode = ExportAuthMode.Tenant,
            TenantId = "<TENANT_ID>",
        },
    },
});

// Use provider helpers for automatic capture, for example with OpenAI:
var response = await OpenAIRecorder.CreateResponseAsync(
    sigil,
    openAIClient,
    inputItems,
    options: new OpenAISigilOptions
    {
        ConversationId = "conv-1",
        AgentName = "my-agent",
    }
);

await sigil.ShutdownAsync(CancellationToken.None);
```

Replace *SIGIL\_ENDPOINT* and *TENANT\_ID* with your values.

## Configure authentication

For Grafana Cloud, use basic auth with your Cloud Access Policy Token:

csharp ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```csharp
Auth = new AuthConfig
{
    Mode = ExportAuthMode.Basic,
    TenantId = "<INSTANCE_ID>",
    BasicPassword = "<API_KEY>",
}
```

## Set up traces and metrics

The SDK emits OpenTelemetry spans and metrics alongside generation data. To export them, configure a `TracerProvider` and `MeterProvider` in your application before creating the Sigil client. Without this, traces and metrics are silently lost.

Refer to [Set up traces and metrics](/docs/grafana-cloud/machine-learning/ai-observability/get-started/grafana-cloud/#set-up-traces-and-metrics) for Grafana Cloud OTLP options and [SDK configuration](/docs/grafana-cloud/machine-learning/ai-observability/configure/sdk/#opentelemetry-setup) for setup snippets.

## Verify data

Open the AI Observability plugin in Grafana and navigate to **Conversations**. Your generation should appear within a few seconds. Check your **Traces** and **Metrics** data sources for SDK-emitted spans and metrics.

## Next steps

- [Configure SDK options](/docs/grafana-cloud/machine-learning/ai-observability/configure/sdk)
- [Instrument with framework integrations](/docs/grafana-cloud/machine-learning/ai-observability/guides/instrument-agents)
