Sign inSign up

jerryin/new-api-channel-updater

By jerryin

โ€ขUpdated 13 days ago

Image
0

3.3K

jerryin/new-api-channel-updater repository overview

โ New-API Channel Updater

Automated tool for fetching the latest AI model lists from multiple platforms and updating them to your API service channels.

โ โœจ Features

  • Multi-platform Support: Automatically fetches the latest AI models from OpenRouter, Google Gemini, Cloudflare AI, and NVIDIA NIM
  • Model Availability Test: Optionally probes each model (chat / embeddings) before updating the channel and drops the broken ones
  • Automated Updates: Updates model lists to your API service channels automatically
  • Scheduled Tasks: Supports cron expressions for scheduled execution
  • Flexible Configuration: Easy configuration via config.ini file or environment variables
  • Module Enable/Disable: Control module activation via configuration
  • Notification: Supports DingTalk notifications for task results
  • Containerized Deployment: Docker image for easy deployment
  • CLI Tool: Manual execution via command-line interface
  • Concurrent Execution: Multi-threaded parallel execution for efficiency

โ ๐Ÿš€ Quick Start

First, create a config.ini file with your settings (see Configurationโ  section for details).

Then run the container:

docker run -d --name new-api-channel-updater --restart=unless-stopped \
  -v $(pwd)/config.ini:/app/config.ini \
  -v $(pwd)/logs:/app/logs \
  jerryin/new-api-channel-updater
โ Docker Compose
services:
  new-api-channel-updater:
    image: jerryin/new-api-channel-updater
    container_name: new-api-channel-updater
    restart: unless-stopped
    volumes:
      - ./config.ini:/app/config.ini
      - ./logs:/app/logs

โ โš™๏ธ Configuration

Create a config.ini file with the following structure:

[api]
base_url = http://your-api:3000/api
token = your_api_token
new_api_user = 1

[openrouter]
enabled = true
channel_id = 1
api_key = your_openrouter_api_key  # Optional, can be empty
free_model_mapping = false
token_threshold = 10000000  # Minimum total tokens threshold (prompt + completion)
fixed_models = openai/gpt-4.5,anthropic/claude-3.7  # Comma-separated fixed model IDs (optional)

[gemini]
enabled = true
channel_id = 2
api_key = your_gemini_api_key
excluded_keywords =  # Comma-separated keywords to exclude (optional)

[nvidia]
enabled = true
channel_id = 3
api_token = your_nvidia_api_token  # Optional, can be empty
excluded_models =  # Comma-separated model IDs to exclude (optional)
# Enable the model availability test for this module only (overrides global [model_test])
model_test_enabled = false

[cloudflare]
enabled = true
channel_id = 4
account_id = your_cloudflare_account_id
api_token = your_cloudflare_api_token  # Bearer token for Cloudflare API

[dingtalk]
access_token = your_dingtalk_access_token
secret = your_dingtalk_secret

[schedule]
cron = 30 */4 * * *

[log]
loglevel = INFO
keep_days = 7

[model_test]
# Model availability test: send one minimal request to verify a model really works
enabled = false
api_key =
base_url =
concurrency = 8
timeout = 30
max_tokens = 16
retries = 1
cache_hours = 24
cache_dir = logs/model_test
test_types = auto
on_error = keep
on_all_failed = keep_all
prompt = hi
embedding_input = hello

All configuration options can also be set via environment variables with the format SECTION_OPTION (e.g., API_BASE_URL, OPENROUTER_ENABLED).

โ ๐Ÿงช Model Availability Test

Model lists returned by providers often contain models that cannot actually be invoked (deprecated, not deployed, vision/embedding-only, ...). When enabled, every model is probed with a minimal request before the channel is updated:

  • chat models: POST {base_url}/chat/completions with the configured max_tokens;
  • embeddings models: POST {base_url}/embeddings;
  • The probe type is controlled by test_types: with auto it is inferred from the model ID, and models that cannot be probed (e.g. rerank / reward models) are skipped and kept.
โ Options
OptionDefaultDescription
enabledfalseMaster switch; when disabled no module runs any test
api_keyemptyAPI key used for probing; falls back to the module credential (e.g. nvidia.api_token)
base_urlemptyProbe endpoint; falls back to the module built-in URL
concurrency8Number of models probed in parallel
timeout30Timeout (seconds) of a single probe request
max_tokens16Max tokens for the chat probe, keep it small to lower the cost
retries1Retries per model (4xx responses fail fast without retrying)
cache_hours24How long a probe result stays cached; 0 disables the cache
cache_dirlogs/model_testDirectory of the result cache
test_typesautoauto / chat / embeddings
on_errorkeepPer-model failure: keep (log only) or drop (remove from the list)
on_all_failedkeep_allWhen every model fails (bad key / network outage): keep_all keeps the current models and skips the update, error does the same but marks the module run as failed
prompthiPrompt used for the chat probe
embedding_inputhelloInput used for the embeddings probe
โ Per-module overrides

Any module section can override the global settings with the model_test_ prefix, e.g. enable it for NVIDIA only:

[model_test]
enabled = false
timeout = 30
on_error = keep

[nvidia]
enabled = true
channel_id = 3
api_token = your_nvidia_api_token
model_test_enabled = true
model_test_timeout = 90

on_error defaults to keep (log only, no removal). Run a round first, check the failure list in logs/nvidia_nim.log, then switch to drop once it looks correct. Results are cached for cache_hours, so transient network errors will not immediately change the channel.

โ ๐Ÿ› ๏ธ Manual Execution

Execute modules manually using the CLI tool:

# View CLI tool help information
docker exec new-api-channel-updater python cli.py --help

# List available modules
docker exec new-api-channel-updater python cli.py --list

# Execute a specific module
docker exec new-api-channel-updater python cli.py openrouter

# Execute all modules
docker exec new-api-channel-updater python cli.py all

โ ๐Ÿงฉ Supported Platforms

  • OpenRouter: Gets model lists from OpenRouter's API
  • Google Gemini: Fetches models from Google Gemini API
  • Cloudflare AI: Fetches Text Generation models from Cloudflare AI API
  • NVIDIA NIM: Fetches AI models from NVIDIA NIM API

โ ๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSEโ  file for details.

Tag summary

Content type

Image

Digest

sha256:3d7c63349โ€ฆ

Size

50.3 MB

Last updated

13 days ago

docker pull jerryin/new-api-channel-updater