npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@amux.ai/llm-bridge

v0.3.2

Published

Core IR and adapter interfaces for Amux

Readme

@amux.ai/llm-bridge

Core IR (Intermediate Representation) and adapter interfaces for Amux

npm version License: MIT

Overview

@amux.ai/llm-bridge is the core package of Amux that provides:

  • Intermediate Representation (IR): Unified data structures for LLM requests/responses
  • Adapter Interface: Standard interface for building provider adapters
  • Bridge Pattern: Orchestration layer for bidirectional conversion
  • HTTP Client: Built-in HTTP client with SSE streaming support
  • Zero Dependencies: No runtime dependencies

Installation

pnpm add @amux.ai/llm-bridge
# or
npm install @amux.ai/llm-bridge
# or
yarn add @amux.ai/llm-bridge

Quick Start

Create a Bridge

import { createBridge } from '@amux.ai/llm-bridge'
import { openaiAdapter } from '@amux.ai/adapter-openai'
import { anthropicAdapter } from '@amux.ai/adapter-anthropic'

const bridge = createBridge({
  inbound: openaiAdapter,
  outbound: anthropicAdapter,
  config: {
    apiKey: process.env.ANTHROPIC_API_KEY,
    baseURL: 'https://api.anthropic.com'
  }
})

// Send request in OpenAI format, get response in OpenAI format
// But actually calls Anthropic API under the hood
const response = await bridge.chat({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello!' }]
})

Streaming

for await (const chunk of bridge.chatStream({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true
})) {
  console.log(chunk)
}

Core Concepts

Intermediate Representation (IR)

The IR is the central data structure that all adapters convert to/from:

  • LLMRequestIR: Unified request format
  • LLMResponseIR: Unified response format
  • LLMStreamEvent: Unified streaming events
  • LLMErrorIR: Unified error format

Adapter Interface

Every adapter implements the LLMAdapter interface:

interface LLMAdapter {
  inbound: {
    parseRequest(request: unknown): Promise<LLMRequestIR>
    parseResponse(response: unknown): Promise<LLMResponseIR>
    parseStream(chunk: string): Promise<LLMStreamEvent | null>
    parseError(error: unknown): LLMErrorIR
  }
  outbound: {
    buildRequest(ir: LLMRequestIR): unknown
    buildResponse(ir: LLMResponseIR): unknown
  }
  capabilities: AdapterCapabilities
  getInfo(): AdapterInfo
}

Bridge Pattern

The Bridge orchestrates the conversion flow:

  1. Inbound adapter parses incoming request → IR
  2. Validate IR (optional)
  3. Outbound adapter builds provider request from IR
  4. Send HTTP request to target provider
  5. Outbound adapter parses response → IR
  6. Inbound adapter builds final response from IR

API Reference

createBridge(options)

Create a new bridge instance.

Options:

  • inbound - Inbound adapter instance
  • outbound - Outbound adapter instance
  • config - Configuration object
    • apiKey - API key for the outbound provider
    • baseURL - Base URL for the outbound provider (optional)
    • timeout - Request timeout in milliseconds (optional)
    • headers - Additional HTTP headers (optional)

Returns: Bridge instance

bridge.chat(request)

Send a chat completion request.

Parameters:

  • request - Request object in inbound adapter format

Returns: Promise<Response> - Response in inbound adapter format

bridge.chatStream(request)

Send a streaming chat completion request.

Parameters:

  • request - Request object in inbound adapter format with stream: true

Returns: AsyncIterable<string> - Server-Sent Events stream

Available Adapters

TypeScript Support

This package is written in TypeScript and provides full type definitions.

import type { 
  LLMRequestIR, 
  LLMResponseIR, 
  LLMAdapter,
  Bridge 
} from '@amux.ai/llm-bridge'

Contributing

Contributions are welcome! Please see our Contributing Guide.

License

MIT © isboyjc

Links