Images, audio, and moderation
Use compatible image generation, image edit, transcription, speech, and moderation endpoints.
These operations are available on adapters whose capability metadata marks them as supported.
Image generation
import { imageGeneration } from "any-llm-ts";
const image = await imageGeneration({
provider: "openai",
model: "gpt-image-1",
prompt: "A small robot reading TypeScript documentation",
size: "1024x1024",
outputFormat: "png",
});
console.log(image.data[0]?.url ?? image.data[0]?.b64Json);Image edit
import { imageEdit } from "any-llm-ts";
const edited = await imageEdit({
provider: "openai",
model: "gpt-image-1",
image: "./robot.png",
prompt: "Make the robot hold a TypeScript book",
});
console.log(edited.data[0]?.url ?? edited.data[0]?.b64Json);image accepts a filesystem path, bytes, a Blob, or a (filename, content[, mimeType]) tuple.
Pass an array when the provider accepts multiple reference images.
Gemini image models generate and edit through generateContent instead of OpenAI's Images API.
Pass a Nano Banana or *-image-* model, map size to an aspect ratio Gemini accepts, and read
b64Json plus optional usage. Gemini rejects responseFormat: "url" because it returns image
bytes. Vertex AI does not implement this path.
Bedrock edits images with Stability AI image services such as
us.stability.stable-image-inpaint-v1:0. Style Transfer takes two images; Fast Upscale, Remove
Background, and Erase Object take an empty prompt. Pass mask on the request, and seed or
output_format in providerOptions. Bedrock returns b64Json and rejects responseFormat: "url".
Audio transcription
import { readFile } from "node:fs/promises";
import { transcription } from "any-llm-ts";
const bytes = await readFile("meeting.mp3");
const result = await transcription({
provider: "openai",
model: "whisper-1",
file: bytes,
filename: "meeting.mp3",
});
console.log(result.text);Text to speech
import { writeFile } from "node:fs/promises";
import { speech } from "any-llm-ts";
const audio = await speech({
provider: "openai",
model: "gpt-4o-mini-tts",
voice: "alloy",
input: "Hello from any-llm-ts.",
responseFormat: "mp3",
});
await writeFile("speech.mp3", audio);OpenAI and Azure OpenAI take instructions, speed, and the usual formats (mp3, opus, aac,
flac, wav, pcm). Groq, Together, Mistral, Gemini, and DeepInfra also advertise speech, with
provider limits: Groq serves flac / mp3 / wav and rejects instructions; Together serves
mp3 / wav and rejects instructions and speed; Mistral Voxtral sends voice as voice_id
and rejects aac; Gemini TTS goes through generateContent and returns WAV (or raw PCM); DeepInfra
serves flac / mp3 / opus / pcm / wav and rejects instructions and aac. Vertex AI does
not inherit Gemini speech.
Moderation
import { moderation } from "any-llm-ts";
const result = await moderation({
input: "Text to classify",
});The stateless moderation helper defaults to openai when provider is omitted. Results normalize
the model, flagged state, category decisions, scores, and input categories while retaining the SDK
response in raw.
Capability flags are endpoint-level guidance
A true capability does not guarantee that every model offered by the provider implements the
operation. Validate the selected model against the provider's own documentation.