Spectra.Kernel
0.1.2
dotnet add package Spectra.Kernel --version 0.1.2
NuGet\Install-Package Spectra.Kernel -Version 0.1.2
<PackageReference Include="Spectra.Kernel" Version="0.1.2" />
<PackageVersion Include="Spectra.Kernel" Version="0.1.2" />
<PackageReference Include="Spectra.Kernel" />
paket add Spectra.Kernel --version 0.1.2
#r "nuget: Spectra.Kernel, 0.1.2"
#:package Spectra.Kernel@0.1.2
#addin nuget:?package=Spectra.Kernel&version=0.1.2
#tool nuget:?package=Spectra.Kernel&version=0.1.2
Spectra
AI workflow orchestration for .NET. Build workflows as graphs, mix code and agent steps, swap providers without changing the flow.
Documentation · Getting Started · Samples · NuGet
Quickstart
dotnet new console -n MyWorkflow && cd MyWorkflow
dotnet add package Spectra
dotnet add package Spectra.Extensions
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddSpectra(spectra =>
{
spectra.AddOpenRouter(c =>
{
c.ApiKey = Environment.GetEnvironmentVariable("OPENROUTER_API_KEY")!;
c.Model = "openai/gpt-4o-mini";
});
spectra.AddConsoleEvents();
});
})
.Build();
var workflow = WorkflowBuilder.Create("greet-and-translate")
.AddAgent("assistant", "openrouter", "openai/gpt-4o-mini", a => a
.WithSystemPrompt("You are a helpful assistant."))
.AddAgentNode("greet", "assistant", n => n
.WithUserPrompt("Say hello to {{inputs.name}}.")
.WithMaxIterations(1))
.AddAgentNode("translate", "assistant", n => n
.WithUserPrompt("Translate to French: {{nodes.greet.output}}")
.WithMaxIterations(1))
.AddEdge("greet", "translate")
.Build();
var runner = host.Services.GetRequiredService<IWorkflowRunner>();
var state = new WorkflowState { ["inputs.name"] = "World" };
var result = await runner.RunAsync(workflow, state);
Console.WriteLine(result["nodes.translate.output"]);
dotnet run
Nodes do work. Edges define flow. State moves through the graph.
Using a different provider? Replace
AddOpenRouter(...)withAddOpenAI(...),AddAnthropic(...),AddGemini(...), orAddOllama(...). The workflow definition stays the same.
Read the full getting-started guide →
Why Spectra
Workflows are visible graphs. Define workflows as directed graphs in C# or JSON. Every step, edge, and condition is explicit — not buried in application code.
Mix any kind of step. Code functions, LLM prompts, autonomous agents, human approval gates, subgraphs — all first-class nodes in the same workflow.
Swap providers freely. Route each step to OpenAI, Claude, Gemini, Ollama, or OpenRouter. Define fallback chains. The workflow definition doesn't change.
Define in C# or JSON. Use the fluent builder for code-first control, or JSON for portable, editable definitions that don't require recompilation. Both describe the same model.
Features
- Graph-based orchestration — directed graphs with conditional edges, parallel fan-out, and cyclic loops with guard rails
- Multi-provider — OpenAI, Anthropic, Gemini, Ollama, OpenRouter, and any OpenAI-compatible API
- Agent step — autonomous tool-using agents with iteration limits and cost tracking (coming soon)
- Multi-agent — supervisor, handoff, and delegation patterns
- MCP integration — connect agents to MCP tool servers over stdio or SSE
- Checkpointing — pause and resume workflows from any node
- Time travel — fork execution from any checkpoint and explore different paths
- Interrupts — pause any step for human approval, inject feedback, resume
- Streaming — token-level streaming through the workflow pipeline
- Prompt management — prompts as markdown files with YAML front matter and
{{variable}}templating - Resilience — provider fallback chains, tool circuit breakers, retry with backoff, response caching
- Sessions — multi-turn conversational state with history windowing
- Memory — cross-session persistent memory for agents
- Observability — OpenTelemetry tracing, structured events, compliance audit trail
- Typed state — compile-time merge policies for parallel execution
- Standard DI —
AddSpectra(...)plugs intoIServiceCollectionlike any .NET service
Packages
| Package | Description |
|---|---|
Spectra |
Entry point — DI registration, fluent builders, hosted service |
Spectra.Extensions |
LLM providers: OpenAI, Anthropic, Gemini, Ollama, OpenRouter |
Spectra.Kernel |
Execution engine, scheduler, built-in steps, resilience decorators |
Spectra.Contracts |
Interfaces and data models only — for building extensions |
Spectra.AspNetCore |
HTTP endpoints for exposing workflows via ASP.NET Core |
Most projects need Spectra + Spectra.Extensions. The rest are for advanced scenarios.
Samples
| Sample | What it shows |
|---|---|
| HelloWorld | Minimal single-node workflow |
| JsonVsCode | Same workflow defined in C# and JSON |
| BranchingWorkflow | Conditional edges and dynamic routing |
| ParallelFanOut | Parallel branch execution with fan-in |
| CyclicLoop | Retry loops with guard rails |
| CheckpointResume | Pause and resume from checkpoint |
| InterruptApproval | Human-in-the-loop approval gate |
| SingleAgent | Autonomous agent with tools |
| AgentWithMcp | Agent connected to MCP tool servers |
| AgentWithFallback | Provider fallback chains |
| MultiAgent | Agent-to-agent handoff |
| MultiAgentSupervisor | Supervisor delegates to worker agents |
| SubgraphComposition | Nested workflows with isolated state |
| StreamingOutput | Token-level streaming through the pipeline |
| StructuredOutput | JSON-constrained LLM output |
| MemoryStoreRecall | Cross-session persistent memory |
| ResearchPipeline | Multi-step research with validation |
Documentation
Full documentation at alicank.github.io/Spectra.
- Getting Started — install to running workflow in 60 seconds
- Workflows & Graphs — nodes, edges, state, branching, loops
- LLM Providers — setup for each provider
- Agent Step — autonomous tool-using agents
- Multi-Agent Patterns — supervisor, handoff, delegation
- Architecture — package structure, execution flow, extension points
Contributing
Contributions are welcome. Please open an issue first to discuss what you'd like to change.
git clone https://github.com/alicank/spectra.git
cd spectra
dotnet build
dotnet test
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Spectra.Contracts (>= 0.1.2)
- Spectra.Extensions (>= 0.1.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Spectra.Kernel:
| Package | Downloads |
|---|---|
|
Spectra
AI workflow orchestration for .NET. Define workflows as graphs, mix code and agent steps, choose providers per step. |
GitHub repositories
This package is not used by any popular GitHub repositories.