axil-auren Usage Guide

axil-auren (libauren) is an ultra-portable local LLM inference engine, OpenAI-compatible streaming chat server, and dense vector embeddings library powered by llama.cpp and Vulkan/CPU.

It runs either as a resident Axil network module serving HTTP on port 4242, or as an embedded C library linked directly into your application via <ttypt/auren.h>.


Table of Contents

  1. Starting the Server
  2. Model Configuration (auren.json)
  3. First-Class Session Continuity & Prefix KV Caching
  4. Pi Coding Agent Integration
  5. OpenAI-Compatible HTTP API
  1. Command-Line CLI Utilities
  2. Embedded C Library API (<ttypt/auren.h>)
  3. Automated Verification & Diagnostics

1. Starting the Server

Turnkey Runner Script

The repository provides a turnkey server launcher that automatically configures library paths and discovers configuration files:

# Start server on default port 4242:
./scripts/auren-server

# Or specify a custom port:
AUREN_PORT=8000 ./scripts/auren-server

Running Directly via Axil

If axil is installed under $PREFIX (e.g. ~/.local):

LD_LIBRARY_PATH="$HOME/.local/lib" \
axil -A -d -p 4242 -m "$HOME/.local/lib/libaxil-auren"

Background Daemon Execution

To run in the background as a daemon:

nohup ./scripts/auren-server > /tmp/auren.log 2>&1 &

To stop a running daemon:

pkill -f "axil.*4242"

2. Zero-Config Auto-Discovery & Optional auren.json

axil-auren starts cleanly with no configuration file:

To override discovery order, context sizes, or GPU layer counts explicitly, create an auren.json file:

{
  "models": [
    {
      "id": "olmoe",
      "path": "~/.models/olmoe-1b-7b-instruct-q3_k_m.gguf",
      "capabilities": ["chat", "judge"],
      "n_ctx": 4096,
      "n_gpu_layers": 0,
      "temperature": 0.7
    },
    {
      "id": "qwen",
      "path": "~/.models/qwen2.5-0.5b-instruct.gguf",
      "capabilities": ["chat", "judge"],
      "n_ctx": 131072,
      "n_gpu_layers": 0,
      "temperature": 0.7
    },
    {
      "id": "bge-base",
      "path": "~/.models/bge-base-en-v1.5.gguf",
      "capabilities": ["embed"],
      "n_ctx": 512,
      "n_gpu_layers": 0
    },
    {
      "id": "bge-small",
      "path": "~/.models/bge-small-en-v1.5.gguf",
      "capabilities": ["embed"],
      "n_ctx": 512,
      "n_gpu_layers": 0
    }
  ],
  "defaults": {
    "chat": "olmoe",
    "judge": "olmoe",
    "embed": "bge-base"
  },
  "max_resident": 3
}

Mixture of Experts (MoE) Support

axil-auren natively supports sparse MoE models like OLMoE-1B-7B-Instruct. With 64 experts and 8 active experts per token, OLMoE evaluates only ~1.3B parameters of compute per token, delivering generation latency close to a 1B model while maintaining the knowledge, context handling, and reasoning depth of a 7B model. Thanks to mmap, weights are dynamically paged without requiring all expert layers to be actively resident in compute registers.

Aiming Higher: Hardware Sizing & Scaling Guide

Different environments require different trade-offs between memory footprint, latency, and reasoning capability. axil-auren supports 3 clear hardware tiers:

Tier 1: Ultra-Lightweight (<4 GB RAM or Low-Spec VPS)

Tier 2: Balanced MoE (8โ€“16 GB RAM โ€” Recommended Default)

Tier 3: Aiming Higher (16โ€“32 GB+ RAM or Dedicated GPU Offload)

For users on high-spec workstations or systems with Vulkan/CUDA GPUs who want maximum reasoning depth:

`json { "models": [ { "id": "qwen-7b", "path": "~/.models/qwen2.5-7b-instruct-q4_k_m.gguf", "capabilities": ["chat", "judge"], "n_ctx": 8192, "n_gpu_layers": 33 }, { "id": "bge-large", "path": "~/.models/bge-large-en-v1.5.gguf", "capabilities": ["embed"], "enable_embeddings": 1, "n_ctx": 512 } ], "defaults": { "chat": "qwen-7b", "judge": "qwen-7b", "embed": "bge-large" } } `

Key Configuration Parameters

Configuration Search Order

When starting up, axil-auren searches for configuration in the following order:

  1. AUREN_CONFIG_PATH environment variable (if explicitly set).
  2. ./auren.json (current working directory).
  3. ~/.config/auren/config.json (user configuration directory).
  4. ~/.auren.json (user home directory).
  5. ~/auren.json (fallback user root).

3. First-Class Session Continuity & Prefix KV Caching

The Problem in Autonomous Agent Loops

Autonomous agents (such as the Pi coding agent) typically send large system instructions, tool definitions, and project documentation (~10,000โ€“15,000 tokens) on every conversational turn.

On standard stateless servers, the server wipes its KV cache on every turn. Processing 15,000 tokens from scratch on CPU can take 30โ€“60 seconds per prompt, even when generating just a 5-token response.

How axil-auren Solves This

axil-auren introduces native session continuity:

  1. When a client includes an x-session-id HTTP header or "session_id" JSON field:
  1. When Turn 2 arrives with the accumulated conversation:
  1. Turn 2+ latency drops from ~30 seconds to milliseconds:
TurnTotal ContextReused from KVEvaluated DeltaMeasured Latency
Turn 1 (Cold Ingestion)3,552 tokens0 tokens3,552 tokens30.49s
Turn 2 (Prefix Cache Hit)3,569 tokens3,552 tokens (99.5%)17 tokens2.01s (15.18x speedup)
Turn 3 (Continued Session)3,584 tokens3,569 tokens (99.6%)15 tokens1.98s (15.40x speedup)

4. Pi Coding Agent Integration

axil-auren is designed to be the primary local inference backend for the Pi coding agent.

Step 1: Configure ~/.pi/agent/models.json

Add the auren provider to ~/.pi/agent/models.json:

{
  "providers": {
    "auren": {
      "name": "axil-auren",
      "baseUrl": "http://localhost:4242/v1",
      "api": "openai-completions",
      "apiKey": "local",
      "models": [
        {
          "id": "qwen",
          "name": "Qwen 2.5 0.5B Instruct",
          "contextWindow": 131072,
          "maxTokens": 32768,
          "cost": {
            "input": 0,
            "output": 0,
            "cacheRead": 0,
            "cacheWrite": 0
          },
          "compat": {
            "supportsDeveloperRole": false,
            "supportsUsageInStreaming": false,
            "maxTokensField": "max_tokens"
          }
        }
      ]
    }
  }
}

Step 2: Install the Session Continuity Extension

Ensure the provider hook is active at ~/.pi/agent/extensions/auren-prefix-cache.ts:

export default function aurenPrefixCache(pi: any) {
  function getActiveSessionId(ctx: any): string {
    return ctx?.sessionManager?.getSessionId?.() || "default-session";
  }

  pi.on("before_provider_headers", (event: any, ctx: any) => {
    if (ctx?.model?.provider === "auren") {
      event.headers["x-session-id"] = getActiveSessionId(ctx);
    }
  });

  pi.on("before_provider_request", (event: any, ctx: any) => {
    if (ctx?.model?.provider === "auren") {
      if (event?.payload && typeof event.payload === "object") {
        event.payload.session_id = getActiveSessionId(ctx);
      }
    }
  });
}

Step 3: Run Pi with Local Inference

# Launch interactive coding session:
pi --model auren/qwen

# Or run a single instruction:
pi --model auren/qwen -p "Review git status and tell me what is uncommitted."

5. OpenAI-Compatible HTTP API

A. Chat Completions (POST /v1/chat/completions)

Supports both traditional string messages and modern array-of-blocks content ([{"type":"text","text":"..."}]).

Non-Streaming Example:

curl -s http://localhost:4242/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "x-session-id: dev-session-1" \
  -d '{
    "model": "qwen",
    "messages": [
      { "role": "system", "content": "You are a concise engineering assistant." },
      { "role": "user", "content": "What is the primary benefit of zero-copy in-memory maps?" }
    ],
    "temperature": 0.7,
    "stream": false
  }'

Streaming SSE Example:

curl -N -s http://localhost:4242/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "x-session-id: dev-session-1" \
  -d '{
    "model": "qwen",
    "messages": [
      { "role": "system", "content": "You are a concise engineering assistant." },
      { "role": "user", "content": "Write a C function to reverse a string." }
    ],
    "stream": true
  }'

B. Vector Embeddings (POST /v1/embeddings)

Generates dense float embeddings using bge-small-en-v1.5 (384-dimensional, 37 MB, ultra-lightweight and fast) or bge-base-en-v1.5 (768-dimensional, 118 MB, higher retrieval accuracy) in under a few milliseconds.

Single Text Embedding (bge-base, 768 dimensions):

curl -s http://localhost:4242/v1/embeddings \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bge-base",
    "input": "in-memory zero-copy vectors"
  }'

Batch Array Embeddings (bge-small, 384 dimensions):

curl -s http://localhost:4242/v1/embeddings \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bge-small",
    "input": [
      "zero-copy memory mapping",
      "spatial morton z-order curve",
      "accent-preserving lemma tokenizer"
    ]
  }'

C. System One Reflexive Decisions (POST /v1/systemone)

axil-auren serves POST /v1/systemone (and POST /api/v1/systemone/) as the unified System 1 decision engine. It evaluates choices and nearest-exemplars in a single forward pass with 0 generated decode tokens (~5โ€“15ms latency), avoiding regex fragile parsing.

It supports three distinct modes:

1. Binary & Choice Gating (Single-pass Logits)

Evaluates prompt forward pass and extracts logits between candidate options with calibrated probabilities:

curl -s http://localhost:4242/v1/systemone \
  -H "Content-Type: application/json" \
  -d '{
    "model": "judge",
    "prompt": "Evaluate whether this query asks for software code changes.\nQuery: Please fix the null pointer exception in parse_header.\nAnswer [yes/no]:",
    "choices": ["yes", "no"],
    "threshold": 0.5
  }'

Response:

{
  "ok": true,
  "decision": "yes",
  "choice": "yes",
  "choice_index": 0,
  "confidence": 0.998,
  "probability": 0.998,
  "margin": 6.354,
  "threshold": 0.5,
  "model": "olmoe"
}

2. Nearest-Exemplar Matching (In-Memory Embeddings)

Classifies input text against candidate exemplars using in-memory SIMD cosine similarity over cached vector embeddings:

curl -s http://localhost:4242/v1/systemone \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bge-base",
    "text": "Refactor memory allocator in axil core",
    "exemplars": {
      "trivial": "Fix spelling mistake in markdown doc",
      "standard": "Implement new REST API endpoint with test suite",
      "complex": "Refactor multi-threaded memory allocator and lock-free queue"
    }
  }'

Response:

{
  "ok": true,
  "decision": "complex",
  "choice": "complex",
  "confidence": 0.887,
  "similarity": 0.887,
  "margin": 0.356,
  "scores": {
    "trivial": 0.214,
    "standard": 0.531,
    "complex": 0.887
  },
  "model": "bge-base"
}

3. Jev Structured Question Evaluation

Evaluates structured questions against conversational state for memory classifiers and agents:

curl -s http://localhost:4242/v1/systemone \
  -H "Content-Type: application/json" \
  -d '{
    "model": "default",
    "state": "User: We configured Redis with 3 shards to scale caching.\nAssistant: Noted, 3 shards configured.",
    "questions": {
      "memory_action": {
        "type": "choice",
        "instructions": "Choose whether to remember a new fact or skip.",
        "criteria": { "remember": "New fact worth saving", "skip": "Transient chitchat" }
      }
    }
  }'

Response:

{
  "model": "olmoe",
  "answers": {
    "memory_action": {
      "type": "choice",
      "choice": "remember",
      "confidence": 0.92,
      "probabilities": { "remember": 0.92, "skip": 0.08 }
    }
  },
  "usage": { "input_tokens": 62, "output_tokens": 1 }
}

D. Model Discovery (GET /v1/models)

curl -s http://localhost:4242/v1/models

6. Command-Line CLI Utilities

The repository provides several native CLI utilities located in ./scripts/ and ./bin/:

`bash ./bin/auren-chat

Or with custom port:

AUREN_PORT=4242 ./bin/auren-chat `

`bash ./scripts/auren-list ./scripts/auren-list qwen `

`bash ./scripts/auren-path qwen2.5-0.5b `


7. Embedded C Library API (<ttypt/auren.h>)

Link libaxil-auren.so directly into C applications without network overhead.

Text Generation Example

#include <stdio.h>
#include <ttypt/auren.h>

int main(int argc, char **argv) {
    struct auren_config cfg = {
        .model_path = argc > 1 ? argv[1] : "qwen2.5-0.5b-instruct.gguf",
        .temperature = 0.7f,
        .n_ctx = 2048
    };

    struct auren_context *ctx = auren_create(&cfg);
    if (!ctx) {
        fprintf(stderr, "Failed to load model\n");
        return 1;
    }

    char out[1024];
    long bytes = auren_generate(ctx, "Explain in-memory key-value maps briefly.", out, sizeof(out));
    if (bytes > 0) {
        printf("Response:\n%s\n", out);
    }

    auren_free(ctx);
    return 0;
}

Dense Vector Embeddings Example

#include <stdio.h>
#include <ttypt/auren.h>

int main(void) {
    struct auren_config cfg = {
        .model_path = "bge-small-en-v1.5.gguf",
        .enable_embeddings = 1,
        .n_ctx = 512
    };

    struct auren_context *ctx = auren_create(&cfg);
    if (!ctx) return 1;

    float vec[384];
    long dim = auren_embed(ctx, "in-memory zero-copy vectors", vec, 384);
    if (dim > 0) {
        printf("Generated %ld-dim vector: [%.4f, %.4f, ...]\n", dim, vec[0], vec[1]);
    }

    auren_free(ctx);
    return 0;
}

Compiling and Linking

cc app.c $(pkg-config --cflags --libs axil-auren)

8. Automated Verification & Diagnostics

Run the standalone native driver to verify inference, embedding dimensions, and multi-turn session persistence without HTTP or external daemons:

LD_LIBRARY_PATH=./lib \
./bin/engine-test ~/.models/qwen2.5-0.5b-instruct.gguf

Expected output:

puddle: dim=896 max|v|=77.6 finite=1 ok
turn1: 3 chunks, seq ok, full reply (7 bytes)
turn2: recalled history ('cherry')
after-reset: ok (7 bytes)
oneshot(non-stream): object=chat.completion finish=stop (312 bytes)
oneshot(stream): 33 delta chunks + stop
oneshot(array-content): success (319 bytes)
session-continuity: 500+ token context verified, turn1=13269.6ms, turn2=5308.0ms, recalled secret token ok
PASS: engine embed/chat/oneshot (61 results, 14 final)