Skip to content

MemoriLabs/axon

Repository files navigation

Memori Labs

The universal LLM interceptor and hook registry

Axon plugs into the official LLM SDKs you already use. It allows you to seamlessly intercept, modify, and monitor LLM requests and responses through a unified hook system without changing your underlying application code.

NPM version License Discord


What is Axon?

Axon is a lightweight SDK wrapper that gives you complete visibility and control over your LLM traffic. Instead of building custom wrappers around OpenAI, Anthropic, or Gemini, Axon patches the official clients directly.

You write a hook once, and it normalizes the requests and responses across all supported providers.

  • Zero Overhead: Plugs directly into your existing client initialization. No need to rewrite your agent or application logic.
  • Unified Hook System: Modify prompts (before) or track token usage (after) using a single standard format, regardless of which LLM provider your app is talking to.
  • First-Class Streaming: Seamlessly handles and aggregates asynchronous streaming responses behind the scenes so your hooks always get the full picture.

Official SDK

Axon is available for TypeScript / Node.js:


Quick Glance

Axon's API is designed to feel native and consistent.

TypeScript

import { OpenAI } from 'openai';
import { Axon } from '@memorilabs/axon';

const client = new OpenAI();
const axon = new Axon().llm.register(client);

// 1. Intercept and modify requests
axon.hook.before((req, ctx) => {
  console.log(`Sending to: ${req.model}`);
  return req;
});

// 2. Track responses and tokens
axon.hook.after((req, res, ctx) => {
  console.log(`Tokens used: ${res.usage?.totalTokens}`);
});

// 3. Call the client exactly as you normally would
await client.chat.completions.create({ ... });

Supported Integrations

Currently, Axon can patch the following official SDKs out of the box:

Provider TypeScript Peer Dependency
OpenAI openai
Anthropic @anthropic-ai/sdk
Google Gemini @google/genai

Contributing

We welcome contributions from the community! Please see our Contributing Guidelines for details on how to set up your development environment, run tests, and submit pull requests.

Support

License

Apache 2.0 - see LICENSE

About

The universal LLM interceptor and hook registry

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors