pipedog is an unofficial community port of Pipecat, not affiliated with Daily.
pipedog
Image generation

OpenAI

Image generation with OpenAIImageGenService, using OpenAI's GPT Image models.

Overview

  • OpenAIImageGenService: turns each TextFrame it receives into a prompt for OpenAI's Images API (images.generate) and pushes the result as a URLImageRawFrame of RGB pixels.

Installation

bun add @pipedog/openai
import { OpenAIImageGenService } from "@pipedog/openai/image";

Prerequisites

  • An OpenAI account and an API key from the OpenAI dashboard.
  • Pass the key as apiKey (required). The examples read it from OPENAI_API_KEY.

OpenAIImageGenService

Configuration

Prop

Type

Settings

Runtime-updatable settings, passed as settings: new OpenAIImageGenService.Settings({...}) (OpenAIImageGenSettings). Any setting you leave out keeps the default below.

SettingTypeDefaultDescription
modelstring"gpt-image-2.5-flare"Image model.
imageSizeOpenAIImageSize | string | nullnull"auto", "1024x1024", "1536x1024", "1024x1536", ... null leaves it to OpenAI.
qualityOpenAIImageQuality | string | nullnull"auto", "low", "medium", "high", ... Lower is faster. null lets OpenAI pick.
moderationOpenAIImageModeration | string | nullnullContent-moderation level for generated images: "low" for less restrictive filtering, or "auto". null leaves OpenAI's default.

Usage

image.ts
import { OpenAIImageGenService } from "@pipedog/openai/image";

const imageGen = new OpenAIImageGenService({
  apiKey: process.env.OPENAI_API_KEY ?? "",
  settings: new OpenAIImageGenService.Settings({
    model: "gpt-image-2.5-flare",
    imageSize: "1024x1024",
    quality: "low",
  }),
});

Notes

  • Each TextFrame is pushed on downstream, then used as the prompt. One image is generated per prompt (n: 1).
  • The GPT Image models return the image inline (base64). When the response carries a URL instead, the image is downloaded with fetch (the global one, or the fetch option) and the URL is set on the frame.
  • The image is decoded to RGB (alpha dropped) with decodePngToRgb, a pure JS PNG decoder. Pass decodeImage to decode other formats.
  • A response with no image data produces an ErrorFrame.
  • As upstream, the constructor passes only settings to the base service, so the inherited frame processor options (such as name) have no effect.

Runtime notes

RuntimeWorksWhat it needs
Bun✅ yesNothing.
Node.js✅ yesNothing.
Deno✅ yesNothing.
Cloudflare Workers✅ yesNothing.

Generated from pipecat.runtimes and pipecat.compat in packages/openai/package.json: ✅ means the compat smoke test passes on that runtime.

  • The client is the openai JS SDK over fetch, and decoding is pure JS (fast-png), so it works on Bun, Node, Deno and Cloudflare Workers.
  • The fetch option replaces upstream's required aiohttp_session. decodeImage is a pipedog addition; upstream decodes with Pillow.
  • The deprecated imageSize and model constructor options are not ported. Use settings.
  • For Azure OpenAI image generation, see AzureImageGenServiceREST.

pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.

Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).

On this page