Mythosia.AI.Abstractions 3.0.0

dotnet add package Mythosia.AI.Abstractions --version 3.0.0
                    
NuGet\Install-Package Mythosia.AI.Abstractions -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mythosia.AI.Abstractions" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mythosia.AI.Abstractions" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Mythosia.AI.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mythosia.AI.Abstractions --version 3.0.0
                    
#r "nuget: Mythosia.AI.Abstractions, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mythosia.AI.Abstractions@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mythosia.AI.Abstractions&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Mythosia.AI.Abstractions&version=3.0.0
                    
Install as a Cake Tool

Mythosia.AI.Abstractions

Core contracts and shared models for the Mythosia.AI ecosystem. Defines IAIService, the optional IImageGenerationService capability, provider-neutral model types, and streaming primitives. Consumed by Mythosia.AI.Rag and any library that needs the AI service contract without pulling in heavy provider implementations.

Upgrading to v3? This is the abstractions release paired with Mythosia.AI v7. See the v3.0 release notes and migration guide.

Installation

dotnet add package Mythosia.AI.Abstractions

Install this package directly only when writing a library that depends on the AI service contract (e.g., RAG orchestration, custom middleware). Applications normally take a transitive dependency through Mythosia.AI.


Core Interface

IAIService

The central abstraction for AI completion and streaming.

public interface IAIService
{
    string Model { get; }
    string Provider { get; }
    string SystemMessage { get; set; }
    bool StatelessMode { get; set; }
    ChatBlock ActivateChat { get; }

    Task<string> GetCompletionAsync(
        string prompt,
        AIRequestProfile? profile = null,
        AIRequestContext? context = null);

    Task<string> GetCompletionAsync(
        Message message,
        AIRequestProfile? profile = null,
        AIRequestContext? context = null);

    IAsyncEnumerable<string> StreamAsync(string prompt, CancellationToken ct = default);
    IAsyncEnumerable<string> StreamAsync(
        Message message,
        AIRequestContext? context = null,
        CancellationToken ct = default);

    IAsyncEnumerable<StreamingContent> StreamAsync(
        string prompt,
        StreamOptions options,
        CancellationToken ct = default);

    IAsyncEnumerable<StreamingContent> StreamAsync(
        Message message,
        StreamOptions options,
        AIRequestContext? context = null,
        CancellationToken ct = default);
}

All concrete providers (OpenAIService, AnthropicService, GoogleAIService, etc.) in Mythosia.AI implement this interface.


IImageGenerationService

Image generation is an optional provider capability rather than part of the LLM-focused IAIService contract. Consumers can depend on the abstraction without assuming that every chat provider can generate images.

using Mythosia.AI.Models.Images;
using Mythosia.AI.Services;

if (service is IImageGenerationService imageService)
{
    ImageGenerationResult result = await imageService.GenerateImagesAsync(
        new ImageGenerationRequest
        {
            Prompt = "A glass pavilion at sunrise",
            Count = 1,
            Size = "1024x1024"
        });

    IReadOnlyList<GeneratedImage> images = result.Images;
}

DefaultImageModel is independent from IAIService.Model. ImageEditRequest adds ordered InputImages and an optional Mask; provider support varies. OpenAI supports mask editing, while Gemini accepts reference images but rejects a separate mask and requires Count = 1.


Models

Type Description
Message A conversation message with role, content, and optional multimodal content
MessageContent Base class for multimodal content (TextContent, ImageContent, AudioContent)
ChatBlock Conversation container holding system message and message history
ActorRole Message role enum (System, User, Assistant, Function)
AIRequestContext Per-request context overrides (system message prefix/suffix, message override)
AIRequestProfile Per-request parameter overrides (temperature, max tokens, stateless mode)
AIModels Model identifier constants for all supported providers, including GPT-5.6 and Grok 4.5/current xAI aliases
Gpt5_6Reasoning GPT-5.6 reasoning effort (Auto, None, Low, Medium, High, XHigh, Max)
Gpt5_6ReasoningMode Standard or Pro reasoning execution; Pro is a request mode, not a separate GPT-5.6 model ID
GrokReasoning xAI reasoning effort (Auto, None, Low, Medium, High); valid levels depend on the selected Grok model
AIProvider Provider enum (OpenAI, Anthropic, Google, xAI, DeepSeek, Perplexity)
ImageGenerationRequest Provider-neutral prompt and output controls for generating one or more images
ImageEditRequest Image-generation request with ordered reference images and an optional mask
ImageInput Binary image input with MIME type and file name
GeneratedImage Generated bytes, MIME type, optional URL, and revised prompt
ImageGenerationResult Images plus provider, model, request ID, and optional token usage

Streaming

Type Description
StreamingContent Streaming chunk with content, type, metadata, token usage, and round information
StreamingContentType Chunk type enum (Text, Reasoning, FunctionCall, FunctionResult, Status, Error, Completion, RoundUsage)
StreamOptions Streaming behavior options (metadata, function calls, reasoning)
TokenUsage Token count data (input, output, cached input, cache creation, reasoning)
StreamDiagnostics SSE round observability snapshot — lines read, accumulated chars, last raw line, elapsed time
StreamDiagnosticsBuilder Fluent configurator for service-level streaming diagnostics; consumed by Mythosia.AI's WithStreamDiagnostics(d => d.OnRawLine(...).OnComplete(...))

Functions

Type Description
FunctionDefinition Function schema for LLM function calling
FunctionCall One typed provider function call with ID, order, arguments, and provider metadata
FunctionCallBatch Ordered calls returned by one assistant response
FunctionCallResult Output or isolated error for one call
FunctionCallResultBatch Ordered results correlated to one function-call batch
FunctionCallingPolicy Controls function calling behavior and iteration limits
FunctionExecutionMode Selects sequential or bounded-parallel execution for one function-call batch
AiFunctionAttribute Marks a method as an AI-callable function
AiParameterAttribute Describes a function parameter for the AI

Exceptions

Type Description
AIServiceException Base exception for AI service errors
AgentMaxStepsExceededException Thrown when agent exceeds maximum iteration steps
ContextLengthExceededException Provider context-window rejection with recovery metadata when available
StreamReadException Thrown when an SSE read fails (transport error, premature stream end, etc.). Wraps the underlying exception in InnerException and attaches a StreamDiagnostics snapshot via the Diagnostics property

Relationship to Microsoft.Extensions.AI

IAIService is Mythosia.AI's provider-neutral contract and is independent from Microsoft.Extensions.AI.IChatClient. It exposes Mythosia-specific stateful sessions (ChatBlock), request profiles and contexts, typed streaming events, and the built-in multi-round function loop. This package does not implement or reference IChatClient, and the two interfaces are not implicitly interchangeable.

Applications that use both ecosystems should put an explicit adapter at their integration boundary and decide how message history, tool execution, streaming metadata, and usage are mapped. Keeping that conversion explicit avoids silently losing semantics when either abstraction evolves.


Why This Package?

Mythosia.AI.Rag  →  Mythosia.AI.Abstractions  (no provider SDK dependencies)
                     instead of
                     Mythosia.AI  (Azure.AI.OpenAI, NJsonSchema, TiktokenSharp, ...)

By depending on abstractions rather than the full implementation package, libraries like Mythosia.AI.Rag avoid pulling in provider-specific dependencies. The concrete provider is chosen by the final application.


Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Mythosia.AI.Abstractions:

Package Downloads
Mythosia.AI

Provider-neutral .NET library for OpenAI, Anthropic Claude, Google Gemini, xAI Grok, DeepSeek, and Perplexity. Provides text and multimodal completions, streaming, reasoning, structured output, token usage, context recovery, ordered function-call batches with sequential or bounded-parallel handler execution, and optional OpenAI/Gemini image generation and editing. Targets .NET Standard 2.1.

Mythosia.AI.Rag

RAG (Retrieval Augmented Generation) orchestration for Mythosia.AI. Implements Mythosia.AI.Rag.Abstractions v6.x. Includes RagPipeline, text splitters, context builder, OpenAI/vLLM embedding providers, hybrid search (BM25 + Vector + RRF), re-ranking (Cohere, LLM, vLLM), Agentic RAG tool registration with per-call RagQueryOptions and structured search traces, search gate, keyword extraction, weighted-blend final selection, progress reporting, DoclingDocument-to-RagDocument conversion, and per-query VectorFilter passthrough (StoreFilter). Depends on Mythosia.AI.Abstractions (IAIService) instead of the full Mythosia.AI implementation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 171 8/8/2026
2.5.0 201 7/23/2026
2.4.0 260 6/10/2026
2.3.0 258 5/30/2026
2.2.0 691 4/28/2026
2.2.0-preview1 219 4/25/2026
2.1.0 462 4/16/2026
2.0.0 560 4/3/2026
1.1.0 216 4/2/2026
1.0.0 297 3/29/2026

v3.0.0 is a breaking release. Adds current provider model constants and reasoning enums, the optional IImageGenerationService contract and image models, typed FunctionCallBatch/FunctionCallResultBatch fields, and FunctionExecutionMode for sequential or bounded-parallel handlers. Removes ChatBlock.RemoveFunctionMessages(), retired model constants, and GrokReasoning.Off. Full notes and migration guide: https://github.com/AJ-comp/Mythosia.AI/blob/main/src/core/Mythosia.AI.Abstractions/RELEASE_NOTES.md#v300