Skip to content

feat: add Forge as LLM provider for ACE-Step-1.5#944

Open
Yiiii0 wants to merge 1 commit intoace-step:mainfrom
Yiiii0:feat/add-forge-integration
Open

feat: add Forge as LLM provider for ACE-Step-1.5#944
Yiiii0 wants to merge 1 commit intoace-step:mainfrom
Yiiii0:feat/add-forge-integration

Conversation

@Yiiii0
Copy link
Copy Markdown

@Yiiii0 Yiiii0 commented Mar 27, 2026

Summary

Adds Forge as a supported LLM provider by extending the external language model provider configuration and request handling logic to include Forge's OpenAI-compatible API.

Changes

  • .env.example: Added FORGE_API_KEY and FORGE_API_BASE environment variable examples for Forge configuration.
  • acestep/text_tasks/external_ai_request_helpers.py: Updated request-building logic to support Forge's OpenAI-compatible JSON output format.
  • acestep/text_tasks/external_ai_request_helpers_test.py: Added tests for Forge-specific request payloads, including JSON output handling.
  • acestep/text_tasks/external_lm_providers.py: Added Forge to _EXTERNAL_PROVIDER_PROFILES with default settings and API endpoint details.
  • acestep/text_tasks/external_lm_providers_test.py: Added validation tests for Forge provider configuration.

Usage

  1. Set the following environment variables:

    • FORGE_API_KEY: Your Forge API key.
    • FORGE_API_BASE (optional): Base URL for Forge API, defaulting to https://api.forge.tensorblock.co/v1.
  2. Configure Forge as the provider in your code:

    from acestep.text_tasks.external_lm_providers import LLM
    
    llm = LLM("forge/OpenAI/gpt-4o-mini")
    response = llm.chat(messages=[{"role": "user", "content": "Hello, Forge!"}])
    print(response)
  3. Example model name format: "forge/OpenAI/gpt-4o-mini".

Test Evidence

  • Ran pytest tests/:
    • acestep/text_tasks/external_ai_request_helpers_test.py: Added tests for Forge request payloads, all passed.
    • acestep/text_tasks/external_lm_providers_test.py: Validated Forge provider configuration, all tests passed.
  • Total: 874 tests passed, 0 failed.

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.

I work at TensorBlock and will help maintain this integration.

References

Summary by CodeRabbit

Release Notes

  • New Features

    • Integrated support for Forge as an external language model provider, allowing users to supply custom API credentials and endpoints through environment configuration.
  • Chores

    • Updated the environment configuration template with optional Forge API key and base URL entries for streamlined setup.
  • Tests

    • Added comprehensive unit tests verifying Forge provider integration, JSON response format handling, and default model selection behavior.

## Changes

- Add Forge as LLM provider for ACE-Step-1.5

Files modified:
.env.example
acestep/text_tasks/external_ai_request_helpers.py
acestep/text_tasks/external_ai_request_helpers_test.py
acestep/text_tasks/external_lm_providers.py
acestep/text_tasks/external_lm_providers_test.py
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

The changes add support for a new Forge external language model provider. Configuration entries are added to .env.example, the provider registry is updated with Forge-specific defaults, JSON response handling logic is extended to support Forge, and comprehensive unit tests are added to verify the new functionality.

Changes

Cohort / File(s) Summary
Configuration
.env.example
Added FORGE_API_KEY and FORGE_API_BASE optional environment variables for Forge LM provider authentication and base URL configuration.
Provider Registration
acestep/text_tasks/external_lm_providers.py
Added Forge provider profile to the _EXTERNAL_PROVIDER_PROFILES registry with OpenAI-compatible protocol, default model, base URL preset, and API key configuration; updated get_external_provider_choices() to include Forge in the provider ordering.
Provider Registration Tests
acestep/text_tasks/external_lm_providers_test.py
Added unit tests verifying Forge provider profile properties (protocol, default model, base URL, API key), provider choice inclusion, and model fallback behavior.
Request Handling
acestep/text_tasks/external_ai_request_helpers.py
Extended build_request_for_protocol to apply JSON-only response configuration (response format and stop tokens) for the forge provider when require_json_output is enabled, consistent with openai and zai providers.
Request Handling Tests
acestep/text_tasks/external_ai_request_helpers_test.py
Added unit test test_build_request_for_protocol_requests_json_output_for_forge_format verifying JSON output configuration is correctly applied for Forge provider requests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes


🐰 A forge has opened in our lab with glee,
Where language models flow wild and free,
JSON requests stack high like carrots in spring,
New providers bring capabilities we sing! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and clearly summarizes the main change: adding Forge as a new LLM provider for ACE-Step-1.5. It is specific, concise, and directly related to the primary objective of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
acestep/text_tasks/external_lm_providers.py (1)

56-69: Consider aligning env var naming convention with other providers.

The Forge profile uses FORGE_API_KEY for the API key env var, while other providers use the ACESTEP_ prefix (e.g., ACESTEP_OPENAI_API_KEY, ACESTEP_GLM_API_KEY). Interestingly, secret_path_env does use the prefix (ACESTEP_FORGE_SECRET_PATH).

This inconsistency may be intentional (perhaps to match Forge's own documentation), but consider standardizing to ACESTEP_FORGE_API_KEY for internal consistency, or documenting why Forge uses a different convention.

🔧 Optional: Standardize env var naming
     "forge": ExternalProviderProfile(
         provider_id="forge",
         label="Forge",
         protocol="openai_chat",
         default_model="OpenAI/gpt-4o-mini",
         default_base_url="https://api.forge.tensorblock.co/v1/chat/completions",
-        api_key_env="FORGE_API_KEY",
+        api_key_env="ACESTEP_FORGE_API_KEY",
         api_key_required=True,
         secret_path_env="ACESTEP_FORGE_SECRET_PATH",
         secret_file_name="forge_api_key.enc",

If you apply this change, also update .env.example accordingly.

Note: The static analysis warnings (S106) on lines 64-65 are false positives—these are configuration key names, not hardcoded secrets.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@acestep/text_tasks/external_lm_providers.py` around lines 56 - 69, The Forge
ExternalProviderProfile uses api_key_env="FORGE_API_KEY" which is inconsistent
with other providers; change the api_key_env field on the "forge"
ExternalProviderProfile to "ACESTEP_FORGE_API_KEY" to match the ACESTEP_ prefix
(leave secret_path_env="ACESTEP_FORGE_SECRET_PATH" as-is), and update
.env.example to reflect the new ACESTEP_FORGE_API_KEY variable so examples and
runtime config stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.env.example:
- Line 63: The .env.example entry FORGE_API_BASE is misleading because the app
uses profile.default_base_url; either remove the FORGE_API_BASE line from
.env.example, or implement support by reading process.env.FORGE_API_BASE where
the base URL is resolved (replace or override profile.default_base_url). Update
the code path that computes the base URL (the place referencing
profile.default_base_url) to prefer process.env.FORGE_API_BASE when set, and
adjust .env.example accordingly if you choose to implement support.

---

Nitpick comments:
In `@acestep/text_tasks/external_lm_providers.py`:
- Around line 56-69: The Forge ExternalProviderProfile uses
api_key_env="FORGE_API_KEY" which is inconsistent with other providers; change
the api_key_env field on the "forge" ExternalProviderProfile to
"ACESTEP_FORGE_API_KEY" to match the ACESTEP_ prefix (leave
secret_path_env="ACESTEP_FORGE_SECRET_PATH" as-is), and update .env.example to
reflect the new ACESTEP_FORGE_API_KEY variable so examples and runtime config
stay consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1af35bd7-b251-4ef4-be84-4a1d7d51829d

📥 Commits

Reviewing files that changed from the base of the PR and between 84ba95e and 2bdff92.

📒 Files selected for processing (5)
  • .env.example
  • acestep/text_tasks/external_ai_request_helpers.py
  • acestep/text_tasks/external_ai_request_helpers_test.py
  • acestep/text_tasks/external_lm_providers.py
  • acestep/text_tasks/external_lm_providers_test.py

Comment thread .env.example

# Forge external LM settings (optional)
# FORGE_API_KEY=your-forge-api-key
# FORGE_API_BASE=https://api.forge.tensorblock.co/v1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for FORGE_API_BASE usage in the codebase
# Expected: Find code that reads FORGE_API_BASE env var, or confirm it's unused

echo "=== Searching for FORGE_API_BASE usage ==="
rg -n "FORGE_API_BASE" --type py

echo ""
echo "=== Searching for os.getenv/environ patterns with FORGE ==="
rg -n "getenv.*FORGE|environ.*FORGE" --type py

Repository: ace-step/ACE-Step-1.5

Length of output: 168


Remove FORGE_API_BASE from .env.example or implement support for it.

FORGE_API_BASE is documented in this file but is not consumed by the application. The code defaults to profile.default_base_url instead of checking this environment variable, making this documentation misleading to users.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.example at line 63, The .env.example entry FORGE_API_BASE is misleading
because the app uses profile.default_base_url; either remove the FORGE_API_BASE
line from .env.example, or implement support by reading
process.env.FORGE_API_BASE where the base URL is resolved (replace or override
profile.default_base_url). Update the code path that computes the base URL (the
place referencing profile.default_base_url) to prefer process.env.FORGE_API_BASE
when set, and adjust .env.example accordingly if you choose to implement
support.

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.

1 participant