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.

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.