> For the complete documentation index, see [llms.txt](https://docs.pal.aic.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pal.aic.io/getting-started.md).

# Getting started

This walkthrough registers PAL.NET, supplies an access-token provider, and executes a generated operation. The application can be an ASP.NET Core service, worker, console application, Azure Function, or another .NET host with `Microsoft.Extensions.DependencyInjection`.

{% stepper %}
{% step %}

## Add the runtime projects

For a source checkout, the minimum runtime references are:

```xml
<ItemGroup>
  <ProjectReference Include="..\\PAL.Core.Models.Domain\\PAL.Core.Models.Domain.csproj" />
  <ProjectReference Include="..\\PAL.Core.Services.Domain\\PAL.Core.Services.Domain.csproj" />
  <ProjectReference Include="..\\PAL.Core.Services.Compatibility\\PAL.Core.Services.Compatibility.csproj" />
  <ProjectReference Include="..\\PAL.Core.Services.Generation\\PAL.Core.Services.Generation.csproj" />
</ItemGroup>
```

The generated platform clients are compiled into `PAL.Core.Services.Domain`. In a packaged application, consume the authorised PAL.NET package set instead of copying generated files into the application.

Add only the higher-level packages you use:

| Need                                   | PAL.NET project               | Registration                     |
| -------------------------------------- | ----------------------------- | -------------------------------- |
| Generated platform operations          | `PAL.Core.Services.Domain`    | `AddPalantirGeneratedPlatform()` |
| Ontology runtime                       | `PAL.Core.Services.Ontology`  | `AddPalantirOntology()`          |
| Dataset metadata and table streams     | `PAL.Core.Services.Datasets`  | `AddPalantirDatasets()`          |
| SQL query lifecycle and result streams | `PAL.Core.Services.Sql`       | `AddPalantirSql()`               |
| AIP Agent sessions                     | `PAL.Core.Services.AipAgents` | `AddPalantirAipAgents()`         |
| {% endstep %}                          |                               |                                  |

{% step %}

## Register the runtime

```csharp
using Microsoft.Extensions.DependencyInjection;
using PAL.Core.Models.Domain.Contracts;
using PAL.Core.Services.Domain.Extensions;
using PAL.Core.Services.Domain.Generated.Platform;
using PAL.Core.Services.Ontology.Extensions;

var services = new ServiceCollection();

services.AddPalantir(new PalantirClientOptions
{
    BaseAddress = new Uri("https://customer.palantircloud.com/"),
    ApiVersion = "v2",
    DefaultScopes = ["api:read"],
    RequestTimeout = TimeSpan.FromSeconds(100)
});

services.AddPalantirGeneratedPlatform();
services.AddPalantirOntology();

// Replace the default fail-closed token provider with your approved provider.
services.AddScoped<IPalantirAccessTokenProvider, MyAccessTokenProvider>();

var provider = services.BuildServiceProvider();
```

`AddPalantir` validates local options and registers the transport pipeline. It does not contact Palantir, request a token, read a licence file, or perform hidden network work.
{% endstep %}

{% step %}

## Use a higher-level client

```csharp
using PAL.Core.Services.Ontology.Contracts;

await using var scope = provider.CreateAsyncScope();
var ontology = scope.ServiceProvider.GetRequiredService<IPalOntologyClient>();

var page = await ontology.ListObjectsAsync(
    ontology: "my-ontology",
    objectType: "employee",
    new PalOntologyListOptions
    {
        PageSize = 100,
        Select = ["employeeId", "displayName"],
        OrderBy = "displayName"
    },
    cancellationToken);

foreach (var item in page.Items)
    Console.WriteLine(item.PrimaryKey);
```

{% endstep %}

{% step %}

## Use generated platform clients

Generated clients are registered as scoped services. Each capability has a generated client and a generated operation catalog. The exact method names and request models are generated from the pinned compatibility source, so use IntelliSense or the generated source for the operation you need.

```csharp
using PAL.Core.Services.Domain.Generated.Platform;

var admin = scope.ServiceProvider.GetRequiredService<AdminPlatformClient>();
var request = EnrollmentGetCurrentEnrollmentRequest
    .CreateBuilder()
    .Build();

var enrollment = await admin.EnrollmentGetCurrentEnrollmentAsync(request, cancellationToken);
```

The generated layer applies authentication, licensing, scopes, cancellation, retries, error mapping, diagnostics, pagination, and streaming through the shared PAL.NET pipeline.
{% endstep %}

{% step %}

## Dispose streamed results

Any method returning a `PalantirStreamingResponse`, `PalDatasetTable`, or `PalSqlQueryResult` owns an upstream response and its stream. Consume it inside `using` or `await using`:

```csharp
await using var table = await datasets.ReadTableAsync(request, cancellationToken);
await table.Data.CopyToAsync(outputStream, cancellationToken);
```

{% endstep %}
{% endstepper %}

## First-run checklist

* `BaseAddress` is an absolute HTTPS enrollment URL.
* The token provider is registered and can request the operation's scopes.
* The licence guard is configured with an approved entitlement.
* The API version and capability are supported by the release baseline.
* The caller's upstream identity has permission for the requested resource.
* Cancellation tokens flow from the host request or job lifetime.
