Modelflare Blog

Modelflare Blog

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

Diagram: one entry point routed to several model backends

Introducing Modelflare: one API key for text, image, and video models

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.

Diagram: a request passing through a compatible interface

Switching the OpenAI SDK to Modelflare (Python, JavaScript, curl)

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

Diagram: a coding agent connected through a gateway to several services

Configuring coding agents with Modelflare: Claude Code, Codex, OpenCode, Gemini CLI, CC-Switch, and Grok Build

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.

Diagram: parallel routes converging with fallback paths

Modelflare API recipes: streaming, routing fallback, images, and async video

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.

Illustration: a key module feeding a single route

Smart API Keys: one key for every model your account can use

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.

Illustration: parallel routes converging on one output

Model groups and failover: how Modelflare routes a request

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.

Illustration: a balance weighing request units

Usage and cost records: reading what each request cost

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.

Illustration: media inputs feeding a processing unit and a film strip

The Modelflare Media Skill: image and video generation from coding agents

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 cover: orbital ring city

Castaly: an AI video and image studio built on Modelflare

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.