The Java Test Generation Suite now supports multiple LLM providers through a factory pattern. You can easily switch between different AI models based on your needs, budget, and preferences.
| Provider | Models Available | Strengths |
|---|---|---|
| Gemini (default) | gemini-1.5-pro, gemini-1.5-flash, gemini-2.0-flash-exp |
Large context window, good code understanding |
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo |
Excellent code generation, reliable |
| Anthropic | claude-3-5-sonnet-20241022, claude-3-5-haiku-20241022 |
Strong reasoning, good at following instructions |
| Groq | llama-3.1-70b-versatile, llama-3.1-8b-instant, mixtral-8x7b-32768 |
Fast inference, cost-effective |
In your .env file, set the LLM_PROVIDER variable:
export LLM_PROVIDER=gemini # Options: gemini, openai, anthropic, groqSet the appropriate API key for your chosen provider:
# For Gemini (default)
export GOOGLE_API_KEY=your_google_api_key_here
# For OpenAI
export OPENAI_API_KEY=your_openai_api_key_here
# For Anthropic
export ANTHROPIC_API_KEY=your_anthropic_api_key_here
# For Groq
export GROQ_API_KEY=your_groq_api_key_hereEach provider supports model and temperature customization:
# Gemini Configuration
export GEMINI_MODEL=gemini-1.5-pro
export GEMINI_TEMPERATURE=0.1
# OpenAI Configuration
export OPENAI_MODEL=gpt-4o
export OPENAI_TEMPERATURE=0.1
# Anthropic Configuration
export ANTHROPIC_MODEL=claude-3-5-sonnet-20241022
export ANTHROPIC_TEMPERATURE=0.1
# Groq Configuration
export GROQ_MODEL=llama-3.1-70b-versatile
export GROQ_TEMPERATURE=0.1export LLM_PROVIDER=gemini
export GOOGLE_API_KEY=your_google_api_key_here
export GEMINI_MODEL=gemini-1.5-proexport LLM_PROVIDER=openai
export OPENAI_API_KEY=your_openai_api_key_here
export OPENAI_MODEL=gpt-4oexport LLM_PROVIDER=anthropic
export ANTHROPIC_API_KEY=your_anthropic_api_key_here
export ANTHROPIC_MODEL=claude-3-5-sonnet-20241022export LLM_PROVIDER=groq
export GROQ_API_KEY=your_groq_api_key_here
export GROQ_MODEL=llama-3.1-70b-versatileMake sure you have all required dependencies installed:
pip install -r requirements.txtThis will install all LLM provider libraries:
langchain-google-genaifor Geminilangchain-openaifor OpenAIlangchain-anthropicfor Anthropiclangchain-groqfor Groq
- Go to Google AI Studio
- Create a new API key
- Set it as
GOOGLE_API_KEY
- Go to OpenAI Platform
- Navigate to API Keys section
- Create a new API key
- Set it as
OPENAI_API_KEY
- Go to Anthropic Console
- Create an API key
- Set it as
ANTHROPIC_API_KEY
- Go to Groq Console
- Create an API key
- Set it as
GROQ_API_KEY
Once configured, the system will automatically use your chosen provider:
# The system will detect your LLM_PROVIDER and use the appropriate model
python3 src/llm/test_case_generator.py --target-class "com.example.MyService"You'll see output like:
🤖 Initializing OPENAI LLM...
Model: gpt-4o
Temperature: 0.1
❌ Missing dependency for OPENAI: No module named 'langchain_openai'
Install required package: pip install langchain-openai
Solution: Install the specific package:
pip install langchain-openai # or langchain-anthropic, langchain-groq❌ API key not found. Please set OPENAI_API_KEY environment variable for openai
Solution: Set the correct API key in your .env file.
❌ Failed to initialize OPENAI LLM: Incorrect API key provided
Solution: Verify your API key is correct and has appropriate permissions.
- OpenAI GPT-4o: Most reliable and consistent results
- Anthropic Claude 3.5 Sonnet: Excellent instruction following
- Gemini 1.5 Flash: Good balance of speed and quality
- Groq Llama 3.1-8b-instant: Very fast inference
- Gemini 1.5 Pro: Large 2M token context window
- Anthropic Claude 3.5 Sonnet: 200k token context
Approximate costs per 1M tokens (as of 2024):
| Provider | Model | Input | Output |
|---|---|---|---|
| Gemini | 1.5-pro | $3.50 | $10.50 |
| Gemini | 1.5-flash | $0.075 | $0.30 |
| OpenAI | gpt-4o | $2.50 | $10.00 |
| OpenAI | gpt-4o-mini | $0.15 | $0.60 |
| Anthropic | claude-3.5-sonnet | $3.00 | $15.00 |
| Groq | llama-3.1-70b | $0.59 | $0.79 |
Prices subject to change - check provider websites for current rates