Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Breaking changes

- Core
- The **LLM Advisor** supports **API Route**, an OpenAI-compatible multi-model gateway: set **`LLM_PROVIDER: api-route`** and **`API_ROUTE_API_KEY`** to use API Route models through MegaLinter.

- New linters

Expand Down
5 changes: 3 additions & 2 deletions docs/llm-advisor.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MegaLinter includes an AI-powered advisor that provides intelligent fix suggesti

## Features

- **Multi-Provider Support**: Works with OpenAI, Anthropic, Google Gemini, Hugging Face, Mistral AI, DeepSeek, Grok, OrcaRouter, and local Ollama models
- **Multi-Provider Support**: Works with OpenAI, Anthropic, Google Gemini, Hugging Face, Mistral AI, DeepSeek, Grok, OrcaRouter, API Route, and local Ollama models
- **Context-Aware Suggestions**: Analyzes code context around errors for better recommendations
- **Integrated Reporting**: AI suggestions appear directly in MegaLinter reports
- **Configurable**: Control which models to use and how many errors to analyze
Expand All @@ -22,6 +22,7 @@ MegaLinter includes an AI-powered advisor that provides intelligent fix suggesti
| [DeepSeek](llm-provider/llm_provider_deepseek.md) | Yes | Cloud | [Setup Guide](llm-provider/llm_provider_deepseek.md) |
| [Grok](llm-provider/llm_provider_grok.md) | Yes | Cloud | [Setup Guide](llm-provider/llm_provider_grok.md) |
| [OrcaRouter](llm-provider/llm_provider_orcarouter.md) | Yes | Cloud | [Setup Guide](llm-provider/llm_provider_orcarouter.md) |
| [API Route](llm-provider/llm_provider_api_route.md) | Yes | Cloud | [Setup Guide](llm-provider/llm_provider_api_route.md) |
| [Ollama](llm-provider/llm_provider_ollama.md) | No | Local | [Setup Guide](llm-provider/llm_provider_ollama.md) |
| [Hugging Face](llm-provider/llm_provider_huggingface.md) | Optional | Local/Cloud | [Setup Guide](llm-provider/llm_provider_huggingface.md) |

Expand All @@ -38,7 +39,7 @@ See [All LLM Providers](llm-providers.md) for a complete comparison and setup in
LLM_ADVISOR_ENABLED: true

# Choose your provider and model
LLM_PROVIDER: openai # openai, anthropic, google, huggingface, mistral, deepseek, grok, orcarouter, ollama
LLM_PROVIDER: openai # openai, anthropic, google, huggingface, mistral, deepseek, grok, orcarouter, api-route, ollama
LLM_MODEL_NAME: gpt-4.1-mini
LLM_MAX_TOKENS: 1000
LLM_TEMPERATURE: 0.1
Expand Down
74 changes: 74 additions & 0 deletions docs/llm-provider/llm_provider_api_route.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<div align="center">
<img src="https://www.api-route.com/favicon.ico" alt="API Route Logo" height="64" />
</div>

# API Route Provider

[API Route](https://www.api-route.com) is an OpenAI-compatible multi-model AI API gateway. It provides one base URL and API key for accessing models from multiple providers, including GPT, Claude, Gemini, Kimi, and Qwen.

## Setup

1. **Get API Key**: Sign in to [API Route](https://www.api-route.com) and create an API key.

2. **Set Environment Variable**:

Set **API_ROUTE_API_KEY=your-api-key** in your CI/CD secret variables.

> Make sure the secret variable is sent to MegaLinter from your CI/CD workflow. Example in GitHub Action: `API_ROUTE_API_KEY: ${{ secrets.API_ROUTE_API_KEY }}`

3. **Configure MegaLinter**:

```yaml
LLM_ADVISOR_ENABLED: true
LLM_PROVIDER: api-route
LLM_MODEL_NAME: gpt-5.6-sol
LLM_MAX_TOKENS: 1000
LLM_TEMPERATURE: 0.1
```

## Model List

For the current list of models available through API Route, see:

- [API Route Pricing and Models](https://www.api-route.com/pricing)

## Configuration Options

### Basic Configuration

```yaml
LLM_PROVIDER: api-route
LLM_MODEL_NAME: gpt-5.6-sol
```

### Advanced Configuration

```yaml
# Custom API endpoint (if needed)
API_ROUTE_BASE_URL: https://global.api-route.com/v1
```

## Troubleshooting

### Common Issues

1. **"Invalid API key"**

- Verify `API_ROUTE_API_KEY` is correct
- Check that the key is active and has available balance

2. **"Rate limit exceeded"**

- Check your API Route usage and rate limits
- Retry with appropriate backoff

3. **"Model not available"**

- Verify the value of `LLM_MODEL_NAME`
- Check the current model list on the [API Route pricing page](https://www.api-route.com/pricing)

### Debug Mode

```yaml
LOG_LEVEL: DEBUG
```
3 changes: 2 additions & 1 deletion docs/llm-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ This page provides a comprehensive comparison of all supported LLM providers for
| [Mistral AI](llm-provider/llm_provider_mistralai.md) | $ | Cloud | Easy | European alternative |
| [DeepSeek](llm-provider/llm_provider_deepseek.md) | $ | Cloud | Easy | Code-focused models |
| [Grok](llm-provider/llm_provider_grok.md) | $$ | Cloud | Easy | xAI's conversational model |
| [OrcaRouter](llm-provider/llm_provider_orcarouter.md) | $$ | Cloud | Easy | Multi-model AI gateway |
| [OrcaRouter](llm-provider/llm_provider_orcarouter.md) | $ | Cloud | Easy | Multi-model AI gateway |
| [API Route](llm-provider/llm_provider_api_route.md) | $ | Cloud | Easy | Unified multi-model gateway |
| [Ollama](llm-provider/llm_provider_ollama.md) | Free | Local | Medium | Privacy, offline use |
| [Hugging Face](llm-provider/llm_provider_huggingface.md) | Free* | Local/Cloud | Hard | Open models, customization |

Expand Down
1 change: 1 addition & 0 deletions megalinter/llm_provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This directory contains the modular LLM provider system for MegaLinter's AI-powe
| DeepSeek | `llm_provider_deepseek.py` | DeepSeek Chat, DeepSeek Coder | Yes |
| Grok | `llm_provider_grok.py` | Grok Beta (xAI) | Yes |
| OrcaRouter | `llm_provider_orcarouter.py` | Any model routed by OrcaRouter | Yes |
| API Route | `llm_provider_api_route.py` | GPT, Claude, Gemini, and more | Yes |
| Hugging Face | `llm_provider_huggingface.py` | Any HF transformer model | Optional |
| Ollama | `llm_provider_ollama.py` | Llama, CodeLlama, Mistral, etc. | No |

Expand Down
1 change: 1 addition & 0 deletions megalinter/llm_provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"DeepSeekProvider": "llm_provider_deepseek",
"GrokProvider": "llm_provider_grok",
"OrcaRouterProvider": "llm_provider_orcarouter",
"ApiRouteProvider": "llm_provider_api_route",
}

__all__ = [
Expand Down
72 changes: 72 additions & 0 deletions megalinter/llm_provider/llm_provider_api_route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""
API Route LLM Provider for MegaLinter
"""

import logging
from typing import Any, Dict, Optional

from langchain_openai import ChatOpenAI
from megalinter import config

from .llm_provider import LLMProvider


class ApiRouteProvider(LLMProvider):

def get_default_model(self) -> str:
return "gpt-5.6-sol"

def load_config(self, request_id: Optional[str] = None) -> Dict[str, Any]:
return {
"api_key": config.get(request_id, "API_ROUTE_API_KEY", ""),
"base_url": config.get(
request_id,
"API_ROUTE_BASE_URL",
"https://global.api-route.com/v1",
),
"model_name": config.get(request_id, "LLM_MODEL_NAME", ""),
"temperature": float(
config.get(
request_id,
"LLM_TEMPERATURE",
str(self.get_default_config_value("temperature")),
)
),
"max_tokens": int(
config.get(
request_id,
"LLM_MAX_TOKENS",
str(self.get_default_config_value("max_tokens")),
)
),
}

def initialize(self) -> bool:
try:
api_key = self.get_config_value("api_key")
if not api_key:
raise ValueError("API_ROUTE_API_KEY is required")

model_name = self.get_config_value("model_name") or self.get_default_model()
base_url = self.get_config_value(
"base_url", "https://global.api-route.com/v1"
)
temperature = self.get_config_value("temperature")
max_tokens = self.get_config_value("max_tokens")

# API Route exposes an OpenAI-compatible API.
self.llm = ChatOpenAI(
model=model_name,
temperature=temperature,
max_tokens=max_tokens,
api_key=api_key,
base_url=base_url,
)

logging.debug(f"API Route provider initialized with model {model_name}")
return True

except Exception as e:
logging.error(f"Failed to initialize API Route provider: {str(e)}")
return False
3 changes: 3 additions & 0 deletions megalinter/llm_provider/llm_provider_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LLMProviderFactory:
"deepseek": ("llm_provider_deepseek", "DeepSeekProvider"),
"grok": ("llm_provider_grok", "GrokProvider"),
"orcarouter": ("llm_provider_orcarouter", "OrcaRouterProvider"),
"api-route": ("llm_provider_api_route", "ApiRouteProvider"),
}

@classmethod
Expand Down Expand Up @@ -78,6 +79,7 @@ def get_supported_providers(cls) -> Dict[str, str]:
"deepseek": "DeepSeek models",
"grok": "Grok (xAI) models",
"orcarouter": "OrcaRouter models",
"api-route": "API Route models",
}

@classmethod
Expand All @@ -92,4 +94,5 @@ def get_supported_providers_api_key_var_names(cls) -> list[str]:
"DEEPSEEK_API_KEY",
"GROK_API_KEY",
"ORCAROUTER_API_KEY",
"API_ROUTE_API_KEY",
]
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ nav:
- "MistralAI": "llm-provider/llm_provider_mistralai.md"
- "OpenAI": "llm-provider/llm_provider_openai.md"
- "OrcaRouter": "llm-provider/llm_provider_orcarouter.md"
- "API Route": "llm-provider/llm_provider_api_route.md"
- "Ollama": "llm-provider/llm_provider_ollama.md"
- "Hugging Face": "llm-provider/llm_provider_huggingface.md"
- "Flavors":
Expand Down