feat: add Kimi (Moonshot AI) provider + refactor admin key management #144

Merged
nabil_salah merged 3 commits from refactor_add_remove_endpoints into main 2026-06-09 13:34:31 +00:00
Member

Summary

This PR adds Kimi (Moonshot AI) as a first-class provider and improves the admin API key management endpoints with duplicate prevention and value-based removal.

Changes

1. New Provider: Kimi (Moonshot AI)

  • Added kimi_api_keys to Config with full hero_proc integration
  • Created Kimi provider using OpenAI-compatible endpoint (https://api.moonshot.cn/v1)
  • Added Kimi to audio (TTS/STT) and embedding provider builders
  • Updated chat fallback order to include "kimi"
  • Added "kimi" to fake-mode provider lists
  • Updated modelsconfig.yml to route kimi-k2 through direct Kimi API (priority 1) with OpenRouter fallback (priority 2)
  • Updated README/PURPOSE docs to list Kimi as a supported provider

2. Admin Key Management Improvements

providers.add_key:

  • Added duplicate check — returns error if key already exists for the provider
  • Prevents accidental double-adds that would create redundant pool entries

providers.remove_key:

  • New behavior: Now accepts a key parameter and removes by value
  • Returns error if the key is not found

providers.remove_key_by_index:

  • Renamed from the old providers.remove_key (index-based removal preserved)
  • Accepts key_index parameter (0-based)

3. Admin UI Updates

  • Updated provider pane to support both removal methods:
    • "Remove" button per key (uses remove_key_by_index)
    • New "Remove by key" input + button (uses remove_key)
  • Updated OpenRPC specs and schema definitions

4. Documentation

  • Added provider key management section to docs/api.md with curl examples
  • Updated supported provider list to include kimi

API Changes

# Add key (duplicate-safe)
POST admin/rpc -d '{"method":"providers.add_key","params":{"provider":"kimi","key":"sk-kimi-..."}}'

# Remove by value (new behavior)
POST admin/rpc -d '{"method":"providers.remove_key","params":{"provider":"kimi","key":"sk-kimi-..."}}'

# Remove by index (renamed method)
POST admin/rpc -d '{"method":"providers.remove_key_by_index","params":{"provider":"kimi","key_index":0}}'

Testing

  • Added unit tests for add/remove logic and Kimi provider support
  • All 101 existing tests pass
  • Integration tested against running server:
    • Key add/remove (by value and by index)
    • Duplicate rejection
    • Kimi model routing
    • Chat completions via direct Kimi API
## Summary This PR adds **Kimi (Moonshot AI)** as a first-class provider and improves the admin API key management endpoints with duplicate prevention and value-based removal. ## Changes ### 1. New Provider: Kimi (Moonshot AI) - Added `kimi_api_keys` to `Config` with full hero_proc integration - Created Kimi provider using OpenAI-compatible endpoint (`https://api.moonshot.cn/v1`) - Added Kimi to audio (TTS/STT) and embedding provider builders - Updated chat fallback order to include `"kimi"` - Added `"kimi"` to fake-mode provider lists - Updated `modelsconfig.yml` to route `kimi-k2` through direct Kimi API (priority 1) with OpenRouter fallback (priority 2) - Updated README/PURPOSE docs to list Kimi as a supported provider ### 2. Admin Key Management Improvements **`providers.add_key`:** - Added duplicate check — returns error if key already exists for the provider - Prevents accidental double-adds that would create redundant pool entries **`providers.remove_key`:** - **New behavior**: Now accepts a `key` parameter and removes by value - Returns error if the key is not found **`providers.remove_key_by_index`:** - **Renamed** from the old `providers.remove_key` (index-based removal preserved) - Accepts `key_index` parameter (0-based) ### 3. Admin UI Updates - Updated provider pane to support both removal methods: - "Remove" button per key (uses `remove_key_by_index`) - New "Remove by key" input + button (uses `remove_key`) - Updated OpenRPC specs and schema definitions ### 4. Documentation - Added provider key management section to `docs/api.md` with curl examples - Updated supported provider list to include `kimi` ## API Changes ```bash # Add key (duplicate-safe) POST admin/rpc -d '{"method":"providers.add_key","params":{"provider":"kimi","key":"sk-kimi-..."}}' # Remove by value (new behavior) POST admin/rpc -d '{"method":"providers.remove_key","params":{"provider":"kimi","key":"sk-kimi-..."}}' # Remove by index (renamed method) POST admin/rpc -d '{"method":"providers.remove_key_by_index","params":{"provider":"kimi","key_index":0}}' ``` ## Testing - Added unit tests for add/remove logic and Kimi provider support - All 101 existing tests pass - Integration tested against running server: - Key add/remove (by value and by index) - Duplicate rejection - Kimi model routing - Chat completions via direct Kimi API
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
feat add more tests
All checks were successful
Build and Test / build (pull_request) Successful in 7m55s
6b1f09000f
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
nabil_salah deleted branch refactor_add_remove_endpoints 2026-06-10 08:07:32 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_aibroker!144
No description provided.