AI Copilot
This module is in early access. APIs may change significantly.
Enterprise AI integration with a unified API across multiple providers. Built-in prompt safety and token budget management.
Why Use AI Copilot?
Integrating LLMs across different providers requires provider-specific code. AI Copilot provides a unified API for chat completions, embeddings, and structured outputs.
Supported Providers
Azure OpenAI
Enterprise-grade AI using Azure OpenAI and GitHub Models providers.
GitHub Models
Free tier AI access via GitHub token. Great for development.
Result Object
The IAIClient.ChatAsync() method returns a completion result with the following properties:
| Property | Type | Description |
|---|---|---|
Content | string | The generated text response |
Role | ChatRole | Role of the response (assistant, tool, etc.) |
TokensUsed | int | Total tokens consumed |
PromptTokens | int | Tokens in the input prompt |
CompletionTokens | int | Tokens in the generated response |
Model | string? | The model/deployment used |
FinishReason | string? | Why generation stopped (stop, length, etc.) |
ResponseId | string? | Provider response identifier |
Streaming Result
For StreamChatAsync(), each chunk contains:
| Property | Type | Description |
|---|---|---|
Content | string | Partial text content |
IsComplete | bool | Whether this is the final chunk |
FinishReason | string? | Stop reason if complete |
Embedding Result
For GetEmbeddingsAsync():
| Property | Type | Description |
|---|---|---|
Embeddings | float[][] | Vector representations |
Model | string | Embedding model used |
TokensUsed | int | Tokens consumed |
Key Features
- Unified API - Switch providers via configuration, not code
- Streaming - Real-time token-by-token responses
- Embeddings - Generate vectors for semantic search
- Structured Output - Parse JSON responses automatically
- Prompt Safety - Built-in injection detection
- Token Budgets - Per-tenant usage limits
Examples
Quick Install
# .NET
dotnet add package PrimusSaaS.AI
# Node.js
npm install @primus-saas/ai-client
Next Steps
| Want to... | See Guide | |------------|-----------|| | Get started quickly | Integration Guide | | Advanced configuration | Advanced |