Skip to content

feat: Add LiteLLM AI Gateway support#40

Open
devhimanshuu wants to merge 3 commits into
bug0inc:mainfrom
devhimanshuu:ai_gateway
Open

feat: Add LiteLLM AI Gateway support#40
devhimanshuu wants to merge 3 commits into
bug0inc:mainfrom
devhimanshuu:ai_gateway

Conversation

@devhimanshuu

Copy link
Copy Markdown

Support for LiteLLM Gateway & Enterprise Models

Description

This PR introduces support for LiteLLM, a popular open-source AI proxy. By adding LiteLLM as an officially supported AI gateway, Passmark now seamlessly integrates with enterprise providers like Azure OpenAI and AWS Bedrock.

Enterprise users who mandate strict compliance requirements and cannot use public APIs can now configure Passmark to route requests securely through their internal infrastructure via LiteLLM.

Changes Made

  • src/config.ts:
    • Added 'litellm' to the AIGateway union type.
    • Updated configuration error messages to include LiteLLM setup instructions (e.g., configuring LITELLM_BASE_URL and LITELLM_API_KEY).
  • src/models.ts:
    • Added the @ai-sdk/openai provider to interact with LiteLLM's OpenAI-compatible endpoints.
    • Implemented getLiteLLMProvider() to securely instantiate the model client based on environment variables.
    • Created resolveLiteLLMModelId() to seamlessly map Passmark's default canonical model prefixes (e.g., google/ to gemini/) to match LiteLLM's expected formats.
    • Integrated the new gateway routing logic into resolveModel().
  • Testing (src/__tests__/):
    • Added unit tests to config.test.ts to verify the new gateway configuration parsing.
    • Created models.test.ts to fully cover the environment validation, provider creation, and prefix-mapping logic for LiteLLM.

How to Test

  1. Set the environment variable LITELLM_BASE_URL to your local or hosted LiteLLM instance (e.g., export LITELLM_BASE_URL=http://localhost:4000/v1).
  2. Optionally configure LITELLM_API_KEY if your proxy requires authentication.
  3. Configure Passmark to use the new gateway:
    configure({ ai: { gateway: 'litellm' } });
  4. Run your test suite. Passmark should now securely proxy all requests through your LiteLLM gateway to Azure, Bedrock, or any other configured backend.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds LiteLLM as an additional AI gateway option so Passmark can route model requests through a LiteLLM OpenAI-compatible proxy (supporting enterprise deployments like Azure OpenAI / Bedrock behind internal infrastructure).

Changes:

  • Extends AIGateway to include "litellm" and wires LiteLLM routing into resolveModel().
  • Introduces a LiteLLM provider factory (createOpenAI with baseURL) plus a small model-id remapping helper for LiteLLM.
  • Adds unit tests covering gateway configuration and basic LiteLLM env validation behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/models.ts Adds LiteLLM provider creation, model-id remapping, and gateway routing branch.
src/config.ts Extends AIGateway union type with "litellm".
src/tests/models.test.ts New tests for LiteLLM gateway env validation and resolution behavior.
src/tests/config.test.ts Adds a config test ensuring ai.gateway can be set to "litellm".
Comments suppressed due to low confidence (1)

src/models.ts:178

  • The resolveModel() docstring lists supported gateways but doesn't mention the newly added "litellm" routing path, so it's now out of sync with behavior.

/**
 * Resolves a canonical model ID to a LanguageModel instance wrapped with Axiom instrumentation.
 * Input format: "provider/model-name" (e.g. "google/gemini-3-flash")
 *

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +13
beforeEach(() => {
vi.resetModules();
process.env = { ...originalEnv };
resetConfig();
});
Comment thread src/__tests__/models.test.ts Outdated
devhimanshuu and others added 2 commits June 15, 2026 18:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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