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 · universal method
rw.run()
The shortest way to call a model: a string back for chat, an array of images for image models, vectors for embeddings. The SDK picks the endpoint from the model slug; the type option overrides it.
Signature
rw.run(model: string, input: string | ChatMessage[], options?: RunOptions): Promise<RunResult>Parameters
modelrequiredinputrequiredoptions.typeoptions.max_tokensoptions.temperatureoptions.top_poptions.noptions.sizeoptions.negative_promptReturn value
| Endpoint | Returns | Notes |
|---|---|---|
| Chat | string | The assistant's text. Use rw.chat() for usage and finish_reason. |
| Image | ImageResult[] | Objects with url. At runtime they also carry job_id and status; url is null while a slow run is still processing (see rw.job()). |
| Embedding | number[][] | One vector per input, in input order. |
Examples
All examples assume const rw = railwail(process.env.RAILWAIL_API_KEY) in an ES module (see Overview).
Text from a prompt
const text = await rw.run("gpt-4o-mini", "Explain quantum computing simply.", { max_tokens: 300 });
console.log(text);Chat with a system prompt
const reply = await rw.run(
"claude-sonnet-4-6",
[
{ role: "system", content: "You are a pirate." },
{ role: "user", content: "Tell me a joke." },
],
{ max_tokens: 200 },
);
console.log(reply);Image generation
The key needs the images scope.
const images = await rw.run("flux-1-schnell", "A cat in space, watercolor");
console.log(images[0].url); // may be a temporary provider URL: download it to keep itForce the endpoint
The SDK recognises image models by a built-in list and the substrings flux, dall-e, stable-diffusion, ideogram and recraft; embeddings by embed. Anything else goes to chat, so tell it:
const imgs = await rw.run("imagen-4-flagship", "A lighthouse at dusk", { type: "image" });Not for video or speech
rw.run() they would go to chat and fail with 400 model_not_supported. Use video generation or audio speech.