Claude Sonnet 4
Anthropic's most capable model. Excellent for complex analysis, coding, math, and creative writing.
Examples
See what Claude Sonnet 4 can generate
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.
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.
0.7
Response will appear here...
Pricing
API Integration
Use our OpenAI-compatible API to integrate Claude Sonnet 4 into your application.
npm install railwailimport 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);Free credits on sign-up
Related Models
View all Text & ChatClaude Opus 4
Anthropic's most powerful model. Exceptional at complex analysis, agentic tasks, and extended reasoning.
GPT-4.1
OpenAI's newest flagship model. Improved reasoning, instruction following, and coding over GPT-4o.
GPT-4.5 Preview
OpenAI's latest frontier model with improved reasoning, creativity, and instruction following. Significant improvements over GPT-4o.
GPT-4o
OpenAI's most capable multimodal model. Excellent for complex reasoning, coding, and creative tasks.
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.