Skip to content

feat: Add Forge as LLM provider - #116

Closed
Yiiii0 wants to merge 1 commit into
HKUDS:mainfrom
Yiiii0:feature/forge-20260307-192557
Closed

feat: Add Forge as LLM provider#116
Yiiii0 wants to merge 1 commit into
HKUDS:mainfrom
Yiiii0:feature/forge-20260307-192557

Conversation

@Yiiii0

@Yiiii0 Yiiii0 commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Forge as an OpenAI-compatible gateway provider in nanobot's provider registry, following the same pattern as AiHubMix.

Changes Made

  • nanobot/nanobot/providers/registry.py: Added ProviderSpec for Forge with is_gateway=True, litellm_prefix="openai", strip_model_prefix=True
  • nanobot/nanobot/config/schema.py: Added forge field to ProvidersConfig
  • nanobot/nanobot/providers/litellm_provider.py: Extended env_extras handling to use os.environ[...] (override) for gateways instead of setdefault, matching the primary env_key pattern at line 60
  • nanobot/README.md: Added Forge to provider table

Usage

# In nanobot config:
providers:
  forge:
    api_key: "your-forge-api-key"
    api_base: "https://api.forge.tensorblock.co/v1"  # optional, this is the default

Checklist

  • Changes tested locally
  • Documentation updated
  • Ran pre-commit hooks

I work at TensorBlock and will help maintain this integration.


About Forge

Forge is an open-source middleware service for unified AI model provider management. It routes requests across 40+ AI providers with access to thousands of models through a single OpenAI-compatible API.

## Changes

- Automated integration updates from manager loop.

Files modified:
nanobot/README.md
nanobot/nanobot/config/schema.py
nanobot/nanobot/providers/litellm_provider.py
nanobot/nanobot/providers/registry.py
Zongwei9888 added a commit that referenced this pull request Aug 6, 2026
Ports three provider contributions that could not merge as submitted: #138
and #130 also touched new_ui/ and nanobot/, and #116 targeted nanobot/ only.
Those trees were removed in the v2.0 refactor. The provider work itself
applies unchanged to core/providers.

ProvidersConfig reads each provider via getattr(providers, spec.name), so a
ProviderSpec without a matching field is silently skipped — all three get both
halves, as the ProvidersConfig docstring requires.

Endpoints verified reachable: router.requesty.ai (200), api.minimax.io (401),
api.forge.tensorblock.co (401).

Also fixes a gateway bug #116 found in nanobot's provider that core had only
half-fixed: spec.env_key was forced for gateways, but env_extras still used
setdefault, so a stale ambient variable outranked the gateway the user picked.

Dropped from the originals: the tests covering new_ui's requesty_models
service and nanobot's registry. One of those imported "nanobot.config.schema",
which now resolves to an unrelated PyPI package (nanobot-ai) when installed —
it fails locally and skips in CI, testing nothing either way.

Co-authored-by: Thibault Jaigu <thibault.jaigu@gmail.com>
Co-authored-by: Yiiii0 <yiqiaozhou@outlook.com>
Co-authored-by: octo-patch <octo-patch@github.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Zongwei9888

Copy link
Copy Markdown
Collaborator

Ported to core/providers in b737060 (via #159), with a Co-authored-by: trailer for you.

Your branch targeted nanobot/, which the v2.0 refactor removed, so the spec was rewritten against core/providers/registry.py — same fields, openai_compat backend instead of the litellm prefix. api.forge.tensorblock.co/v1/models verified reachable (401).

strip_model_prefix=True came across as you had it. That is the field that makes this more than a convenience entry: through the generic custom provider, a habitual anthropic/claude-3 would be sent to Forge verbatim and fail.

Your second change found a real bug here too. The setdefault fix you made in nanobot's litellm_provider.py applies to core/providers/openai_compat.py, which had it only half-right:

if spec.is_gateway:
    os.environ[spec.env_key] = api_key      # gateway wins
else:
    os.environ.setdefault(spec.env_key, api_key)
...
for env_name, env_val in spec.env_extras:
    os.environ.setdefault(env_name, resolved)   # gateway does NOT win

A stale ambient variable outranked the gateway the user had selected. #159 applies the same rule to env_extras, with a test that fails if it is reverted. Latent on main today — only zhipu uses env_extras and it is not a gateway — but it would have bitten the first gateway that needed one. Thanks for catching it.

@Zongwei9888 Zongwei9888 closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants