The railwail SDK is JavaScript/TypeScript only; there is no Python package. Python tabs on this page use the official OpenAI SDK with base_url="https://railwail.com/api/v1". OpenAI compatibility
This page documents the railwail npm SDK. cURL tabs call the same REST endpoints directly; see the REST API reference.
SDK · images
rw.image()
Generate images from a prompt. Calls POST /api/v1/images/generations and returns the image URLs. The key needs the images scope.
Signature
rw.image(model: string, prompt: string, options?: ImageOptions): Promise<ImageResponse>Parameters
Only model and prompt work for every model. The other options are passed on and used only where the model has that input; each model page lists its inputs.
modelrequiredpromptrequiredoptions.n1options.sizeoptions.qualityoptions.styleoptions.negative_promptResponse
interface ImageResponse {
created: number;
data: {
url: string; // null while the run is still processing (HTTP 202)
revised_prompt?: string; // your prompt, unchanged
// also present at runtime, not in the 1.0.0 types:
// job_id: string; status: "completed" | "processing"
}[];
}Keep the file, not the link
url can point to the provider's storage and expire after a while, so download images you want to keep. If a run takes longer than about 85 seconds, the answer comes back with url: null and a job_id; fetch the result later with rw.job().Examples
Basic
import railwail from "railwail";
const rw = railwail(process.env.RAILWAIL_API_KEY);
const res = await rw.image("flux-1-schnell", "A beautiful sunset over Tokyo");
console.log(res.data[0].url);Several images
const res = await rw.image("flux-1-schnell", "A cyberpunk cityscape, neon, rain", { n: 2 });
for (const img of res.data) {
console.log(img.url ?? "still processing");
}Other models
Use any slug from the list below. For models with extra inputs (styles, reference images, aspect ratios) the model page shows the full input form and API code; the REST reference is Image Generation.
const res = await rw.image("flux-1-1-pro", "Product photo of a ceramic mug, studio light");Image models you can call
- FLUX 1.1 Pro
flux-1-1-pro$0.048/image - Flux 1.1 Pro Ultra
flux-pro-ultra$0.072/image - Flux Dev
flux-dev$0.0384/image - Google Imagen 4
imagen-4-flagship$0.048/image - Icons (SDXL Flat Pop)
galleri5-icons-replicate≈ $0.0094/run - Ideogram v3 Quality
ideogram-v3-quality$0.108/image - Recraft 20B SVG
recraft-20b-svg-replicate$0.0528/image - Sticker Maker
sticker-maker-replicate≈ $0.0055/run