Local & self-hosted agents

Local Agent API — LangGraph, OpenClaw & Self-Hosted Agent Loops

Run LangGraph, OpenClaw, or custom agent orchestration on your machine — route each hop through LumeAPI with OpenAI-compatible Chat Completions and swap model id per step.

Agents multiply tokens per user action. Cheap steps on Flash or mini; hard reasoning on Sonnet or Sol — same API key and base URL.

  • One API key
  • Dozens of models
  • Text, image & video
  • Up to 70% off

Mainstream agent routing models

Official reference vs LumeAPI catalog rates. Pricing unit: per 1M input / output tokens. Last updated: 2026-07-22. Source: provider list price.

ModelOfficial (in / out)LumeAPI (in / out)Savings
GPT-5.6 Solgpt-5.6-sol$5.00 / $30.00$1.50 / $9.0070% offDetails →
GPT-5.6 Terragpt-5.6-terra$2.50 / $15.00$0.75 / $4.5070% offDetails →
GPT-5.5gpt-5.5$5.00 / $30.00$1.50 / $9.0070% offDetails →
GPT-5.4gpt-5.4$2.50 / $15.00$0.75 / $4.5070% offDetails →
Claude Fable 5claude-fable-5$10.00 / $50.00$5.00 / $25.0050% offDetails →
Claude Opus 4.8claude-opus-4-8$5.00 / $25.00$2.50 / $12.5050% offDetails →
Claude Opus 4.7claude-opus-4-7$5.00 / $25.00$2.50 / $12.5050% offDetails →
Claude Sonnet 4.6claude-sonnet-4-6$3.00 / $15.00$1.50 / $7.5050% offDetails →
Gemini 3.1 Progemini-3.1-pro-preview$2.00 / $12.00$1.00 / $6.0050% offDetails →
GPT-5.4 minigpt-5.4-mini$0.75 / $4.50$0.225 / $1.3570% offDetails →
Gemini 3.5 Flashgemini-3.5-flash$1.50 / $9.00$0.75 / $4.5050% offDetails →
Gemini 3 Flashgemini-3-flash$0.50 / $3.00$0.25 / $1.5050% offDetails →

Monthly cost examples

Illustrative totals for claude-sonnet-4-6 using catalog list prices — your actual bill depends on retries, tool loops, and output length.

Support agent (5 hops)

40M input + 12M output tokens / month

Flash plan + Sonnet execute

Official (Claude Sonnet 4.6)
$300.00/mo
LumeAPI
$150.00/mo
Monthly savings
$150.0050% off

Rates last updated 2026-07-22

Research agent (12 hops)

120M input + 45M output tokens / month

Long tool loops

Official (Claude Sonnet 4.6)
$1,035.00/mo
LumeAPI
$517.50/mo
Monthly savings
$517.5050% off

Rates last updated 2026-07-22

Keep the agent runtime local; centralize model access at the gateway

Last verified: 2026-07-25

A local agent architecture does not require local inference. Run LangGraph, LangChain, or OpenClaw on your workstation, VM, container platform, or private network, then send only model requests through LumeAPI. Your agent process keeps ownership of tool execution, state, secrets, retrieval indexes, shell access, and approval workflows. LumeAPI provides the OpenAI-compatible Chat Completions endpoint the agent uses for text generation.

Point OpenAI-compatible clients at https://api.lumeapi.site/v1 and authenticate with a Bearer API key from the LumeAPI Console. The base URL must stop at /v1. Do not append /chat/completions in LangChain, LangGraph, OpenClaw, or SDK client configuration; those clients construct the Chat Completions path themselves.

The practical advantage is per-hop routing. A graph does not need to use one expensive model from intake through final answer. Use gemini-3-flash for classification and lightweight extraction, gpt-5.4-mini for plans and tool selection, claude-sonnet-4-6 for synthesis, and gpt-5.6-sol only when the task has earned escalation. This makes model choice an explicit part of graph design instead of a global application setting.

LumeAPI is an independent service. It is not OpenAI, Anthropic, or Google.

Route each agent hop by task shape, not provider branding

Last verified: 2026-07-25

Use stable catalog IDs in graph nodes and routing rules. The rates below are LumeAPI catalog input/output prices as updated 2026-07-22.

Agent hopRecommended modelWhy this tier fitsLumeAPI input / output rateEscalate when
Intent classification, triage, extractiongemini-3-flashLow-cost first pass for deciding whether a request needs tools, retrieval, or human review.$0.25 / $1.50The request is ambiguous, high-risk, or requires multi-step reasoning.
Planning, tool selection, graph routinggpt-5.4-miniGood default planner when the node must turn a request into structured next actions without paying for a top-tier model on every hop.$0.225 / $1.35The plan repeatedly fails validation or requires deeper technical judgment.
Research synthesis, user-facing draftingclaude-sonnet-4-6Use where the agent must combine retrieved evidence, tool outputs, and instructions into a coherent final response.$1.50 / $7.50The task has material business impact, difficult reasoning, or unresolved contradictions.
Complex escalation and final reviewgpt-5.6-solReserve for exception paths: difficult diagnosis, high-stakes review, and complex final decisions.$1.50 / $9.00A human review queue or a narrower specialist workflow is more appropriate.
High-capability generalist alternativegpt-5.6-terraA higher-tier option for nodes that need more than a mini model but do not require the designated escalation route.$0.75 / $4.50The graph needs the stricter escalation policy assigned to gpt-5.6-sol.

Rates are catalog figures, not a promise about the total cost of an agent run. Tool calls, retries, long prompts, retrieved context, and output limits still determine spend.

Build a LangGraph with model ownership at the node level

Last verified: 2026-07-25

LangGraph supports separate model instances per node. Treat that as a production control: each node should have an assigned task, model, output contract, timeout policy, and escalation condition.

  • 1. Create a LumeAPI API key in the Console and store it in the runtime secret manager rather than in graph source code.
  • 2. Set OPENAI_API_KEY to that key and set OPENAI_BASE_URL to https://api.lumeapi.site/v1 in the process environment.
  • 3. Create separate ChatOpenAI instances for gemini-3-flash, gpt-5.4-mini, claude-sonnet-4-6, and gpt-5.6-sol. Set base_url to https://api.lumeapi.site/v1 on every instance when you need explicit configuration.
  • 4. Put classification in its own LangGraph node and require a structured result such as route, confidence, risk level, and retrieval_required. Keep this node on gemini-3-flash.
  • 5. Put planning in a separate node using gpt-5.4-mini. Have it produce a bounded tool plan with an allowed tool list, arguments, and a stop condition.
  • 6. Run tools in dedicated nodes owned by your application. Do not give the model unrestricted shell, database, or network access simply because the graph is local.
  • 7. Send retrieved documents and verified tool outputs to a synthesis node using claude-sonnet-4-6. Include source identifiers in state so the node can cite what it actually received.
  • 8. Add an explicit conditional edge to gpt-5.6-sol only for defined triggers: failed plan validation, conflicting evidence, repeated tool errors, or a high-impact request class.
  • 9. Apply a per-node recursion or retry budget. A failed tool loop should terminate with diagnostic state, not silently burn tokens through repeated planning.
  • 10. Log graph node name, model ID, input token estimate, output token estimate, route decision, and terminal status. Redact API keys and sensitive tool payloads before logs leave the runtime.

For LangGraph's prebuilt agent flow, the relevant construction pattern is create_react_agent(llm, tools). For custom graphs, instantiate a different LLM per node rather than mutating one shared client.

Copy-paste LangGraph configuration with per-hop LumeAPI models

Last verified: 2026-07-25

python
import os
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

# Export these before running:
# export OPENAI_API_KEY='YOUR_LUMEAPI_KEY'
# export OPENAI_BASE_URL='https://api.lumeapi.site/v1'

BASE_URL = os.environ.get("OPENAI_BASE_URL", "https://api.lumeapi.site/v1")
API_KEY = os.environ["OPENAI_API_KEY"]

classifier_llm = ChatOpenAI(
    model="gemini-3-flash",
    api_key=API_KEY,
    base_url=BASE_URL,
    temperature=0,
)
planner_llm = ChatOpenAI(
    model="gpt-5.4-mini",
    api_key=API_KEY,
    base_url=BASE_URL,
    temperature=0,
)
synthesis_llm = ChatOpenAI(
    model="claude-sonnet-4-6",
    api_key=API_KEY,
    base_url=BASE_URL,
    temperature=0.2,
)
escalation_llm = ChatOpenAI(
    model="gpt-5.6-sol",
    api_key=API_KEY,
    base_url=BASE_URL,
    temperature=0,
)

@tool
def get_order_status(order_id: str) -> str:
    """Return a verified order status for an order ID."""
    # Replace with an authenticated call to your internal service.
    return f"Order {order_id}: status unavailable in this example."

# A tool-using node can have its own model assignment.
planner_agent = create_react_agent(planner_llm, [get_order_status])

# In a custom StateGraph, call classifier_llm in the routing node,
# invoke planner_agent in the planning/tool node, call synthesis_llm
# in the response node, and reserve escalation_llm for conditional edges.

result = classifier_llm.invoke(
    "Classify this request as simple, tool_required, or escalation: "
    "Where is order A-1042?"
)
print(result.content)

Do not change BASE_URL to https://api.lumeapi.site/v1/chat/completions. ChatOpenAI adds the Chat Completions path.

Configure OpenClaw as a separate LumeAPI provider

Last verified: 2026-07-25

OpenClaw custom providers should use a new provider name. Do not attempt to override the built-in openai provider base URL.

  • 1. Open the OpenClaw configuration file used by the agent runtime and locate the models.providers configuration path.
  • 2. Add a new custom provider under models.providers named lumeapi. Do not modify the built-in openai provider entry.
  • 3. Set models.providers.lumeapi.baseUrl to https://api.lumeapi.site/v1 exactly. Do not add /chat/completions.
  • 4. Set models.providers.lumeapi.api to openai-completions so OpenClaw uses the OpenAI-compatible Chat Completions interface.
  • 5. Supply the LumeAPI key at models.providers.lumeapi.apiKey using your deployment's secret-injection mechanism. Avoid committing the key in shared configuration.
  • 6. Add the model IDs your workflows use under models.providers.lumeapi.models, including gemini-3-flash, gpt-5.4-mini, claude-sonnet-4-6, and gpt-5.6-sol.
  • 7. Set the provider configuration mode to merge so the custom provider is added without replacing unrelated configured providers.
  • 8. Set agents.defaults.model.primary to lumeapi/gpt-5.4-mini for a sensible default planning model, then assign other LumeAPI models in agents that need different roles.
  • 9. Restart or reload the OpenClaw runtime using its normal deployment procedure, then send a small prompt that confirms the selected model ID in application logs.
  • 10. Test a tool-enabled agent separately from a plain chat agent. Provider connectivity does not prove that your tool permission policy, tool schemas, or approval gates are correct.

The relevant OpenClaw settings paths are models.providers, models.providers.lumeapi.baseUrl, models.providers.lumeapi.api, models.providers.lumeapi.apiKey, models.providers.lumeapi.models, and agents.defaults.model.primary.

Make escalation a measurable economic decision

Last verified: 2026-07-25

The most common routing mistake is sending every message to the strongest available model because the first demo looked better. That approach hides cost in routine traffic: greetings, basic extraction, duplicate tickets, simple status questions, and requests that should have been answered by a tool call. A local agent can make cheaper decisions before it spends on synthesis.

Start with a routing contract. The classifier returns a narrow label, the planner can request only approved tools, and the synthesis node receives evidence rather than raw access to every system. Escalation should depend on visible state: low classifier confidence, validation failure, conflicting tool results, policy-sensitive categories, or a capped number of unsuccessful attempts. Do not escalate merely because a model generated a long answer.

Track spend by graph node and route, not only by user session. If claude-sonnet-4-6 synthesis dominates cost, reduce duplicate context and cap outputs before changing models. If gpt-5.6-sol appears frequently, inspect the reason codes. A high escalation rate usually indicates an unclear router, weak tool result schemas, missing retrieval filters, or a task that needs a human-owned workflow rather than a larger model.

Input and output rates differ substantially for several models. Output limits are a direct routing and cost control, especially for planning and synthesis nodes.

Production hardening for self-hosted agent runtimes

Last verified: 2026-07-25

Local deployment changes where your agent runs, not the need for controls around credentials, tool authority, retries, and observability.

  • 1. Inject the LumeAPI key at runtime and rotate it through the same process used for other production secrets. Confirm that OPENAI_API_KEY never appears in traces, exception text, or support bundles.
  • 2. Allow outbound access only to https://api.lumeapi.site/v1 where your network policy supports domain-based egress rules. Keep internal tools on their existing private network boundaries.
  • 3. Set explicit maximum output sizes for each node. Classifiers should return compact labels; planners should return bounded action lists; synthesis should have a user-visible response limit.
  • 4. Validate model output before it controls an edge or tool invocation. Parse route labels, tool arguments, identifiers, and policy flags against application-defined schemas.
  • 5. Use idempotency-aware tool design. A graph retry must not accidentally create duplicate tickets, issue duplicate refunds, or repeat state-changing operations.
  • 6. Separate read-only and write-capable tools. Require an approval node, a user confirmation, or a service-side policy check before write-capable operations run.
  • 7. Add timeouts and a finite retry count around both model calls and tools. Preserve the failed node, route reason, and safe error summary in graph state for debugging.
  • 8. Build a replay set of representative requests: simple requests, tool-required requests, ambiguous requests, unsafe requests, and known failure cases. Run it whenever prompts, model routing, or tool schemas change.
  • 9. Monitor model ID distribution, escalation percentage, tool error rate, retry count, and completion length. Alert on route shifts that could indicate a broken classifier or an unexpected workload change.
  • 10. Document client limitations before standardizing developer tools. For example, Cursor tab completion may not use a custom URL even when a chat-oriented integration supports OpenAI-compatible endpoints.

OpenAI compatibility applies to text-model Chat Completions usage. Validate each local agent feature independently instead of assuming every editor, completion mode, or provider-specific capability accepts a custom endpoint.

Cost multiplies per hop

A single user request in a local agent may trigger five to fifteen Chat Completions calls. Route classification and planning to gemini-3-flash or gpt-5.4-mini; reserve claude-sonnet-4-6 or gpt-5.6-sol for synthesis and tool-heavy steps.

LangGraph and LangChain integrate via ChatOpenAI(base_url="https://api.lumeapi.site/v1") — no graph rewrite when you change model id per node.

Sum Usage rows for all hops in a completed workflow to get true cost per task, not cost per API call in isolation.

Self-serve path: register to first API call

LumeAPI is designed for developers who want to integrate without scheduling demos. Create an account, confirm your email, and open Console to generate an API key. Fund your USD wallet with USDT on supported chains when you are ready for billable traffic—there is no mandatory minimum beyond what your tests require.

Point your OpenAI-compatible client at https://api.lumeapi.site/v1, set Authorization to Bearer your key, and pass a catalog model id in the model field. Run a short curl or SDK script from /docs to verify latency, streaming, and error handling before you attach the key to production services.

Use Usage logs to reconcile per-call cost with finance forecasts. When a model tier is too expensive or quality is insufficient, change model id—not your entire integration. For cross-provider price tables and Research deep dives, follow internal links on this page rather than duplicating migration math here.

Documentation, catalog, and support

Every catalog model has a detail page under /models with official reference pricing, LumeAPI pricing, and links to /docs/models/{id} for parameters and curl examples. Start there when this commercial page points you to a model id you have not called before.

The /docs index lists gateway authentication, Chat Completions, image endpoints, and async video patterns. llms.txt bundles the same information for agent tooling—useful when you want a single URL to paste into Cursor or an internal bot.

Research articles explain why bills grow and how to compare providers; commercial pages like this one explain what LumeAPI offers and how to start. Follow internal links instead of searching for duplicate migration content across pages.

If billing, chain deposits, or integration behavior is unclear, use /contact for support channels. Include your model id, approximate request time, and whether the issue is authentication, balance, or model parameters—that speeds up resolution.

Why LumeAPI

One key, dozens of models

A single API key calls GPT, Claude, Gemini, and more on one USD wallet — no separate vendor accounts per provider.

Up to 70% below reference

Published catalog rates undercut official list pricing. GPT tiers up to ~70% off; Claude and Gemini 50% off official reference.

Official application channels

Model capacity is sourced through major providers’ authorized application channels — recognizable catalog ids, not opaque repackaged endpoints.

Real-time Usage logs

Every call records model id, token counts, latency, and exact USD cost. Audit any line item in Console — usage and price are traceable.

OpenAI-compatible gateway

Point Cursor, SDKs, and agents at one base URL. Change API key, base URL, and model id — keep your existing integration shape.

Text, image, and video

Chat, image generation, and async video on the same key and wallet when you outgrow text-only workloads.

Get started in three steps

  1. Create an API key — register and open Console.
  2. Set the LumeAPI base URLhttps://api.lumeapi.site/v1
  3. Choose a supported model id — from the table above or model catalog.

Migrate in minutes

Three values change: API key, base URL, model id. Everything else stays the same.

Before (single expensive model per hop)

python
from openai import OpenAI

client = OpenAI(api_key="YOUR_OPENAI_API_KEY")

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Hello"}],
)

After (LumeAPI)

python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_LUMEAPI_KEY",
    base_url="https://api.lumeapi.site/v1",
)

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Hello"}],
)

Full step-by-step rollout, streaming checks, and FAQ: Agent API cost guide →

Migration & compatibility

What changes

API key, base URL (https://api.lumeapi.site/v1), and model id to a LumeAPI catalog entry. Message shape stays OpenAI-compatible for most apps.

What to test

Streaming, tool calling, JSON mode, and error handling on your heaviest models. Shadow 5–10% of traffic before full cutover.

What may differ

Provider-native features (Anthropic Batch, Google Grounding, OpenAI Assistants) may require the official API. Test your exact payload.

Rollback

Keep environment variables for base URL and model id. Switch back instantly if staging tests fail.

Trust & billing

LangGraph compatible?

Yes — use langchain_openai.ChatOpenAI with LumeAPI base_url and catalog model id.

Runs locally?

Your orchestrator runs on your machine; model inference calls go to LumeAPI gateway.

Multi-model?

One API key — change model per request in code.

Observability?

Usage logs list every hop with model id and USD cost.

Built for these workloads

LangGraph / LangChain

ChatOpenAI with base_url=https://api.lumeapi.site/v1.

Per-hop routing

Different model id for classify, plan, tool, and synthesize steps.

Tool calling

OpenAI-compatible tools on catalog text models — validate schemas in staging.

Cost per task

Sum Usage rows for all hops in one completed workflow.

Related guides

Part of the Cheap LLM API hub — models, pricing, and integration guides for this provider.

FAQ

LangGraph base_url example?

ChatOpenAI(base_url="https://api.lumeapi.site/v1", model="claude-sonnet-4-6"). See page sections.

OpenClaw / custom loops?

Any client that speaks OpenAI Chat Completions works — set env OPENAI_BASE_URL.

vs /ai-agent-api?

/ai-agent-api is product-agnostic agent economics. This page is local/self-hosted setup.

Cheapest agent hops?

gemini-3-flash or gpt-5.4-mini for classification and routing.

Streaming in agents?

Supported — test stream handling in your graph nodes.

Tool errors?

See /research/prevent-duplicate-ai-agent-tool-calls for idempotency patterns.

Wire your local agents to LumeAPI

Set base URL and model id in your agent runner https://api.lumeapi.site/v1. Need help choosing a model? Browse the developer docs or contact support.