Official SDK

Railwail SDK

The simplest way to use every AI model. One function call — no boilerplate, no configuration, no base URLs to remember.

Installation

Terminal
npm install railwail

Zero dependencies. Works with Node.js 18+, Bun, and Deno. Supports both ESM and CommonJS.

Initialization

Create a client using the factory function or the class constructor.

TypeScript
import railwail from "railwail";

// Factory function (recommended)
const rw = railwail("rw_live_xxxxx");

// Or import the class directly
import { Railwail } from "railwail";

const rw = new Railwail("rw_live_xxxxx", {
  baseUrl: "https://railwail.com",  // default
  timeout: 120000,                   // 2 min default (ms)
});

Methods Overview

The SDK provides these methods for interacting with AI models.

MethodDescriptionReturns
rw.run()Universal method — auto-detects endpointstring | ImageResult[] | number[][]
rw.chat()Chat completions with full responseChatResponse
rw.image()Image generation from textImageResponse
rw.embed()Vector embeddingsEmbeddingResponse
rw.models()List available modelsModelListResponse
rw.model()Get specific model detailsModel
rw.job()Check async job statusJob

Start with rw.run()

If you're new to Railwail, start with rw.run(). It's the simplest way to use any model and handles routing automatically.

Automatic Type Inference

The SDK automatically detects the right endpoint based on the model name. Image models (Flux, DALL-E, Stable Diffusion) route to the image endpoint, embedding models route to the embedding endpoint, and everything else goes to chat completions.

You can override this with the type option:

TypeScript
// Auto-detected as "image"
await rw.run("flux-schnell", "A cat");

// Auto-detected as "embed"
await rw.run("text-embedding-3-small", "Hello");

// Force specific endpoint
await rw.run("my-custom-model", "Hello", { type: "chat" });
await rw.run("my-custom-model", "A cat", { type: "image" });
await rw.run("my-custom-model", "Hello", { type: "embed" });

Explore Methods