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

# .NET SDK

> Install and use the Tuteliq .NET SDK

The Tuteliq .NET SDK provides an async client for the Tuteliq child safety API. It supports .NET 6.0+ and ships with full XML documentation and nullable reference type annotations.

## Installation

Install via NuGet:

```bash theme={"dark"}
dotnet add package Tuteliq
```

Or via the Package Manager Console:

```powershell theme={"dark"}
Install-Package Tuteliq
```

## Initialize the client

```csharp theme={"dark"}
using Tuteliq;

var tuteliq = new TuteliqClient("YOUR_API_KEY");
```

<Warning>
  Never hardcode API keys in source code. Use `IConfiguration`, user secrets, or a secrets manager.
</Warning>

```csharp theme={"dark"}
using Microsoft.Extensions.Configuration;

var config = new ConfigurationBuilder()
    .AddUserSecrets<Program>()
    .Build();

var tuteliq = new TuteliqClient(config["Tuteliq:ApiKey"]);
```

## Detect unsafe content

Scan a single text input for harmful content across all KOSA categories.

```csharp theme={"dark"}
var result = await tuteliq.DetectUnsafeAsync(
    text: "Let's meet at the park after school, don't tell your parents",
    ageGroup: AgeGroup.TenToTwelve
);

Console.WriteLine(result.Safe);        // false
Console.WriteLine(result.Severity);    // Severity.High
Console.WriteLine(result.Categories);  // [Category.Grooming, Category.Secrecy]
```

## Detect grooming patterns

Analyze a conversation history for grooming indicators.

```csharp theme={"dark"}
var result = await tuteliq.DetectGroomingAsync(
    messages: new[]
    {
        new Message(Role.Stranger, "Hey, how old are you?"),
        new Message(Role.Child, "I'm 11"),
        new Message(Role.Stranger, "Cool. Do you have your own phone?"),
        new Message(Role.Stranger, "Let's talk on a different app, just us"),
    },
    ageGroup: AgeGroup.TenToTwelve
);

Console.WriteLine(result.GroomingDetected); // true
Console.WriteLine(result.RiskScore);        // 0.92
Console.WriteLine(result.Stage);            // GroomingStage.Isolation
```

## Analyze emotions

Evaluate emotional well-being from conversation text.

```csharp theme={"dark"}
var result = await tuteliq.AnalyzeEmotionsAsync(
    text: "Nobody at school talks to me anymore. I just sit alone every day.",
    ageGroup: AgeGroup.ThirteenToFifteen
);

Console.WriteLine(result.Emotions);   // [Emotion { Label = "sadness", Score = 0.87 }, ...]
Console.WriteLine(result.Distress);   // true
Console.WriteLine(result.RiskLevel);  // RiskLevel.Elevated
```

## Analyze voice

Upload an audio file for transcription and safety analysis.

```csharp theme={"dark"}
var audioBytes = await File.ReadAllBytesAsync("recording.wav");

var result = await tuteliq.AnalyzeVoiceAsync(
    file: audioBytes,
    ageGroup: AgeGroup.ThirteenToFifteen
);

Console.WriteLine(result.Transcript);
Console.WriteLine(result.Safe);
Console.WriteLine(result.Emotions);
```

## Fraud detection

Detect financial exploitation, social engineering, and scam patterns targeting minors. Other methods — `DetectAppFraudAsync`, `DetectMuleRecruitmentAsync` — follow the same pattern.

### Detect social engineering

```csharp theme={"dark"}
var result = await tuteliq.DetectSocialEngineeringAsync(
    text: "If you really trusted me you'd send me your home address. All my real friends do.",
    ageGroup: AgeGroup.TenToTwelve
);

Console.WriteLine(result.Detected);    // true
Console.WriteLine(result.RiskScore);   // 0.88
Console.WriteLine(result.Level);       // "high"
Console.WriteLine(result.Categories);  // [{ Tag = "TRUST_EXPLOITATION", ... }]
```

### Detect romance scam

```csharp theme={"dark"}
var result = await tuteliq.DetectRomanceScamAsync(
    text: "I've never felt this way about anyone before. You're so mature for your age. Keep us a secret.",
    ageGroup: AgeGroup.ThirteenToFifteen
);

Console.WriteLine(result.Detected);   // true
Console.WriteLine(result.RiskScore);  // 0.91
```

## Safety extended

Detect extended safety threats including gambling harm, coercive control, vulnerability exploitation, and radicalisation.

### Detect vulnerability exploitation

```csharp theme={"dark"}
var result = await tuteliq.DetectVulnerabilityExploitationAsync(
    text: "I know you said your parents don't listen to you. I'm different — I actually care.",
    ageGroup: AgeGroup.ThirteenToFifteen
);

Console.WriteLine(result.Detected);   // true
Console.WriteLine(result.RiskScore);  // 0.85
```

### Detect radicalisation

```csharp theme={"dark"}
var result = await tuteliq.DetectRadicalisationAsync(
    text: "They're all against us. Only our group understands the truth. Are you ready to act?",
    ageGroup: AgeGroup.ThirteenToFifteen
);

Console.WriteLine(result.Detected);   // true
Console.WriteLine(result.Level);      // "high"
```

## Multi-endpoint analysis

Run multiple detection endpoints on a single text in one API call.

```csharp theme={"dark"}
var result = await tuteliq.AnalyseMultiAsync(
    text: "You're so special. Nobody else understands you like I do. Send me a photo.",
    detections: new[] { Detection.SocialEngineering, Detection.Grooming, Detection.RomanceScam },
    ageGroup: AgeGroup.ThirteenToFifteen
);

Console.WriteLine(result.Summary.OverallRiskLevel);  // "high"
Console.WriteLine(result.Summary.DetectedCount);     // 2

foreach (var r in result.Results)
{
    Console.WriteLine($"{r.Endpoint}: {r.Detected} (risk: {r.RiskScore})");
}
```

<Info>
  `AnalyseMultiAsync` is billed per individual detection endpoint, not per request.
</Info>

## Analyze video

Upload a video file for frame-by-frame safety analysis.

```csharp theme={"dark"}
var videoBytes = await File.ReadAllBytesAsync("clip.mp4");

var result = await tuteliq.AnalyzeVideoAsync(
    file: videoBytes,
    filename: "clip.mp4",
    ageGroup: AgeGroup.ThirteenToFifteen
);

Console.WriteLine(result.FramesAnalyzed);
Console.WriteLine(result.OverallRiskScore);

foreach (var finding in result.SafetyFindings)
{
    Console.WriteLine($"Frame {finding.FrameIndex}: {finding.Description} ({finding.Severity})");
}
```

## Dependency injection

<Info>
  The SDK provides extension methods for `IServiceCollection` to integrate with ASP.NET Core dependency injection.
</Info>

```csharp theme={"dark"}
// Program.cs or Startup.cs
builder.Services.AddTuteliq(options =>
{
    options.ApiKey = builder.Configuration["Tuteliq:ApiKey"];
    options.Timeout = TimeSpan.FromSeconds(30);
    options.Retries = 2;
});
```

Then inject `ITuteliqClient` into your controllers or services:

```csharp theme={"dark"}
public class ModerationService
{
    private readonly ITuteliqClient _tuteliq;

    public ModerationService(ITuteliqClient tuteliq)
    {
        _tuteliq = tuteliq;
    }

    public async Task<bool> IsContentSafe(string text, AgeGroup ageGroup)
    {
        var result = await _tuteliq.DetectUnsafeAsync(text, ageGroup);
        return result.Safe;
    }
}
```

## Error handling

The SDK throws typed exceptions that you can catch and inspect.

```csharp theme={"dark"}
using Tuteliq;

try
{
    var result = await tuteliq.DetectUnsafeAsync(
        text: "some content",
        ageGroup: AgeGroup.TenToTwelve
    );
}
catch (TuteliqException ex)
{
    Console.WriteLine(ex.Code);    // e.g. "AUTH_INVALID_KEY"
    Console.WriteLine(ex.Message); // human-readable description
    Console.WriteLine(ex.Status);  // HTTP status code
}
```

## Configuration options

```csharp theme={"dark"}
var tuteliq = new TuteliqClient(new TuteliqOptions
{
    ApiKey = config["Tuteliq:ApiKey"],
    BaseUrl = "https://api.tuteliq.ai",       // default
    Timeout = TimeSpan.FromSeconds(30),        // request timeout
    Retries = 2                                // automatic retries on failure
});
```

## Next steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore the full API specification.
  </Card>

  <Card title="Node.js SDK" icon="node-js" href="/sdks/node">
    See the Node.js SDK guide.
  </Card>
</CardGroup>
