Mythosia.AI.Abstractions 4.2.0

dotnet add package Mythosia.AI.Abstractions --version 4.2.0
                    
NuGet\Install-Package Mythosia.AI.Abstractions -Version 4.2.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="4.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mythosia.AI.Abstractions" Version="4.2.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 4.2.0
                    
#r "nuget: Mythosia.AI.Abstractions, 4.2.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@4.2.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=4.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Mythosia.AI.Abstractions&version=4.2.0
                    
Install as a Cake Tool

Mythosia.AI.Abstractions

Use this package when building middleware, retrieval integrations or custom providers that need a shared AI contract without pulling in provider SDKs. It defines IAIService, messages, streaming events and shared models, with optional IAIRunService, IAIRequestFeatureService and IImageGenerationService capabilities. Applications normally receive it through Mythosia.AI; the only package dependency is the lightweight Mythosia base library.

Version 4.1.0 speed contracts add InferenceSpeed, immutable AIProcessingInfo, request-feature WithSpeed, tri-state speed capabilities and AIRunResult.Processing. They describe processing mode and provider reports, not measured tokens per second. The matching core implementation provides provider validation and transport wiring; IAIService gains no required members; optional IAIProcessingInfoService and GetLastProcessing() expose observations through interface references. See processing speed.

Current release: 4.2.0

This additive contracts release pairs with Mythosia.AI 8.2.0. It adds AIModels.OpenAI.Gpt6_1Sol for the fixed gpt-6.1-sol model ID, reusing the existing reasoning, Run, request-feature and processing-speed contracts. No required interface members, constructors or existing enum values change. GPT-6.1 Sol requires Low through Max reasoning; older Sol/Luna retain support for None. See the v4.2.0 release notes and model selection and migration.

AIModels.Anthropic.ClaudeSonnet5_5 selects claude-sonnet-5-5; the additive ClaudeThinkingMode enum defines Auto, Adaptive and BetweenTools. Mythosia.AI 8.2.0 supplies validation and execution: adaptive/high by default, explicit between_tools for up-front thinking suppression, and preserved signed tool progress. Sonnet 5.5 configuration and migration.

The v4 contracts below remain available. When upgrading from 3.x or earlier, the v8 migration guide explains the required source changes and rebuilds.

Contract What it enables and what changes
Typed image options Named quality/background/format choices and immutable ImageSize.Auto, .Pixels(...) and .Preset(...); replace former strings and the separate AspectRatio property.
Completion cancellation Both IAIService.GetCompletionAsync signatures append optional CancellationToken; custom implementations must update and propagate it.
AIRunResult AIRun.Result returns a completed snapshot with text, reported usage, citations, requested/actual model, rounds and finish details; former string callers read .Text.
Tool result contracts HandlerWithCancellation and FunctionCallResult.IsCancelled support cooperative execution; core normalizes asynchronous object results.
AIModelCapabilities / ImageModelCapabilities Immutable typed choices distinguish Supported, Unsupported and Unknown without asserting live account access.

GetCompletionAsync and typed StructuredStreamRun<T>.Result keep their return types. Custom AIService providers retain the single-Message completion override and forward protected RequestCancellationToken to transport work. Cancellation cannot guarantee remote inference or billing cancellation. See the completion contract and Run result migration.

AIService.CreateRequest(...), immutable AIRequestBuilder, capability queries and asynchronous tool execution live in the implementation package. Those features add no mandatory IAIService members themselves; the completion cancellation signature changes above still apply. See request settings, tool returns/errors/cancellation, and capability inspection.

The AIModels.Anthropic.ClaudeOpus5_5 identifier selects claude-opus-5-5 using the existing reasoning/display contracts. Its provider validation, preserved-thinking behavior and capabilities require Mythosia.AI 8.1.0 / Abstractions 4.1.0. See Opus 5.5.

The AIModels.OpenAI.Gpt6Sol, Gpt6Luna and additive Gpt6Reasoning.None let applications select complex agent work or economical volume without changing execution APIs. They require Mythosia.AI 8.1.0 / Abstractions 4.1.0. Model selection and controls.

The AIModels.xAI.Grok4_7 identifier selects grok-4.7 with the existing GrokReasoning, request, Run and processing-speed contracts. Core supplies model-specific validation for Low/Medium/High/XHigh, mandatory reasoning and priority processing. This integration requires Mythosia.AI 8.1.0 / Abstractions 4.1.0. No required interface members or service defaults change. See Grok 4.7.

The AIModels.DeepSeek.V4Pro identifier selects text-only DeepSeek V4 Pro and requires Mythosia.AI 8.1.0 / Abstractions 4.1.0. The core package also adds optional Responses execution and Files support for reusing uploaded images with Flash; V4 Pro rejects images. See DeepSeek models, image reuse and limits.

Model contracts include Fable/Mythos 5.1, Gemini 3.7/3.8 Flash, Grok 4.6 with XHigh, DeepSeek Flash, Grok Imagine Image 2.0 and GPT Image 2.5. Perplexity Agent API contracts replace legacy Sonar-specific selections; AIModels.Perplexity.Sonar now identifies perplexity/sonar. Provider execution and validation require Mythosia.AI 8.0.0. GPT-6 Astra and optional Run/request-feature contracts were introduced in v3.1.

Snapshot fixes preserve supported JSON ownership, array bounds, standard read-only wrappers, dictionary comparers and shared references without adding a JSON dependency. See the v4.0.0 release notes for contract details and compatibility.

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,
        CancellationToken cancellationToken = default);

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

    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.


IAIRunService and AIRun

Libraries that need to display or cancel ongoing work can depend on IAIRunService without referencing a concrete provider. See the Run guide for application examples.

To adjust effort for a task or ground an answer in hosted sources without coupling middleware to a provider, use optional IAIRequestFeatureService. Its WithReasoning, WithWebSearch and WithFileSearch extensions retain the concrete service type, copy settings for the next logical request, and reject unsupported capabilities explicitly. AICitation, StreamingContent.Citation and AIRun.Citations carry provider source references independently of text observation. This optional request-feature capability adds no required IAIService members; the completion signature migration still applies in v4.0.0. See reasoning and search for scope, provider support and citation indexing.

Run startup remains an optional capability and adds no mandatory IAIService members of its own. The separate completion signature migration applies to ordinary completion. It exposes StartRunAsync overloads for string and Message input with onText, streaming options, request context, and cancellation.

using Mythosia.AI.Services;

if (service is IAIRunService runService)
{
    await using var run = await runService.StartRunAsync(
        "Summarize the documents.",
        onText: text => Console.Write(text),
        cancellationToken: cancellationToken);
    string answer = (await run.Result).Text;
}

RequestedModel is the single explicit model sent in the request, captured at startup, including a provider model override. It is null when a preset, profile, or server-side model routing selects the model without a single explicit model field (for example, a Perplexity Models list). This is independent of the actual response model in Model.

AIRun is in Mythosia.AI.Models.Runs. It exposes Result, output-only StreamAsync, CanSteer, SteerAsync, Cancel, and DisposeAsync. A single event reader may accompany the text callback. Execution and result collection continue without an event reader; see the run guide for buffering and lifetime contracts.

IImageGenerationService

Use this capability to create visual drafts or revise reference images while retaining the same application-facing request and result types across OpenAI, Google, and xAI. It is optional rather than part of the LLM-focused IAIService contract, so consumers do not have to assume that every chat provider generates images.

For fast visual drafts or precise revisions, select AIModels.OpenAI.GptImage2_5Flare or GptImage2_5Sunburst explicitly through ImageGenerationRequest.Model or ImageEditRequest.Model. GptImage2_5Flare_260908 and GptImage2_5Sunburst_260908 pin the September 8, 2026 snapshots. The existing request/result types and method signatures are reused; OpenAI's default remains GptImage2. Model-specific quality, transparency, size, and input validation belongs to the provider implementation. See the GPT Image 2.5 guide.

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 = ImageSize.Auto,
            OutputFormat = ImageOutputFormat.Auto
        });

    IReadOnlyList<GeneratedImage> images = result.Images;
}

DefaultImageModel is independent from IAIService.Model. xAI defaults to AIModels.xAI.GrokImagineImage2_0 (grok-imagine-image-2.0) from Mythosia.AI 8.0.0. ImageEditRequest adds ordered InputImages and an optional Mask; provider support varies. OpenAI supports mask editing. Gemini accepts reference images but rejects a separate mask and requires Count = 1. xAI accepts 1–10 outputs and 1–5 JPEG/PNG/WebP reference images, without a separate mask.

For autocomplete and clear sizing intent, use ImageQuality, ImageBackground, ImageOutputFormat, and immutable ImageSize. ImageSize.Pixels(width, height) requests exact dimensions; ImageSize.Preset(resolution, aspectRatio) requests a resolution grade and optional ratio. The separate request AspectRatio property is removed. This is a breaking change; see before/after migration. OpenAI accepts Auto/Pixels; Google and xAI accept Auto/Preset. Unsupported modes fail before HTTP instead of silently approximating pixels.

The shared output-format default is now ImageOutputFormat.Auto: OpenAI resolves it to PNG, while Google and xAI use provider-selected output. OpenAI also accepts Png, Jpeg, and WebP; Google accepts explicit Jpeg only; xAI rejects every explicit format because its API cannot select a codec. Read GeneratedImage.MediaType and save with the matching extension. xAI rejects explicit compression and non-Auto backgrounds and accepts ImageQuality.Auto, Low, and Medium. Validation belongs to the provider implementation; the contracts package adds no image codec or provider SDK.


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 Provider model identifiers, including AIModels.Anthropic.ClaudeSonnet5_5, ClaudeOpus5_5, ClaudeFable5_1, ClaudeMythos5_1, GPT-6.1 Sol / GPT-6 Astra / Sol / Luna, GPT-5.6, and current xAI aliases
ClaudeThinkingMode Auto, Adaptive, BetweenTools; core validates model-specific support and effort combinations
ClaudeThinkingDisplay Omitted, Summarized, or Updates; 5.1 progress updates keep reasoning hidden
ClaudeThinkingPrefixMismatchBehavior Error or DropBlock for the provider's handling of thinking bound to a changed conversation
ClaudeInputTransformation Provider-reported thinking changes: Type, Path, Reason, ResponseId, and Model
Gpt6Reasoning GPT-6 effort (Auto, Low, Medium, High, XHigh, Max, plus None); None is supported by Sol/Luna, not Astra; existing numeric values remain unchanged
Gpt6ReasoningMode Standard or Pro reasoning execution on the same selected GPT-6 model ID
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, XHigh); Grok 4.6 adds XHigh and cannot disable reasoning; valid levels depend on the selected model
DeepSeekReasoning Native effort (Auto, Low, High, Max); thinking activation is separate, while WithDeepSeekReasoning enables it. Common ReasoningLevel also supports None and the provider's documented level mappings
AIProvider Provider enum (OpenAI, Anthropic, Google, xAI, DeepSeek, Perplexity)
ImageGenerationRequest Provider-neutral prompt, typed size, quality, background, and output controls for generating one or more images; supported values depend on the provider
ImageQuality / ImageBackground / ImageOutputFormat Named image options; provider/model support is validated before HTTP
ImageSize Immutable Auto, exact Pixels, or resolution-and-ratio Preset intent
ImageResolution / ImageAspectRatio Resolution grades and ratios for ImageSize.Preset; supported values vary by model
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 with optional AllowAsync permission (default false)
FunctionCall One typed provider function call with ID, order, arguments, provider metadata, and actual provider IsAsync status
FunctionCallBatch Ordered calls returned by one assistant response
FunctionCallResult Output or isolated error for one call
FunctionCallResultBatch Results correlated to one function-call batch; native async delivery can be partial
FunctionCallingPolicy Controls function calling behavior and iteration limits
FunctionExecutionMode Selects sequential or bounded-parallel execution for ordinary calls; opted-in async jobs use a separate MaxConcurrency limit
AiFunctionAttribute Marks a method as an AI-callable function, with optional AllowAsync permission (default false)
AiParameterAttribute Describes a function parameter for the AI

When a slow lookup leaves room for independent model work, such as giving general advice while waiting for a forecast, AllowAsync permits the two to overlap on a supporting provider, model, and API. The implementation enables it for GPT-6.1 Sol / GPT-6 Astra / Sol / Luna through Responses; other connections omit the API option and wait for the same handler's result. The permission is preserved when switching models. FunctionCall.IsAsync records the provider's actual call status, so enabling the permission does not guarantee async execution. In Mythosia.AI, FunctionBuilder.WithAsync() is the fluent equivalent of AllowAsync = true.

This is separate from Task-returning handlers and FunctionExecutionMode.Parallel. Pending function jobs belong to the existing completion or streaming request; they are completed and cleaned up before that request ends. Cancellation-aware handlers receive the execution token through HandlerWithCancellation; started handlers that ignore cancellation are still awaited during cleanup. Calls not yet started are skipped with matching cancelled results. Calling the legacy Handler delegate directly uses CancellationToken.None.

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

Build .NET applications with multiple AI providers through consistent completion, streaming and tool workflows. Supports OpenAI GPT-6.1 Sol and GPT-6 Astra/Sol/Luna, Anthropic including Claude Sonnet 5.5 and Opus 5.5, Google, xAI including Grok 4.7, DeepSeek Flash/V4 Pro and Perplexity. Includes immutable request builders, controllable Runs, typed output, cancellable local tools, reasoning, search/citations, image generation/editing, capability inspection and per-request processing-speed observations. Targets .NET Standard 2.1; requires Mythosia.AI.Abstractions 4.2.0. What's New in v8.2.0: GPT-6.1 Sol adds mandatory reasoning, Responses tools and native Run support; Sonnet 5.5 adds adaptive/high defaults and explicit between-tools thinking. Request preparation captures effective settings, runs profile hooks once and validates before side effects. Nested auxiliary requests isolate parent state; forwarded profile changes preserve later request-local tool and policy edits. Claude retains signed and tool history across projection, counting and permitted compaction, preserves persistent instructions, and serializes valid lowercase tool schemas. Streaming fixes cover producer cleanup, HTTP error-body cancellation, identifiable HttpClient timeouts and preservation of outcomes during response disposal. OpenAI Run honors configured endpoints and preserves steering order, cancellation boundaries and terminal outcomes. Existing public execution APIs and service defaults remain. Known limitations: Sonnet 5.5/Opus 5.5 pauses ending in a pending server_tool_use can be rejected before continuation. Custom buffering HTTP content can delay successful SSE body acquisition past cancellation or timeout, retaining the active Run. These cases remain unfixed. Full release notes: https://github.com/AJ-comp/Mythosia.AI/blob/main/src/core/Mythosia.AI/RELEASE_NOTES.md#v820

Mythosia.AI.Rag

Ground AI answers in application-managed documents with loading, splitting, embeddings, vector/text/hybrid retrieval, reranking and metadata filters. Provides standard and Agentic RAG, streaming runs, cancellation and optional PIXIE search. Supports Voyage Context 4, Gemini Embedding 2, OpenAI, Ollama and Perplexity embeddings. Retrieval-aware providers distinguish documents from queries and receive complete ordered document inputs; existing IEmbeddingProvider implementations remain compatible. Validates embedding results before document replacement and isolates query rewriting and reranking. Depends on Mythosia.AI.Abstractions and Mythosia.AI.Rag.Abstractions without referencing the full Mythosia.AI implementation. What's New in v8.3.0: Diagnostics use optional IVectorStoreDiagnostics and InMemory 4.3.0; migrate old InMemory diagnostic interface casts. This minor release intentionally includes a breaking interface migration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.2.0 176 10/3/2026
4.1.0 283 9/24/2026
4.0.0 198 9/13/2026
3.1.0 209 9/8/2026
3.0.0 244 8/8/2026
2.5.0 229 7/23/2026
2.4.0 275 6/10/2026
2.3.0 280 5/30/2026
2.2.0 737 4/28/2026
2.2.0-preview1 239 4/25/2026
2.1.0 478 4/16/2026
2.0.0 600 4/3/2026
1.1.0 233 4/2/2026
1.0.0 310 3/29/2026

v4.2.0 adds AIModels.Anthropic.ClaudeSonnet5_5 for claude-sonnet-5-5 and the additive ClaudeThinkingMode enum (Auto/Adaptive/BetweenTools). Core 8.2.0 provides model validation, adaptive/high defaults, between-tools up-front thinking control and signed-history preservation. Existing reasoning/display and Run contracts are reused. Also adds AIModels.OpenAI.Gpt6_1Sol for gpt-6.1-sol, reusing existing reasoning, Run, request-feature, capability and processing-speed contracts. Existing required interface members, constructors, enum values and model identifiers remain. GPT-6.1 Sol requires Low through Max reasoning; older GPT-6 Sol/Luna retain None support. Mythosia.AI 8.2.0 supplies provider validation and execution. Full notes: https://github.com/AJ-comp/Mythosia.AI/blob/main/src/core/Mythosia.AI.Abstractions/RELEASE_NOTES.md#v420