HERO RUN
Developer docs

If you can call OpenAI, you can call Hero Run.

One base URL, one key, 500+ models across 16 gateways. Use model auto and the router picks a right-sized model for every request at one flat price, paid in $HERO. Every call funds open-source AI.

Download .txt View /docs.txt
Base URL
https://herorunai.com/v1
Auth
Bearer hr_live_… mint a key →

Quickstart

The standard OpenAI client in any language. Just change the base URL.

from openai import OpenAI

client = OpenAI(base_url="https://herorunai.com/v1", api_key="hr_live_...")

r = client.chat.completions.create(
    model="auto",  # the router picks a right-sized model, one flat price
    messages=[{"role": "user", "content": "Explain CRDTs in one line"}],
)
print(r.choices[0].message.content)

Streaming works the standard way: pass stream: true and read SSE chunks. Works with the Vercel AI SDK, LangChain, CrewAI, LlamaIndex, and anything else that accepts an OpenAI base URL.

Official SDK: hero-run-ai

Zero-dependency JS/TS client with chat, streaming, image/video/audio generation, a Vercel AI SDK provider, and a drop-in React chat widget.

install
npm install hero-run-ai
javascript
import { createHeroRun } from "hero-run-ai";

const hero = createHeroRun({ apiKey: process.env.HERO_RUN_KEY });

const { text, hero: meta } = await hero.chat([{ role: "user", content: "hi" }]);
const img = await hero.generate({ kind: "image", prompt: "a molten flame mascot" });

// Vercel AI SDK:  import { createHeroRunProvider } from "hero-run-ai/ai-sdk"
// React widget:   import { HeroRunChat } from "hero-run-ai/react"

Routing modes

Modes are just model ids, with no custom parameters.

autoReads your prompt and routes to a right-sized model: best quality per dollar. Same as optimized.
default
cheapestAlways the cheapest trusted model, regardless of prompt complexity.
lowest cost
fastestThe fastest model on its fastest gateway, by measured speed.
lowest latency
openai/gpt-oss-120bOr any of the 500+ catalog ids (see GET /v1/models).
specific

Each response carries an x_hero field with the router's decision: tier, resolved model, gateway, and the $HERO charged.

Pin a gateway. Append @gateway to any model id to force that exact provider instead of cheapest-first routing: openai/gpt-oss-120b@cerebras, glm-5.2@fireworks, qwen/qwen3.8-27b@openrouter. Works everywhere a model id goes: /v1, the native API, the MCP server, and the SDKs. Billing uses the pinned gateway's own price, and there's no failover, so you get exactly what you asked for. Gateway ids: openrouter, cerebras, cloudflare, fireworks, deepinfra, together, baseten, bfl, wavespeed, fal.

Function calling

Pass tools in the standard OpenAI format; the model's tool_calls come back with finish_reason: "tool_calls", and you return results as role: "tool" messages. Tool turns respond unstreamed.

function calling
tools = [{"type": "function", "function": {
    "name": "get_price",
    "description": "Get a token price in USD",
    "parameters": {"type": "object", "properties": {"symbol": {"type": "string"}}, "required": ["symbol"]},
}}]

r = client.chat.completions.create(model="auto", messages=messages, tools=tools)
call = r.choices[0].message.tool_calls[0]          # finish_reason == "tool_calls"

messages += [r.choices[0].message,                  # then send the result back:
             {"role": "tool", "tool_call_id": call.id, "content": '{"usd": 0.00000022}'}]
r2 = client.chat.completions.create(model="auto", messages=messages, tools=tools)

Images, audio & video

The catalog covers more than text. Generate images through the native API with kind: "image". Model auto routes to the image pool at one flat price, or pick a specific model (Nano Banana / Gemini image, GPT Image, FLUX). The response carries a data:image/png;base64 URI.

import base64, requests

r = requests.post("https://herorunai.com/api/run",
    headers={"x-api-key": "hr_live_..."},
    json={"model": "auto",                    # flat-price image routing, or any image model id
          "input": "a molten-orange anime flame mascot, token logo",
          "kind": "image"})
data_uri = r.json()["image"]                  # "data:image/png;base64,..."
open("out.png", "wb").write(base64.b64decode(data_uri.split(",")[1]))
Images16 models live: Gemini image (Nano Banana), GPT Image, and the FLUX line. Also the MCP server's generate_image tool.
live
AudioSpeech (GPT Audio) and music (Lyria), same call shape with kind: "audio". The response carries a playable data:audio/wav URI plus the transcript as text.
live
VideoText-to-video via WaveSpeed, from wavespeed-ai/wan-2.2/t2v-480p-ultra-fast up to Kling 2.5 and Seedance 2.0. Same call shape with kind: "video"; the response's video is the finished MP4's URL. Clips take 1–3 minutes.
live

Browse what's live right now: GET /api/models and filter by kind.

Agents & MCP

MCP server (one paste)
Any MCP agent (Claude Code, Codex, Cursor…) gets all 500+ models as tools. The setup prompt lives on the API page; the server itself is /hero-run-mcp.mjs.
Agent memory (wallet mode)
The same server gives an agent a memory it owns: memory_mint, memory_checkpoint, memory_recall, plus file attach and export. Set AGENT_PRIVATE_KEY and fund it with a little ETH on Robinhood Chain for gas. Self-hosted by design: the key never leaves your machine, so nobody, not even us, can read your memory. That is why it is not on any hosted connector.
Machine-readable docs
Point an agent at /llms.txt for endpoints, auth, tools support, and the one-paste setup, in a format models read well.
Swarm, from your own agent
Connect the MCP server to Claude Code, Cursor, or Codex, then just ask it to build your idea by splitting the work across a few models at once. Same pattern also runs in-browser at /swarm.
Coding agents (custom model)
Point a coding agent's brain at Hero Run and it thinks on any of the 500+ models, paid in $HERO. Anything that takes an OpenAI-compatible base_url works: Grok Build, DeepSeek Harness (dsh), opencode, Cursor, Cline, Aider. Config below. Add the MCP server too and it can mint + recall its own on-chain memory.

Grok Build (and any custom-model agent)

Grok Build takes a custom model in ~/.grok/config.toml. Point it at Hero Run's /v1 (Chat Completions, with tools + streaming) and it runs on our catalog, billed to your key in $HERO.

~/.grok/config.toml
[model.hero-run]
model = "auto"                          # or any catalog id, e.g. openai/gpt-oss-120b
base_url = "https://herorunai.com/v1"
name = "Hero Run (paid in $HERO)"
env_key = "HERO_RUN_KEY"

[models]
default = "hero-run"
then
export HERO_RUN_KEY=hr_live_...          # mint one at https://herorunai.com/keys
grok -m hero-run -p "Explain this repo"  # or just: grok

dsh (DeepSeek Harness) example, in ~/.dsh/settings.yaml: point a provider at the base URL and pick a default.

yaml
llm-pi-ai:
  providers:
    hero-run:
      apiKeyEnv: HERO_RUN_KEY
      api: openai-completions
      baseURL: https://herorunai.com/v1
      models:
        - id: auto
        - id: cheapest
agent-default-model:
  provider: hero-run
  model: auto

For on-chain memory (mint / checkpoint / recall), also add the Hero Run MCP server. The one-paste setup on the API page covers Grok Build, opencode, Claude Code, Codex, and Cursor. Note: use the base_url / Chat Completions path above; Hero Run does not serve the OpenAI Responses API.

Native HTTP API

Prefer plain endpoints? Same key, same billing.

native HTTP API
GET  https://herorunai.com/api/models              # catalog + $HERO prices
POST https://herorunai.com/api/run                 # {"model":"auto","input":"...","kind":"text"}   header: x-api-key
GET  https://herorunai.com/api/keys/info           # prepaid balance                                header: x-api-key
GET  https://herorunai.com/api/gateways            # live per-gateway speed (tok/s, TTFT)
Mint an API key Live speed & routingWhy $HERO?

No signup, no per-provider accounts. Mint a key with a Base wallet, or pay per call on-chain. Usage funds open-source AI, which is the whole point.