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

@repochan/image-gen

v0.2.0

Published

Image generation library for RepoChan — prompt→PNG via OpenAI-compatible endpoints (sync + optional async queue). Credentials self-managed, no .repochan/ protocol writes.

Readme

@repochan/image-gen

Image generation library for RepoChan — prompt → PNG bytes via OpenAI-compatible HTTP, or natively through the Codex /responses backend (OAuth via codex login).

Modes (users usually ignore this)

| Configured mode | Behavior | |-------------------|----------| | auto (default) | Classic OpenAI submit (no X-Async-Mode). If the response has a job_id/task_id, poll. Host rules may upgrade to openai-async. | | openai | Force classic (no X-Async headers). | | openai-async | Force X-Async-Mode: true + async poll paths. |

Never re-POSTs a full generation after failure (no “try the other mode” — double-bill risk).

Host rules live in src/hostRules.ts (empty by default; add only when a host requires X-Async on submit). Advanced: REPOCHAN_IMAGE_MODE=openai-async or mode in config.

API

  • generate(params, config, options?){ success, image, mode, effectiveMode, modeSource, jobId?, billedRisk?, … }
    • params.referenceImages — array of {data, mimeType} for image-to-image conditioning. When provided, uses /images/edits (multipart); otherwise uses /images/generations (JSON). Multiple reference images are sent as repeated image[] multipart parts.
    • params.quality"low" | "medium" | "high" | "auto" (provider-side rendering quality). Typically sourced from the asset template's quality field.
  • loadConfig / saveGlobalConfig~/.repochan/image.json
  • listEndpointStatuses — configured + effective mode (no secrets)
  • probeEndpointGET /models (no bill)
  • resolveEffectiveMode / BUILTIN_HOST_RULES

Config example

{
  "version": 2,
  "defaultEndpoint": "example",
  "endpoints": {
    "example": {
      "id": "example",
      "baseURL": "https://api.openai.com/v1",
      "apiKey": "${OPENAI_KEY}",
      "model": "gpt-image-2",
      "mode": "auto"
    }
  }
}

Missing modeauto.

CLI

repochan image configure          # OpenAI | Codex | Custom OpenAI-compatible | skip
repochan image status             # shows mode → effectiveMode (+ auth=codex)
repochan image gen --prompt "…"

Advanced: --mode openai-async or config mode: "openai-async" for relays that require async submit headers.

Codex / ChatGPT login (auth.kind: codex)

Reach gpt-image-2 through the Codex /responses backend using the OAuth token from the official codex login. image-gen reads ~/.codex/auth.json (read-only) and refreshes short-lived access tokens itself — no separate reverse-proxy needed.

One-time setup:

codex login                       # official CLI writes ~/.codex/auth.json
repochan image configure --provider codex   # or pick "Codex (ChatGPT login)" interactively

This writes an endpoint with auth: { kind: "codex" }, pointed at https://chatgpt.com/backend-api/codex, model gpt-image-2. The apiKey field is left empty — the OAuth access token is injected per request.

{
  "version": 2,
  "defaultEndpoint": "codex",
  "endpoints": {
    "codex": {
      "id": "codex",
      "baseURL": "https://chatgpt.com/backend-api/codex",
      "apiKey": "",
      "model": "gpt-image-2",
      "auth": { "kind": "codex" }
    }
  }
}

Behavior & boundaries:

  • image-gen never writes back to ~/.codex/. Refreshed access tokens are cached at ~/.repochan/codex-token-cache.json (mode 0600).
  • A 401 from the upstream triggers one token refresh + retry (not a full generation replay — the global "never auto-retry" invariant still holds).
  • Only gpt-image-2 is supported on this transport.
  • repochan image probe on a codex endpoint resolves a valid token (exercising the refresh path) instead of GET /models, which the Codex backend lacks.
  • macOS note: codex login may store tokens in the Keychain rather than ~/.codex/auth.json. If loadCodexAuth can't find the file, re-login or use another provider.

Boundaries

Pure library: returns bytes, never writes project .repochan/ protocol artifacts. Credentials stay here — core has no API keys.