#479

Add LiteLLM provider for pentestgpt-legacy

OpenRheagalFirewants to merge intofrom

Add LiteLLM provider for pentestgpt-legacy

LiteLLM is an open-source gateway that provides a unified completion() interface for 100+ LLM providers. Adding it as a provider gives pentestgpt-legacy users access to Azure, AWS Bedrock, Google Vertex, HuggingFace, vLLM, and any OpenAI-compatible endpoint, all through a single litellm:<model> prefix, without per-provider code.

Changes

FileChange
llm/providers/litellm_provider.pyNew LiteLLMProvider(BaseProvider) using litellm.acompletion() with drop_params=True
llm/registry.pyAdded litellm ProviderInfo + litellm: dynamic prefix resolver
llm/factory.pyRegistered LiteLLMProvider in _PROVIDER_CLASSES
llm/providers/__init__.pyExport LiteLLMProvider
llm/config.pyAdded LITELLM_API_KEY and LITELLM_BASE_URL settings
pyproject.tomlAdded litellm>=1.80.0 as optional dependency
.env.exampleDocumented LiteLLM configuration
tests/legacy/test_litellm_provider.py6 unit tests covering registry, resolve, factory, and proxy config

Usage

# Install with the litellm extra
uv sync --extra litellm

# Use any LiteLLM-supported model
pentestgpt-legacy --reasoning-model litellm:azure/gpt-4 --parsing-model litellm:bedrock/anthropic.claude-v2

# With a LiteLLM proxy
LITELLM_API_KEY=sk-proxy LITELLM_BASE_URL=http://proxy:4000 \
  pentestgpt-legacy --reasoning-model litellm:gpt-4

Tests

Live E2E - full LLMClient stack via Azure Foundry (anthropic/claude-sonnet-4-6):

from pentestgpt_legacy.llm.factory import get_client

# Factory resolves litellm: prefix -> LiteLLMProvider -> litellm.acompletion()
client = get_client('litellm:anthropic/claude-sonnet-4-6')

# Test 1: New conversation
response, cid = client.send_new_message('Say hello in 5 words.')
print(f"Response: {response}")
print(f"Conversation ID: {cid}")
# Response: Hello there, how are you?
# Conversation ID: <uuid>

# Test 2: Multi-turn (same conversation)
response2 = client.send_message('Now say goodbye in 3 words.', cid)
print(f"Follow-up: {response2}")
# Follow-up: Goodbye for now!

Full chain verified: get_client('litellm:...') -> LLMClientFactory -> LiteLLMProvider.acompletion() -> litellm.acompletion(drop_params=True) -> Azure Foundry -> response parsed correctly. Multi-turn conversation state maintained across calls.

Activity

5
gemini-code-assist[bot]reviewed4mo ago
gemini-code-assist[bot]4mo ago

Code Review

This pull request introduces integration with LiteLLM as an optional multi-provider gateway, adding configuration options, a dedicated LiteLLMProvider class, and corresponding unit tests. The feedback suggests two improvements: updating the installation error message to recommend installing the optional dependency via 'uv sync --extra litellm' instead of 'uv add litellm', and safely guarding against an empty response.choices list to prevent a potential IndexError.

IMPORTANT

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026. For more details on the timeline and next steps, please review the Help Documentation.