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

lightport

v2.11.2

Published

A lightweight AI gateway that makes LLM providers OpenAI-compatible.

Downloads

2,131

Readme

Lightport

A lightweight AI gateway that makes LLM providers OpenAI-compatible.

Goal

Lightport does one thing: it accepts OpenAI-compatible requests, transforms them for the target provider, and returns the response. That's it.

Retries, secret management, caching, rate limiting, and other operational concerns are explicitly non-goals. Those are better handled either at a service layer above Lightport or as custom middleware.

Supported endpoints:

  • POST /v1/chat/completions
  • POST /v1/completions
  • POST /v1/responses (+ GET, DELETE, input_items)
  • POST /v1/images/generations (served by the providers that offer image generation — OpenAI, Azure OpenAI, OpenRouter, Bedrock, Vertex AI, Stability AI and others; the rest answer 400)

Supported providers: OpenAI, Anthropic, Azure OpenAI, Google Gemini, Vertex AI, Bedrock, Cohere, Mistral, Groq, Deepseek, Together AI, Fireworks, Ollama, and more (77 total).

Background

Lightport started as a fork of Portkey AI Gateway. Our sole use case for the gateway has always been making AI providers OpenAI-compatible – we only needed the request/response transformation layer.

Since then, Portkey has evolved into a full-featured AI gateway with guardrails, fallbacks, automatic retries, load balancing, smart caching, usage analytics, cost management, and more. We believe those capabilities belong at a higher abstraction level – which is what Glama provides – rather than in the gateway itself.

Concretely, Lightport routes each request to a single provider, once. A config carrying strategy or targets is refused, because nothing here resolves a target; a config carrying retry or cache is served with a warning in the log, because nothing here acts on either. request_timeout is the exception in that list and is honoured.

Since forking, we have fixed numerous bugs, added integration tests for every provider, and continue to actively maintain the gateway as it directly powers Glama.

If you need a lightweight proxy that makes LLM providers OpenAI-compatible, Lightport is for you. If you need an enterprise gateway with all the bells and whistles, consider Portkey Gateway.

Quickstart

pnpx lightport

The gateway runs on http://localhost:8787.

From source

pnpm install
pnpm dev

Make a request

curl http://localhost:8787/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "x-lightport-provider: openai" \
  -H "Authorization: Bearer sk-YOUR-KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Set the provider via x-lightport-provider header and pass credentials via Authorization (or provider-specific headers like x-api-key for Anthropic).

Provider-specific headers

Some providers require additional headers:

| Provider | Headers | | ------------ | ----------------------------------------------------------------------------------------------------- | | Azure OpenAI | x-lightport-azure-resource-name, x-lightport-azure-deployment-id, x-lightport-azure-api-version | | Bedrock | x-lightport-aws-access-key-id, x-lightport-aws-secret-access-key, x-lightport-aws-region | | Vertex AI | x-lightport-vertex-project-id, x-lightport-vertex-region | | Custom host | x-lightport-custom-host |

HTTP proxy

Route provider requests through an HTTP proxy by setting the x-lightport-proxy-url header:

curl http://localhost:8787/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "x-lightport-provider: openai" \
  -H "x-lightport-proxy-url: http://user:[email protected]:8080" \
  -H "Authorization: Bearer sk-YOUR-KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Request timing

Every response carries a Server-Timing header breaking the request into stages, and the same breakdown is logged once per request:

server-timing: total;dur=3020.2, parse;dur=0.2, validate;dur=0.3, transform;dur=0.2,
               socket;dur=3.3, ttfb;dur=3007.5, read;dur=2.2

socket is time spent acquiring an upstream connection (queueing, DNS, TCP, TLS); ttfb is time spent waiting for the provider to answer. A slow gateway and a slow provider are indistinguishable from the outside — these tell them apart. The log line also reports send (writing the response back) and covers requests whose caller hung up before reading any header.

Scripts

pnpm dev           # Development server with hot reload
pnpm build         # Production build
pnpm start:node    # Start production server
pnpm test          # Run tests
pnpm lint          # Lint code
pnpm format        # Format and auto-fix
pnpm knip          # Find unused code/dependencies

Testing with provider credentials

Copy .env.example to .env and fill in API keys for the providers you want to test. Tests automatically load .env and skip providers without credentials.

cp .env.example .env
# fill in your keys
pnpm test

Architecture

Request
  -> bodyParser middleware (parse JSON/FormData)
  -> requestValidator (require provider header)
  -> handler (chatCompletions / completions / modelResponses)
    -> constructConfigFromRequestHeaders()
    -> tryPost()
      -> adapter transform (if needed for responses/messages API)
      -> provider lookup + transformToProviderRequest()
      -> fetch to provider
      -> responseHandler() (transform response back)
    -> Response

The provider system (src/providers/) contains 77 provider implementations. Each defines:

  • API config (base URL, endpoints, headers)
  • Request parameter transforms
  • Response transforms (streaming + non-streaming)