Run AutoGPT on a custom OpenAI base URL.

Updated 2026-07-16

AutoGPT Classic reads OPENAI_API_BASE_URL from its .env and passes it straight to the OpenAI client as base_url. Point it at https://api.apisrouter.com/v1, set one key, and the agent's SMART_LLM and FAST_LLM traffic routes through a single metered endpoint.

Quick answer: two lines in .env.

AutoGPT Classic's .env.template documents OPENAI_API_BASE_URL as "Custom url for the OpenAI API, useful for connecting to custom backends", and the provider code wires it directly into the client: the OpenAICredentials class reads api_base from that variable and passes it as base_url. So the override is uncommenting one line and setting the key: OPENAI_API_BASE_URL to https://api.apisrouter.com/v1 and OPENAI_API_KEY to your gateway key. One scoping note before anything else: this applies to AutoGPT Classic, the autonomous agent living under classic/original_autogpt in the repo. The repo's newer AutoGPT Platform (the visual builder) manages model credentials per block through its own backend, and this environment variable is not how you configure it.

OPENAI_API_BASE_URL=https://api.apisrouter.com/v1
OPENAI_API_KEY=sk-APIsRouter-...
SMART_LLM=gpt-5.4
FAST_LLM=gpt-5.4-mini

How AutoGPT Classic routes model calls.

AutoGPT (Significant-Gravitas on GitHub, roughly 185K stars, the most-starred agent repo in existence) pioneered the autonomous loop: the agent plans, picks an action, executes it, evaluates the result, and repeats until the goal is done or the budget is not. Classic splits its model usage across two slots. SMART_LLM carries the agent's main reasoning turns, and FAST_LLM handles the lighter work; the defaults live in the config as enum values, overridable from the environment. The routing mechanics are unusually clean for a project this old: OpenAICredentials.api_base is UserConfigurable from OPENAI_API_BASE_URL, and get_api_access_kwargs() hands it to the OpenAI client as base_url. Every OpenAI-provider request the agent makes, planning turns, tool-use decisions, summaries, goes to whatever host that variable names. The constraint that separates AutoGPT from freeform tools: SMART_LLM and FAST_LLM are typed as ModelName enums, validated against the model registry compiled into the agent, not free strings. Recent builds' registry covers the GPT-5 series through gpt-5.4 alongside the 4.1, 4o, and o-series families, but the practical rule is to pick from names your checkout's enum actually contains. The gateway then receives exactly that id, so the id must also exist in the catalog; gpt-5.4 and gpt-5.4-mini satisfy both sides today.

Full setup: .env in the right directory, models from the registry.

Copy .env.template to .env inside classic/original_autogpt, uncomment and set the four values, and run the agent from that directory. The .env is loaded relative to the classic agent's working layout, so a beautifully configured file in the repo root does nothing for it. Model selection is a registry lookup, not a passthrough. Setting SMART_LLM to an id the enum does not contain fails validation at startup, before any request is made, which at least fails loudly. The corollary is that Claude ids are not addressable through this path at all: Classic has a separate native Anthropic provider (ANTHROPIC_API_KEY) for those enum names, and that provider does not read OPENAI_API_BASE_URL. If your goal is one key through one endpoint, keep both slots on OpenAI-registry names the gateway serves. Budget discipline still applies. The autonomous loop is famous for spending tokens in unattended bursts, and rerouting it does not change that; it makes it measurable. Classic's own budget settings remain worth setting, and the per-key usage view gives you the external ledger per run.

cd classic/original_autogpt
cp .env.template .env
# edit .env:
#   OPENAI_API_BASE_URL=https://api.apisrouter.com/v1
#   OPENAI_API_KEY=sk-APIsRouter-...
#   SMART_LLM=gpt-5.4
#   FAST_LLM=gpt-5.4-mini
./autogpt.sh run   # or: poetry run autogpt run

Choosing SMART_LLM and FAST_LLM.

The honest comparison is per goal, not per call: give the agent the same goal under two SMART_LLM choices and compare total tokens and outcome quality in the usage log. Autonomous agents are the one workload where the stronger model regularly wins on total cost.

  • SMART_LLM is the agent's judgment. It decides what to do next on every loop iteration, and a bad decision does not just waste one call, it spawns a subtree of wasted calls. gpt-5.4 is the strongest registry-and-catalog match for this slot today.
  • FAST_LLM absorbs the mechanical volume. gpt-5.4-mini keeps the loop's supporting calls at a small fraction of the smart slot's price, which matters because autonomous runs multiply everything.
  • Resist the temptation to run FAST_LLM as the smart slot to save money: the autonomous loop compounds decision quality, so a weaker planner usually costs more in total tokens than it saves per call.
  • Registry names shift with the checkout. After pulling a new version, re-check that your configured names still validate; an enum rename fails at startup with a clear error, which beats a silent fallback.

Pay-as-you-go · transparent per-model pricing

Selected models are priced below official list prices. Exact input, output, cache, and per-request prices are shown for each model.

ModelOfficial PriceOur Price
GPT-5.4$2.50 / $15.00 per M$2.00 / $12.00 per M
GPT-5.4 Mini$0.75 / $4.50 per M$0.60 / $3.60 per M
GPT-5.5$5.00 / $30.00 per M$4.00 / $24.00 per M
GPT-5.3 Codex Spark$1.75 / $14.00 per M$1.40 / $11.20 per M

The failure modes specific to AutoGPT.

The variable-name trap. Three different tools use three different spellings: mem0 reads OPENAI_BASE_URL, Aider reads OPENAI_API_BASE, and AutoGPT Classic reads OPENAI_API_BASE_URL. Muscle memory from another tool leaves the wrong variable set, AutoGPT ignores it silently, and requests keep flowing to api.openai.com on whatever OPENAI_API_KEY holds. Requests not appearing in your gateway usage log means checking this first. Enum rejection at startup. SMART_LLM or FAST_LLM set to an id outside the compiled registry fails validation before the agent runs. This is the correct behavior, but it surprises people arriving from freeform tools where any string is forwarded; the error means "pick a registry name," not "the endpoint is down." Claude names routing natively. Anthropic enum names go through the Anthropic provider and ANTHROPIC_API_KEY, bypassing OPENAI_API_BASE_URL. If you expected every request in one usage log and see only some, the missing traffic is on a native provider path. The wrong .env. The classic agent loads its own directory's .env. A file at the repo root, or a shell export shadowed by a stale .env value, produces confusing half-configured states. Keep the four values in one place: classic/original_autogpt/.env. Platform expectations. The AutoGPT Platform's blocks manage credentials in their own backend; setting this environment variable does not reroute them. This page's path is Classic's.

Who routes AutoGPT through a gateway.

  • Developers resurrecting Classic for autonomous experiments who want the loop's notorious token appetite on a metered, per-key ledger from the first run.
  • Tinkerers running long unattended goals, where per-request visibility into what the agent actually did with its budget matters as much as the total.
  • Teams standardizing one endpoint across many tools, where AutoGPT is one more .env pointed at the same key rather than a separate account.
  • Users pairing gpt-5.4 judgment with gpt-5.4-mini volume, priced per token with no subscription attached to either slot.
  • Developers without access to a given vendor's billing. Top-up based access with no card requirement removes the per-provider sign-up dependency.

Verify the endpoint and debug the first run.

Confirm the gateway serves the exact ids you put in SMART_LLM and FAST_LLM; the agent sends those strings verbatim. The first-run ladder: a validation error naming your model at startup means the id is not in your build's registry, so pick another registry name. A 401 means OPENAI_API_KEY in the classic agent's own .env is not the gateway key. A model-not-found error from the gateway means the registry name you chose is not in the catalog; align the two sides. And a run that works but never appears in the usage log means the base URL variable is misspelled or in the wrong file, and traffic is going to the default host. Once the loop is running, watch the per-request view during the first goal rather than after it. Autonomous agents reveal their token behavior in the first few minutes, and catching a runaway loop early is worth more than any per-token price difference.

curl -s https://api.apisrouter.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY" | head -50

FAQ

Which environment variable sets a custom base URL for AutoGPT?

OPENAI_API_BASE_URL, in the classic agent's .env. It is documented in .env.template as a custom URL for connecting to OpenAI-compatible backends, and the provider passes it to the OpenAI client as base_url. Note the spelling: it differs from the variables other tools use.

Can AutoGPT Classic run Claude models through this base URL?

No. SMART_LLM and FAST_LLM validate against AutoGPT's compiled model registry, and Anthropic names route through the separate native Anthropic provider, which does not read OPENAI_API_BASE_URL. For one key through one endpoint, keep both slots on OpenAI-registry names the gateway serves.

What can SMART_LLM and FAST_LLM be set to?

Names from the ModelName enum in your checkout: recent builds cover the GPT-5 series through gpt-5.4 plus the 4.1, 4o, and o-series families. Unknown strings fail validation at startup. gpt-5.4 and gpt-5.4-mini are solid picks that exist in both the registry and the catalog.

Does this configuration apply to the AutoGPT Platform too?

No. The Platform (the visual builder half of the repo) manages model credentials per block in its own backend. OPENAI_API_BASE_URL configures AutoGPT Classic, the autonomous agent under classic/original_autogpt.

Do I still need an OpenAI account once the base URL is set?

No. With OPENAI_API_BASE_URL pointed at the gateway, OPENAI_API_KEY holds your gateway key and no request goes to OpenAI hosts. The variable names are historical; the credentials are whatever the endpoint behind the base URL accepts.

How much does an AutoGPT run cost?

It is the least predictable workload on this list: the loop decides its own call count, so cost scales with goal difficulty and how often the agent revises its plan. Set the agent's budget controls, watch the per-key usage view live during early runs, and treat per-goal token totals as the metric.