Developers
AI API guides by language
Copy-paste guides for calling 50+ models through one OpenAI-compatible endpoint in your language.
AI API for Python
How to call 50+ AI models from Python with the official openai Python package: setup, a basic request, streaming, and JSON output through one OpenAI-compatible endpoint.
AI agents in Python with an AI API
Step-by-step Python code for AI agents using the official openai Python package and Somnus: model choice, the key API feature, and pitfalls to avoid.
Summarization in Python with an AI API
Step-by-step Python code for summarization using the official openai Python package and Somnus: model choice, the key API feature, and pitfalls to avoid.
AI API for JavaScript (Node.js)
How to call 50+ AI models from JavaScript (Node.js) with the official openai npm package: setup, a basic request, streaming, and JSON output through one OpenAI-compatible endpoint.
AI API for TypeScript
How to call 50+ AI models from TypeScript with the official openai npm package (fully typed): setup, a basic request, streaming, and JSON output through one OpenAI-compatible endpoint.
AI API for Next.js
How to call 50+ AI models from Next.js with the openai npm package inside a server route: setup, a basic request, streaming, and JSON output through one OpenAI-compatible endpoint.
Chatbots in Next.js with an AI API
Step-by-step Next.js code for chatbots using the openai npm package inside a server route and Somnus: model choice, the key API feature, and pitfalls to avoid.
AI API for Go
How to call 50+ AI models from Go with Go's standard net/http package: setup, a basic request, streaming, and JSON output through one OpenAI-compatible endpoint.
AI API for PHP
How to call 50+ AI models from PHP with PHP's built-in cURL extension: setup, a basic request, streaming, and JSON output through one OpenAI-compatible endpoint.
AI API for Ruby
How to call 50+ AI models from Ruby with Ruby's standard Net::HTTP: setup, a basic request, streaming, and JSON output through one OpenAI-compatible endpoint.
AI API for REST (curl)
How to call 50+ AI models from REST (curl) with plain HTTPS requests: setup, a basic request, streaming, and JSON output through one OpenAI-compatible endpoint.
Claude Opus 5.5 API pricing & cost per request
Claude Opus 5.5 API price: $4 / $20 per 1M input/output tokens, $2 / $10 effective on Somnus. Real cost per request for 4 workloads.
Claude Opus 5 API pricing & cost per request
Claude Opus 5 API price: $5 / $25 per 1M input/output tokens, $2.5 / $12.5 effective on Somnus. Real cost per request for 4 workloads.
Claude Sonnet 5 API pricing & cost per request
Claude Sonnet 5 API price: $2 / $10 per 1M input/output tokens, $1 / $5 effective on Somnus. Real cost per request for 4 workloads.
Claude Haiku 4.5 API pricing & cost per request
Claude Haiku 4.5 API price: $1 / $5 per 1M input/output tokens, $0.5 / $2.5 effective on Somnus. Real cost per request for 4 workloads.
GPT-5.6 Sol API pricing & cost per request
GPT-5.6 Sol API price: $5 / $30 per 1M input/output tokens, $2.5 / $15 effective on Somnus. Real cost per request for 4 workloads.
GPT-5.6 Luna API pricing & cost per request
GPT-5.6 Luna API price: $1 / $6 per 1M input/output tokens, $0.5 / $3 effective on Somnus. Real cost per request for 4 workloads.
Gemini 3.1 Pro API pricing & cost per request
Gemini 3.1 Pro API price: $2 / $12 per 1M input/output tokens, $1 / $6 effective on Somnus. Real cost per request for 4 workloads.
Gemini 3.8 Flash API pricing & cost per request
Gemini 3.8 Flash API price: $0.75 / $3.75 per 1M input/output tokens, $0.38 / $1.88 effective on Somnus. Real cost per request for 4 workloads.
Grok 4.7 API pricing & cost per request
Grok 4.7 API price: $2 / $6 per 1M input/output tokens, $1 / $3 effective on Somnus. Real cost per request for 4 workloads.
DeepSeek V4 Pro API pricing & cost per request
DeepSeek V4 Pro API price: $0.66 / $1.98 per 1M input/output tokens, $0.33 / $0.99 effective on Somnus. Real cost per request for 4 workloads.
DeepSeek V4 Flash API pricing & cost per request
DeepSeek V4 Flash API price: $0.22 / $0.66 per 1M input/output tokens, $0.11 / $0.33 effective on Somnus. Real cost per request for 4 workloads.
Kimi K3 API pricing & cost per request
Kimi K3 API price: $3 / $15 per 1M input/output tokens, $1.5 / $7.5 effective on Somnus. Real cost per request for 4 workloads.
GLM 5.3 API pricing & cost per request
GLM 5.3 API price: $1.4 / $4.4 per 1M input/output tokens, $0.7 / $2.2 effective on Somnus. Real cost per request for 4 workloads.
Qwen 3.8 Max API pricing & cost per request
Qwen 3.8 Max API price: $1.65 / $4.95 per 1M input/output tokens, $0.83 / $2.48 effective on Somnus. Real cost per request for 4 workloads.
MiMo V2.5 Pro API pricing & cost per request
MiMo V2.5 Pro API price: $0.44 / $0.87 per 1M input/output tokens, $0.22 / $0.44 effective on Somnus. Real cost per request for 4 workloads.