Engineering notes and setup guides for Modelflare, the API gateway for text, image, and video models, and for Castaly, the studio built on it.

Modelflare is an API gateway that serves text, image, and video models behind one key, with OpenAI-compatible, Anthropic, and Gemini endpoints and per-request cost records.

Existing OpenAI SDK code works with Modelflare after changing the base URL to https://modelflare.dev/v1 and supplying a Modelflare key.

Claude Code connects through Anthropic Messages at https://modelflare.dev, Codex, OpenCode, and Grok Build through https://modelflare.dev/v1, and Gemini CLI through GOOGLE_GEMINI_BASE_URL. All of them use the same Modelflare key.

Request examples for streaming chat, gateway-side fallback with group failover and Smart API Keys, client-side model fallback, image generation, and the asynchronous video task flow.

A Smart API Key is bound to auto instead of a fixed routing group. It resolves a group on each request and orders candidates by a routing strategy that you choose.

Every request depends on two identifiers: the exact model ID in the body and the routing group on the key. Ordinary keys add ordered fallback groups that take over when a route cannot serve the request.

Modelflare records token usage and cost for every request. This guide covers where those records live, how billing units differ between text, image, and video, the cache hit guarantee, and how long logs are kept.

The Media Skill is an installable SKILL.md package. With it, Claude Code, Codex, and other skill-aware agents can choose a Modelflare image or video model, quote its price, send the request, and save the result.

Seedance 2.0 and 2.5 do not accept a photorealistic person or a realistic face as an image URL. Upload the media to the asset library, poll until it is Active, and reference it as asset://<ID> in a video request.

Codex connects over the Responses API at https://modelflare.dev/v1. This guide covers the installer and the root/VPS variant with MODELFLARE_ALLOW_ROOT=1, every key in config.toml, the auth.json format, and the four documented problems.

Claude Code connects through Anthropic Messages with ANTHROPIC_BASE_URL set to https://modelflare.dev. This guide covers the installer and the root/VPS variant with MODELFLARE_ALLOW_ROOT=1, the env block in settings.json, the four model slots, and the documented error codes.

Castaly is a browser studio for AI image and video generation. Models are compared by specification and price, generations are paid from a wallet shared with Modelflare, and every model is also available through the Modelflare API.

A source-backed guide to GPT-6.1 Terra's visual reasoning, computer use, context limits, reasoning controls, pricing, and trade-offs against Astra, Sol, Luna, Claude Sonnet 5.5, and Gemini 3.8 Flash.

Production guide: Load Test an LLM API Without Misleading Results. It includes a deterministic artifact, failure boundaries, rollout checks, and source-qualified limitations.

A wire-level comparison of function definitions, Call IDs, result messages, streaming arguments, authorization, idempotency, and route compatibility.

A detailed, source-backed guide to Kimi K3.1 Pro and Highspeed: 1M context, disclosed architecture, reasoning and tool controls, USD/CNY prices, Claude/GLM/DeepSeek comparisons, and reproducible token budgets.

A production guide to backpressure for AI API workloads: bounded in-flight work, deadline-aware queues, load shedding, fairness, failure tests, and stop signals.

Trace an AI API Request Across Every Attempt: reproducible evidence, failure checks, bounded rollout, and clear production limits.

Make AI API Operations Idempotent with a practical artifact, failure boundaries, verification steps, and production-ready operating controls.

Handle 429s Without Retry Storms: reproducible evidence, failure checks, bounded rollout, and clear production limits.

Calculate LLM Token Cost Per Request: reproducible evidence, failure checks, bounded rollout, and clear production limits.

The value of Claude Haiku 5.5 is not only that it answers faster and costs less, but that it begins to turn model calls into infrastructure that can be deployed at scale.

A deep analysis of Claude Fable 5.2: 1M context, $8/$40 pricing, published benchmarks against Fable 5.1, Opus 5.5, GPT-6 Astra and Gemini 4 Carbon, cost per task, API breaking changes and Modelflare routes.

Enforce AI API Budgets Before Spend: reproducible evidence, failure checks, bounded rollout, and clear production limits.

Explore GPT-6.2 Astra and Sol through coding and reasoning benchmarks, long-context and cache costs, and a breakdown of Modelflare prices by group.

Route Across Models by Cost and Quality with a practical artifact, failure boundaries, verification steps, and production-ready operating controls.

Analyze Gemini 4 Argon, Carbon, Hydrogen, and Neon using public benchmark methods, coding scores, million-token context tests, and inference economics.

Allocate AI API Cost by Team and Workload: reproducible evidence, failure checks, bounded rollout, and clear production limits.

Detect AI API Cost Anomalies with a practical artifact, failure boundaries, verification steps, and production-ready operating controls.

Forecast LLM Usage and Spend: a production guide with an explicit decision, reusable artifact, failure tests, operating signals, and source-qualified limits.

Rotate AI API Keys Without Downtime: reproducible evidence, failure checks, bounded rollout, and clear production limits.