feat(claude): add model alias mapping and improve key normalization

- Introduced model alias mapping for Claude configurations, enabling upstream and client-facing model name associations.
- Added `computeClaudeModelsHash` to generate a consistent hash for model aliases.
- Implemented `normalizeClaudeKey` function to standardize input API key configuration, including models.
- Enhanced executor to resolve model aliases to upstream names dynamically.
- Updated documentation and configuration examples to reflect new model alias support.
This commit is contained in:
Luis Pater
2025-10-28 00:03:41 +08:00
parent 6f9c23af5e
commit c7196ba7dc
10 changed files with 242 additions and 13 deletions

View File

@@ -318,6 +318,9 @@ The server uses a YAML configuration file (`config.yaml`) located in the project
| `claude-api-key.api-key` | string | "" | Claude API key. |
| `claude-api-key.base-url` | string | "" | Custom Claude API endpoint, if you use a third-party API endpoint. |
| `claude-api-key.proxy-url` | string | "" | Proxy URL for this specific API key. Overrides the global proxy-url setting. Supports socks5/http/https protocols. |
| `claude-api-key.models` | object[] | [] | Model alias entries for this key. |
| `claude-api-key.models.*.name` | string | "" | Upstream Claude model name invoked against the API. |
| `claude-api-key.models.*.alias` | string | "" | Client-facing alias that maps to the upstream model name. |
| `openai-compatibility` | object[] | [] | Upstream OpenAI-compatible providers configuration (name, base-url, api-keys, models). |
| `openai-compatibility.*.name` | string | "" | The name of the provider. It will be used in the user agent and other places. |
| `openai-compatibility.*.base-url` | string | "" | The base URL of the provider. |
@@ -325,9 +328,11 @@ The server uses a YAML configuration file (`config.yaml`) located in the project
| `openai-compatibility.*.api-key-entries` | object[] | [] | API key entries with optional per-key proxy configuration. Preferred over api-keys. |
| `openai-compatibility.*.api-key-entries.*.api-key` | string | "" | The API key for this entry. |
| `openai-compatibility.*.api-key-entries.*.proxy-url` | string | "" | Proxy URL for this specific API key. Overrides the global proxy-url setting. Supports socks5/http/https protocols. |
| `openai-compatibility.*.models` | object[] | [] | The actual model name. |
| `openai-compatibility.*.models.*.name` | string | "" | The models supported by the provider. |
| `openai-compatibility.*.models.*.alias` | string | "" | The alias used in the API. |
| `openai-compatibility.*.models` | object[] | [] | Model alias definitions routing client aliases to upstream names. |
| `openai-compatibility.*.models.*.name` | string | "" | Upstream model name invoked against the provider. |
| `openai-compatibility.*.models.*.alias` | string | "" | Client alias routed to the upstream model. |
When `claude-api-key.models` is specified, only the provided aliases are registered in the model registry (mirroring OpenAI compatibility behaviour), and the default Claude catalog is suppressed for that credential.
### Example Configuration File