-
Notifications
You must be signed in to change notification settings - Fork 0
08 SDK sdk guide
Christian Ulson edited this page May 22, 2026
·
3 revisions
Krnl-AI provides SDKs for both Python and .NET to build agent applications programmatically.
pip install krnlaifrom krnlai import CognitiveAgent
agent = CognitiveAgent(safety_level="strict")
response = await agent.run("analyze this dataset")
print(response.output)agent = CognitiveAgent(
mode="auto", # "auto" | "standalone" | "enterprise"
safety_level="strict", # "strict" | "relaxed"
endpoint="", # C# backend URL (enterprise mode)
api_key="", # C# backend API key
max_iterations=10,
enable_emotions=True,
enable_learning=True,
)| Method | Description |
|---|---|
run(command) |
Execute a single command |
run_command(envelope) |
Execute a CommandEnvelope
|
stream(command) |
Stream cognitive cycle events |
close() |
Clean up resources |
| Module | Description |
|---|---|
krnlai.llm.openai |
OpenAI LLM provider |
krnlai.llm.anthropic |
Anthropic LLM provider |
krnlai.llm.ollama |
Ollama LLM provider |
krnlai.llm.google |
Google Gemini provider |
krnlai.llm.deepseek |
DeepSeek provider |
krnlai.llm.groq |
Groq provider |
krnlai.llm.openrouter |
OpenRouter provider |
krnlai.llm.mistral |
Mistral AI provider |
krnlai.llm.cohere |
Cohere provider |
krnlai.llm.together |
Together AI provider |
krnlai.core.safety |
Safety checker and rules |
krnlai.core.memory |
Episodic, semantic, working, procedural, autobiographical memory |
krnlai.core.emotion |
VAD emotional model + pain/reward system |
krnlai.core.policies |
Policy engine |
krnlai.core.risk |
Risk scoring |
krnlai.core.cognition |
Cognitive cycle, metacognition, inner speech |
krnlai.core.consciousness |
Operational consciousness, attention schema |
krnlai.investigation |
Causal investigation and root cause analysis |
krnlai.integrations |
LangChain, CrewAI, AutoGen, FastAPI |
krnlai.enterprise |
Enterprise client and stores |
from krnlai.llm.ollama import OllamaProvider
provider = OllamaProvider(model="llama3.1", endpoint="http://localhost:11434/v1")
response = await provider.chat("Hello!")dotnet add package KrnlAISdkusing KrnlAI;
var client = new KrnlAIClient();
var response = await client.RunAsync("analyze this dataset");
Console.WriteLine(response.Narration);| Model | Description |
|---|---|
AgentRunRequest |
Request to run the agent |
MemorySearchRequest |
Request to search memory |
EpisodeModels |
Episode data models |
HealthModels |
Health check models |
MetricsModels |
Performance metrics models |
GoalModels |
Goal tracking models |
// Search memory
var memoryResult = await client.SearchMemoryAsync("project decision");
// Check health
var health = await client.CheckHealthAsync();
// Get metrics
var metrics = await client.GetMetricsAsync();Krnl-AI Community — MIT License