OpenAI Compatibility

The Railwail API is fully compatible with the OpenAI SDK. Use it as a drop-in replacement — just change the base URL and API key.

Why use the OpenAI SDK?

If you already have code using the OpenAI SDK, you can switch to Railwail without changing any of your application logic. Just update the configuration.

Setup

javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "rw_live_xxxxx",
  baseURL: "https://railwail.com/api/v1",
});

Chat Completions

Use any model through the familiar chat.completions.create method. You can use models from OpenAI, Anthropic, Google, Meta, and more.

javascript
// Use any model through the same interface
const response = await client.chat.completions.create({
  model: "gpt-4o", // or "claude-sonnet-4-5-20250929", "gemini-pro", etc.
  messages: [{ role: "user", content: "Hello!" }],
  temperature: 0.7,
  max_tokens: 500,
});

console.log(response.choices[0].message.content);

Image Generation

javascript
const response = await client.images.generate({
  model: "flux-schnell",
  prompt: "A beautiful sunset over Tokyo",
  size: "1024x1024",
});

console.log(response.data[0].url);

Embeddings

javascript
const response = await client.embeddings.create({
  model: "text-embedding-3-small",
  input: "Hello world",
});

console.log(response.data[0].embedding.length); // 1536

Supported Endpoints

OpenAI MethodRailwail EndpointStatus
chat.completions.create/api/v1/chat/completionsSupported
images.generate/api/v1/images/generationsSupported
embeddings.create/api/v1/embeddingsSupported
models.list/api/v1/modelsSupported

Related