Quick Start

Get up and running with Railwail in under a minute.

1

Get your API key

Go to the Settings page to create your API key. Keys are prefixed with rw_live_ for production use.

2

Install

Install the official Railwail SDK from npm. It has zero dependencies and works with both JavaScript and TypeScript.

Terminal
npm install railwail
3

Make your first request

Two lines of code to generate text, images, or anything else. The rw.run() method auto-detects the right endpoint based on the model.

TypeScript
import railwail from "railwail";

const rw = railwail("rw_live_xxxxx");

// Text generation
const reply = await rw.run("gpt-4o", "Explain quantum computing");
console.log(reply);

// Image generation
const images = await rw.run("flux-schnell", "A sunset over Tokyo");
console.log(images[0].url);

Universal method

rw.run() is the easiest way to get started — it returns a simple string for text models and an array for image models. For full response objects with usage stats, use the specific methods like rw.chat() and rw.image().

More Examples

Chat with message history

Pass an array of messages to have a conversation with context.

TypeScript
const reply = await rw.run("claude-sonnet-4-5-20250929", [
  { role: "system", content: "You are a helpful coding assistant." },
  { role: "user", content: "How do I reverse a string in Python?" },
]);
console.log(reply);

Generate images with options

Generate images with custom size, count, and negative prompts.

TypeScript
const res = await rw.image("flux-schnell", "A cyberpunk cityscape", {
  size: "1024x1024",
  n: 2,
  negative_prompt: "blurry, low quality",
});

for (const img of res.data) {
  console.log(img.url);
}

Generate embeddings

Create vector embeddings for semantic search and RAG applications.

TypeScript
const res = await rw.embed("text-embedding-3-small", [
  "How do I reset my password?",
  "I forgot my login credentials",
  "What are your pricing plans?",
]);

for (const item of res.data) {
  console.log(item.embedding.length); // 1536 dimensions
}

Next Steps