Commit 5616993
authored
feat: complete AI provider configurations with universal model pattern support (#234)
* feat: complete AI provider configurations in ai-gateway template
This commit completes the AI Gateway template configuration by adding
initialization for all new providers introduced in PR #219:
**New providers added:**
- AWS Bedrock (with region and auth configuration)
- Google Vertex AI (with project/region/service account)
- OpenRouter (multi-provider router)
- Cloudflare Workers AI (with account ID)
- DeepL (translation service with target language)
- Dify (AI workflow platform with bot type and variables)
- iFlyTek Spark
- Tencent Hunyuan (with auth ID/key)
- Fireworks AI
- GitHub Models
- Grok (xAI)
- Groq
- Together AI
**Key improvements:**
1. Added conditional initialization for all new providers based on
configuration markers set in get-ai-gateway.sh
2. Implemented support for custom model patterns via environment variables
(e.g., BEDROCK_MODELS, VERTEX_MODELS, etc.) for providers with
non-deterministic model sets
3. Properly configured extra configs (regions, auth keys, account IDs)
for providers requiring additional parameters
4. Maintained alphabetical ordering for better readability
5. Added comprehensive comments for each provider section
**Environment variable pattern:**
For providers with uncertain model sets, users can now customize the
model matching pattern, e.g.:
- BEDROCK_MODELS="claude-.*" for AWS Bedrock Claude models
- VERTEX_MODELS="gemini-.*" for Vertex AI Gemini models
- Default: ".*" (matches all models)
Fixes the issue where PR #219 added provider configurations in
get-ai-gateway.sh but the actual template generation in ai-gateway.sh
was missing the corresponding initialization.
* feat: add model pattern configuration support for all new providers
This commit adds comprehensive model pattern configuration support:
**Interactive mode improvements:**
- Added model pattern configuration prompts to all provider config functions
- For providers with known model patterns (Vertex=gemini-.*, Bedrock=.*, etc.),
provided sensible defaults
- Users can specify custom regex patterns during interactive setup
**CLI parameter support:**
Added new CLI arguments for model pattern configuration:
- --bedrock-models, --vertex-models, --openrouter-models
- --cloudflare-models, --deepl-models, --dify-models
- --fireworks-models, --github-models, --grok-models
- --groq-models, --spark-models, --hunyuan-models
- --togetherai-models
**New configuration functions:**
Added dedicated config functions for providers that previously only
supported API key input:
- configureOpenRouterProvider()
- configureFireworksProvider()
- configureGitHubProvider()
- configureGrokProvider()
- configureGroqProvider()
- configureTogetherAIProvider()
**Usage examples:**
CLI mode:
```bash
./get-ai-gateway.sh start --bedrock-key="xxx" --bedrock-models="claude-.*"
./get-ai-gateway.sh start --openrouter-key="xxx" --openrouter-models=".*"
```
Interactive mode:
Users are now prompted to enter model patterns after API credentials,
with helpful examples and sensible defaults.
All model pattern environment variables are properly passed to the
ai-gateway.sh template via LLM_ENVS array.
* feat: add model pattern configuration for ALL providers
This commit extends model pattern configuration to ALL providers,
not just the newly added ones.
**Template changes (ai-gateway.sh):**
All providers now support custom model patterns via environment variables:
- DASHSCOPE_MODELS (default: qwen)
- DEEPSEEK_MODELS (default: deepseek)
- MOONSHOT_MODELS (default: moonshot-.*|kimi-.*)
- ZHIPUAI_MODELS (default: GLM-)
- MINIMAX_MODELS (default: abab)
- AZURE_MODELS (default: gpt-.*|o1-.*|o3-.*)
- OPENAI_MODELS (default: gpt-.*|o1-.*|o3-.*)
- YI_MODELS (default: yi-)
- AI360_MODELS (default: 360GPT)
- BAICHUAN_MODELS (default: Baichuan)
- BAIDU_MODELS (default: ERNIE-)
- CLAUDE_MODELS (default: claude-)
- COHERE_MODELS (default: command|command-.*)
- DOUBAO_MODELS (default: doubao-)
- GEMINI_MODELS (default: gemini-)
- MISTRAL_MODELS (default: open-mistral-.*|mistral-.*)
- OLLAMA_MODELS (default: codellama.*|llama.*)
- STEPFUN_MODELS (default: step-)
- (Plus all previously added providers)
**CLI parameter support:**
Added corresponding --xxx-models parameters for all providers:
--dashscope-models, --deepseek-models, --moonshot-models,
--zhipuai-models, --minimax-models, --azure-models, --openai-models,
--yi-models, --ai360-models, --baichuan-models, --baidu-models,
--claude-models, --cohere-models, --doubao-models, --gemini-models,
--mistral-models, --ollama-models, --stepfun-models
**Interactive configuration functions:**
Added/updated configuration functions for all providers:
- configureDashscopeProvider()
- configureDeepSeekProvider()
- configureMoonshotProvider()
- configureZhipuAIProvider()
- configureOpenAIProvider()
- configureYiProvider()
- configureAI360Provider()
- configureBaichuanProvider()
- configureBaiduProvider()
- configureCohereProvider()
- configureDoubaoProvider()
- configureGeminiProvider()
- configureMistralProvider()
- configureStepfunProvider()
Updated existing functions with model pattern support:
- configureAzureProvider()
- configureMinimaxProvider()
- configureClaudeProvider()
- configureOllamaProvider()
Each function now prompts for model patterns with sensible defaults
matching the template configuration.
**Usage examples:**
```bash
# Customize models for standard providers
./get-ai-gateway.sh start \
--openai-key="$KEY" --openai-models="gpt-4.*" \
--dashscope-key="$KEY" --dashscope-models="qwen-.*"
# Mix and match providers by model
./get-ai-gateway.sh start \
--deepseek-key="$KEY" --deepseek-models="deepseek-coder.*" \
--moonshot-key="$KEY" --moonshot-models="kimi.*"
```
Now EVERY provider supports custom model pattern configuration,
enabling fine-grained control over model routing.
* feat: add universal model pattern normalization function
This commit adds a unified model pattern normalization system that
supports multiple flexible input formats and intelligently converts
them to optimal match types.
**New normalizeModelPattern() function:**
Supports the following input formats:
1. **Wildcard suffix**: `qwen-*` → PRE `qwen-`
- Converts to prefix match for efficiency
2. **Exact model name**: `qwen3-max` → PRE `qwen3-max`
- Uses prefix match for exact names
3. **Multiple wildcards**: `kimi-*,moonshot-*` → REGULAR `kimi-.*|moonshot-.*`
- Comma-separated patterns with wildcards
- Converts to regex with OR operator
4. **Multiple exact names**: `kimi-2.5,moonshot-k1` → REGULAR `kimi-2.5|moonshot-k1`
- Comma-separated exact model names
- Creates regex OR pattern
5. **Mixed patterns**: `qwen-*,gpt-4` → REGULAR `qwen-.*|gpt-4`
- Supports mixing wildcards and exact names
6. **Match all**: `*` → REGULAR `.*`
- Universal wildcard for all models
**Smart type detection:**
- Single pattern with `-*` suffix → PRE (prefix match, more efficient)
- Multiple patterns (comma-separated) → REGULAR (regex with OR)
- Complex wildcards → REGULAR (full regex power)
- Empty pattern → REGULAR `.*` (match all)
**Updated all provider configurations:**
All providers now use normalizeModelPattern() to process their
model patterns, enabling:
- Consistent user experience across all providers
- Flexible configuration via environment variables
- Automatic optimization (PRE vs REGULAR)
- Support for complex multi-model routing
**Default pattern updates:**
Changed defaults to use the more intuitive wildcard syntax:
- `qwen-*` instead of `qwen`
- `gpt-*,o1-*,o3-*` instead of `gpt-.*|o1-.*|o3-.*`
- `moonshot-*,kimi-*` instead of `moonshot-.*|kimi-.*`
Users can now configure models in the most natural way:
```bash
# Simple prefix match
DASHSCOPE_MODELS="qwen-*"
# Multiple models
OPENAI_MODELS="gpt-4-turbo,gpt-4o"
# Mix exact and wildcard
CLAUDE_MODELS="claude-3-5-sonnet-*,claude-opus-4"
# Comma-separated wildcards
MOONSHOT_MODELS="moonshot-*,kimi-*"
```
The normalization function handles all conversion automatically!
* docs: add comprehensive model pattern configuration help
Added detailed documentation for model pattern configurations in the
--help output, including:
**Format Documentation:**
Documented all 6 supported input formats with examples:
1. Wildcard prefix: `qwen-*` (matches qwen-max, qwen-plus, etc.)
2. Exact model name: `gpt-4-turbo` (matches only this model)
3. Multiple wildcards: `moonshot-*,kimi-*` (matches multiple series)
4. Multiple exact names: `gpt-4-turbo,gpt-4o,gpt-4o-mini`
5. Mixed patterns: `claude-3-5-sonnet-*,claude-opus-4-20250514`
6. Match all: `*` (catch-all provider)
Each format includes:
- Clear example usage
- What it matches
- When to use it
**Available Options:**
Listed all 30+ --xxx-models parameters with provider names:
- --dashscope-models, --deepseek-models, --moonshot-models
- --zhipuai-models, --minimax-models, --azure-models
- --openai-models, --openrouter-models, --yi-models
- ... and all other providers
**Practical Examples:**
Added real-world usage examples:
1. Route specific models to specific providers:
```bash
./get-ai-gateway.sh start --non-interactive \
--openai-key sk-xxx --openai-models "gpt-4-*" \
--deepseek-key sk-xxx --deepseek-models "deepseek-*" \
--claude-key sk-xxx --claude-models "claude-3-5-sonnet-*"
```
2. Multi-provider setup with exact model names:
```bash
./get-ai-gateway.sh start --non-interactive \
--openai-key sk-xxx --openai-models "gpt-4-turbo,gpt-4o" \
--claude-key sk-xxx --claude-models "claude-opus-4-20250514"
```
3. Use OpenRouter as catch-all:
```bash
./get-ai-gateway.sh start --non-interactive \
--openai-key sk-xxx --openai-models "gpt-4-*" \
--openrouter-key sk-xxx --openrouter-models "*"
```
Users can now run `./get-ai-gateway.sh -h` to get comprehensive
guidance on model pattern configuration!1 parent 9f1b76c commit 5616993
2 files changed
Lines changed: 929 additions & 50 deletions
0 commit comments