AI

Setup and Task Configuration

Methods for configuring the AI provider, task type, classification, and credentials before executing an AI operation.

Methods for configuring the AI provider, task type, classification, and credentials before executing an AI operation.

WithCredentials supplies the API credentials for the AI provider. WithProvider sets the AI provider name (e.g., 'OpenAI', 'Anthropic'). WithTask sets the AI operation type using the AITask enum - values include classification, summarization, extraction, and others. WithTaskConfig passes a ClassificationConfig object with detailed task parameters. WithClassificationType sets a specific classification category using AIClassificationType. WithCustomClassification provides a fully custom ClassificationConfig for advanced use cases.

Examples

GPAL Fluent: High-level fluent C# API

//The AI subsystem is a pipeline: configure credentials and task, set the input, set the output target, then Execute. WithCredentials accepts any ICredentials - build the credentials object with GPAL.Credentials. WithUsername/WithPassword unlock the LastPass vault, and WithServiceKey carries the OpenAI API key. WithProvider is a separate setting that names the AI service itself (e.g. 'OpenAI', 'Anthropic').

// Configure AI for text classification GPAL.Ai .WithCredentials(GPAL.CredentialsFor(CredentialServiceType.LastPass) .WithUsername("you@example.com") .WithPassword("your-master-password") .WithServiceKey("sk-...") .ToGPALObject()) .WithProvider(AIProviderType.OpenAI) .WithTask(AITask.Classification) .WithClassificationType(AIClassificationType.Sentiment) .WithInputFrom("The product was excellent and arrived on time.") .WithOutputTo(out var result) .Execute();