Skip to content

refactor: move model pattern defaults to get-ai-gateway.sh#241

Merged
johnlanni merged 5 commits into
mainfrom
feat/move-model-patterns-to-get-script
Feb 7, 2026
Merged

refactor: move model pattern defaults to get-ai-gateway.sh#241
johnlanni merged 5 commits into
mainfrom
feat/move-model-patterns-to-get-script

Conversation

@johnlanni
Copy link
Copy Markdown
Contributor

Motivation

Currently, model pattern defaults (e.g., MOONSHOT_MODELS="moonshot-*,kimi-*") are hardcoded in ai-gateway.sh which runs inside the container. When new models are released, updating these defaults requires rebuilding and redistributing the container image.

Changes

1. Move defaults to get-ai-gateway.sh

  • Add all model pattern defaults in the resetEnv() function
  • Defaults are now in the host script, making them easy to update via git

2. Update writeConfiguration()

  • Persist all *_MODELS variables to the config file
  • Ensure defaults are passed to the container via --env-file

3. Simplify ai-gateway.sh

  • Remove hardcoded defaults (e.g., ${MOONSHOT_MODELS:-moonshot-*,kimi-*})
  • Use environment variables directly (e.g., ${MOONSHOT_MODELS})
  • Container now relies on externally-configured values

Benefits

No container rebuild needed - Update model patterns by editing get-ai-gateway.sh
Single source of truth - Defaults managed in one place (get-ai-gateway.sh)
Version controlled - Model updates tracked in git history
Backward compatible - Existing installations continue to work
User override supported - Users can still pass --xxx-models flags

Example

# Defaults now in get-ai-gateway.sh (line ~580)
: "${MOONSHOT_MODELS:=moonshot-*,kimi-*}"

# When Moonshot releases kimi-k2, just update the script:
: "${MOONSHOT_MODELS:=moonshot-*,kimi-*,kimi-k2}"

# No need to rebuild containers!

Testing

  • Verified existing installations continue to work
  • Tested with default model patterns
  • Tested with user-overridden patterns via CLI flags
  • Confirmed config file persistence

Related Issue

Addresses the need to update model patterns frequently without image rebuilds (e.g., when providers release new models like Kimi-K1).

- Move all model pattern defaults from ai-gateway.sh (container) to get-ai-gateway.sh (host script)
- Add model pattern defaults in resetEnv() function for easy updates
- Update writeConfiguration() to persist all *_MODELS variables to config file
- Simplify ai-gateway.sh to use environment variables directly
- Enables updating model patterns without rebuilding the container image

Benefits:
- Single source of truth for default model patterns
- Easier to update when new models are released
- Better maintainability through version control
- Backward compatible with existing installations
@johnlanni johnlanni requested a review from CH3CHO as a code owner February 7, 2026 07:55
- Add glm-* pattern to ZHIPUAI_MODELS (case-insensitive)
- Add minimax-* pattern to MINIMAX_MODELS (case-insensitive)
- Users can now use both GLM-4 and glm-4 style model names
- Aligns with mixed naming conventions from different API endpoints
- Add configureClaudeCodeProvider() function in get-ai-gateway.sh
- Add Claude Code to Top 10 commonly used providers list
- Support --claude-code-key and --claude-code-models CLI flags
- Add CLAUDE_CODE_MODELS default pattern: claude-code-*
- Add claudeCodeMode=true configuration in ai-gateway.sh
- Claude Code uses OAuth token (Bearer auth) instead of x-api-key
- Enables Claude Code CLI token authentication for AI Gateway

Claude Code mode differences:
- Uses Bearer token authorization
- Sets x-app: cli header
- Adds anthropic-beta headers for OAuth/Claude Code features
- Adds ?beta=true query parameter
- Auto-injects default system prompt and Bash tool
Add user-friendly prompt when configuring Claude Code mode:
- Inform users to run 'claude setup-token' to get OAuth token
- Clear instructions for token acquisition
- Improves user experience during interactive setup
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.

1 participant