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

@derogab/llm-proxy

v0.4.1

Published

A simple and lightweight proxy for seamless integration with multiple LLM providers including OpenAI, Ollama, and Cloudflare AI

Downloads

522

Readme

llm-proxy

A simple and lightweight proxy for seamless integration with multiple LLM providers including OpenAI, Ollama, Cloudflare AI, and Llama.cpp.

Features

  • Multi-provider support: Switch between OpenAI, Ollama, Cloudflare AI, and Llama.cpp with environment variables.
  • TypeScript support: Full TypeScript definitions included.
  • Simple API: Single function interface for all providers.
  • Automatic provider detection: Automatically selects the best available provider based on environment variables.

Installation

npm install @derogab/llm-proxy

Quick Start

import { generate } from '@derogab/llm-proxy';

const messages = [
  { role: 'user', content: 'Hello, how are you?' }
];

const response = await generate(messages);
console.log(response.content);

Configuration

The package automatically detects which LLM provider to use based on your environment variables.
Configure one or more providers:

Provider Selection

LLM_PROVIDER=openai # Optional, explicitly select a provider (openai, cloudflare, ollama, llama.cpp)

When LLM_PROVIDER is set, the package will use that specific provider and skip automatic detection. This is useful when you have multiple providers configured but want to force a specific one. If the required credentials for the specified provider are not configured, an error will be thrown. If not set, consider provider priority.

Note: The legacy PROVIDER environment variable is still supported as a fallback for backward compatibility, but LLM_PROVIDER takes precedence when both are set.

OpenAI

OPENAI_API_KEY=your_openai_api_key # Required
OPENAI_BASE_URL=https://api.openai.com/v1 # Optional
OPENAI_MODEL=gpt-4o-mini                  # Optional, defaults to gpt-4o-mini

Cloudflare AI

CLOUDFLARE_ACCOUNT_ID=your_account_id # Required
CLOUDFLARE_AUTH_KEY=your_auth_key # Required
CLOUDFLARE_MODEL=your_model_name # Required

Ollama (Local)

OLLAMA_URI=http://localhost:11434 # Optional, defaults to http://localhost:11434
OLLAMA_MODEL=llama3.1             # Optional, defaults to llama3.1

Llama.cpp (Local)

LLAMA_CPP_MODEL_PATH=/path/to/your/model.gguf # Required, path to your GGUF model file

API Reference

generate(messages: MessageInputParam[]): Promise<MessageInputParam>

Generates a response from the configured LLM provider.

Parameters:

  • messages: Array of message objects with role and content properties

Returns:

  • Promise that resolves to a message object with role and content properties

Message Format:

type MessageInputParam = {
  role: 'user' | 'assistant' | 'system';
  content: string;
};

Provider Priority

If the LLM_PROVIDER environment variable is set (or the legacy PROVIDER as fallback), the specified provider will be used directly (valid values: openai, cloudflare, ollama, llama.cpp).

Otherwise, the package selects providers automatically in the following order:

  1. OpenAI (if OPENAI_API_KEY is set)
  2. Cloudflare AI (if CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_AUTH_KEY, and CLOUDFLARE_MODEL are set)
  3. Ollama (if OLLAMA_URI is set)
  4. Llama.cpp (if LLAMA_CPP_MODEL_PATH is set)

If no providers are configured, the function throws an error.

Development

# Install dependencies
npm install

# Build the package
npm run build

Credits

LLM Proxy is made with ♥ by derogab and it's released under the MIT license.

Contributors

Tip

If you like this project or directly benefit from it, please consider buying me a coffee:
🔗 bc1qd0qatgz8h62uvnr74utwncc6j5ckfz2v2g4lef
⚡️ [email protected]
💶 Sponsor on GitHub

Stargazers over time

Stargazers over time