Claude Sonnet 4

Popular
Anthropic
Text & Chat

Anthropic's most capable model. Excellent for complex analysis, coding, math, and creative writing.

Examples

See what Claude Sonnet 4 can generate

Code Review

Review this function and suggest improvements: function add(a,b){return a+b}

The function works but could benefit from several improvements. Add TypeScript types for safety: `function add(a: number, b: number): number`. Consider input validation to handle edge cases like NaN or Infinity. You might also add JSDoc comments for documentation. For a utility function, consider making it part of a math utilities module rather than a standalone global function.

Creative Story

Write the opening paragraph of a sci-fi story set on a generation ship that has been traveling for 300 years

Captain Yara Chen pressed her palm against the observation deck glass, feeling the faint vibration of engines that had been running since before her great-great-grandmother was born. Outside, the stars looked the same as they always had—unchanged pinpricks against the void—but the ship's AI had confirmed it this morning: Kepler-442b was now close enough to resolve as a pale blue dot on the long-range sensors. Three hundred years of recycled air, artificial seasons, and carefully rationed hope were finally converging on something real.

Try Claude Sonnet 4

0.7

Response will appear here...

Sign up free to start generating
Get Started

Pricing

Price per Generation
Per generationFree

API Integration

Use our OpenAI-compatible API to integrate Claude Sonnet 4 into your application.

Install
npm install railwail
JavaScript / TypeScript
import railwail from "railwail";

const rw = railwail("YOUR_API_KEY");

// Simple — just pass a string
const reply = await rw.run("claude-sonnet-4", "Hello! What can you do?");
console.log(reply);

// With message history
const reply2 = await rw.run("claude-sonnet-4", [
  { role: "system", content: "You are a helpful assistant." },
  { role: "user", content: "Explain quantum computing simply." },
]);
console.log(reply2);

// Full response with usage info
const res = await rw.chat("claude-sonnet-4", [
  { role: "user", content: "Hello!" },
], { temperature: 0.7, max_tokens: 500 });
console.log(res.choices[0].message.content);
console.log(res.usage);
Specifications
Context window
200,000 tokens
Max output
8,192 tokens
Avg. latency
3.0s
Provider
Anthropic
Category
Text & Chat
Tags
popular
coding
analysis
Try this model

Free credits on sign-up

Start using Claude Sonnet 4 today

Get started with free credits. No credit card required. Access Claude Sonnet 4 and 100+ other models through a single API.