- Implemented `codexAlphaSearchSelectionModel` and `codexAlphaSearchModelRouterHost` for dynamic model selection using plugin-based routing.
- Introduced new `codex-alpha-search` source format for model route requests.
- Integrated routing logic into the model selection pipeline to handle Codex Alpha Search requests with fallback mechanisms.
- Introduced `ClaudeInputTokenState` to track and estimate input token usage for Claude message_start events.
- Added `TranslateStreamWithClaudeInputTokens` for token-aware stream translation.
- Updated executors (XAI, Kimi, Gemini) to leverage the new logic.
- Included robust test cases for token counting, JSON validation, and concurrent tokenization scenarios.
- Refactored token counting logic into a reusable `countXAIInputTokens` function for better readability and maintainability.
- Replaced direct encoder usage with structured input handling, including JSON parsing and segment collection.
- Switched tokenizer from `Cl100kBase` to `O200kBase` to support larger contexts.
Closes: #4492
- Moved `parallel_tool_calls` and `tool_choice` logic inside conditional handling for `chatCompletionsTools`.
- Eliminated redundant field updates to streamline payload processing.
Closes: #4491
- Replaced references to K2.6 with K3 across README files (EN, CN, JA).
- Highlighted Kimi K3's capabilities as the world's first open 3T-class model, including 2.8T parameters, native vision, and enhanced context window (1M tokens).
- Updated quickstart links and clarified CLIProxyAPI support information.
Preserve Codex and XAI upstream message-too-big closes across the Responses WebSocket boundary while treating them as request-scoped errors. Prevent CPA reconnect and credential cooldown/fallback, scope close state to the active connection, retain terminal errors under backpressure, and ensure downstream disconnect cleanup cannot wait behind a blocked writer.
- Added `GetGJSONBytesNoCopy` in `internal/util` for safe, no-copy JSON parse operations leveraging `unsafe`.
- Replaced `gjson.GetBytes` with the new helper in key payload processing paths (`kimi_executor`, `vertex_payload_helpers`, etc.) to improve performance.
- Added unit tests for behavior validation, including edge cases with empty input.
- Introduced `SetStringIfDifferent`, `SetBoolIfDifferent`, and similar helpers in `payload_helpers` to avoid unnecessary writes during JSON modifications.
- Simplified message patching in `kimi_executor` for reasoning and tool call adjustments.
- Updated all executors (Gemini, Codex, XAI, Antigravity, etc.) to use the new helpers, enhancing readability and potentially reducing overhead.
- Removed obsolete `filterKimiEmptyAssistantMessages` function in `kimi_executor`.
- Added tests to ensure no-copy payload reuse for various translators (Codex, Gemini, OpenAI, Claude, etc.).
- Covered scenarios for field normalization, tool parameter cleaning, and thought signature sanitization.
- Included a benchmark for SanitizeGeminiRequestThoughtSignatures with large normalized payloads.
- Introduced field normalization functions (`setCodexRequiredBool`, `setCodexRequiredInclude`) to ensure correct Codex input structure.
- Added tests for normalized payload reuse and field validation in `ConvertOpenAIResponsesRequestToCodex`.
- Implemented `deleteCodexRequestFields` utility to remove unsupported fields dynamically.
- Added benchmarks for normalized payload processing to measure performance across different payload sizes.
Closes: #4362
- Updated `SanitizeCodexInputItemIDs` to remove encrypted reasoning items with IDs exceeding the Codex length limit.
- Refactored logic to deterministically shorten other overlong input item IDs, ensuring compliance with the Codex format.
- Added new tests to verify dropping behavior for encrypted reasoning and shortening of lengthy IDs without encrypted content.
- Added `NormalizeOpenAIFileData` utility to parse and validate file content, ensuring proper MIME type handling and base64 extraction.
- Refactored translation logic to use normalized file data for Gemini, Antigravity, and Interactions processors.
- Introduced comprehensive unit tests for both valid and invalid file data scenarios across all translators.
Fixed: #4416
- Updated `ConvertOpenAIResponsesRequestToOpenAIChatCompletions` to include namespaces when generating function names for tool calls.
- Added test case to validate namespace qualification logic for function call histories.
Fixed: #4423
- Added conditional logic to append `content_block_start` for empty responses, ensuring correct event flow.
- Updated default `responseJSON` structure to use an empty array (`[]`) for the `content` field instead of `null`.
Fixed: #4431
- Refactored state management to introduce deterministic output indexing for reasoning, messages, and function calls.
- Added new structures `MessageItems` and `ReasoningItems` to aggregate responses with consistent indices.
- Updated OpenAI response generation to include `output_index` for all outputs, ensuring correct order and no gaps.
- Enhanced tests to validate contiguous output indices and response event lifecycle.
Fixed: #4429
- Added `promoteXAIAdditionalTools` to normalize and migrate `additional_tools` to the top-level `tools` array in XAI request bodies.
- Updated test cases to validate the promotion logic and ensure unsupported `additional_tools` items are excluded from input payloads.
Closes: #4434
- Implemented logic to differentiate between generic and explicit model-not-found errors for the `count_tokens` endpoint.
- Introduced `recordAvailabilityNeutralResult` to ensure models remain active for generic endpoint errors.
- Expanded test coverage to verify behavior for various 404 scenarios, including error propagation and model suspension handling.
- Refactored error-parsing utilities to identify structured and nested model-not-found errors.
Closes: #4410
- Modified `CredentialFileName` to incorporate `hashAccountID` for better disambiguation when available.
- Updated fallback behavior to maintain compatibility with legacy email-based filenames.
- Refined test suite to validate scenarios with and without account hash and plan type.
Closes: #4425
- Introduced dedicated plugin sync operation timeout (`homePluginSyncOperationTimeout`) for improved task handling.
- Added `cloneRedisOptions` function to safely duplicate Redis options and prevent mutation.
- Modified plugin sync to use a dedicated Redis client with independent configurations.
- Enhanced `GetPluginSync` logic to handle cancellation, timeouts, and TLS handshake gracefully.
- Expanded unit tests to validate new Redis client behavior, plugin sync timeouts, and cancellation handling.
- Updated Kimi executor to delegate non-streaming and streaming Claude requests to the Claude executor when `SourceFormat` is `claude`.
- Injected `base_url` for Claude API compatibility during delegation.
- Removed "Preview" suffix from model IDs, display names, and descriptions.
- Standardized naming conventions for all Gemini 3.x models to reflect production readiness.
- Updated Kimi executor to route all Claude requests through the OpenAI-compatible chat completions API.
- Removed legacy delegation to Claude executor for non-streaming and streaming execution.
- Enhanced translator integration for request normalization and Kimi model stripping.
- Updated tests to validate chat completions behavior, including upstream request logging, payload transformation, and response handling.
- Deleted Kimi K3[1M] variant and associated metadata.
Claude Code sends the configured model name (e.g. kimi-k3[1m]) to
CLIProxyAPI. The Kimi executor forwarded this internal ID to Kimi's
https://api.kimi.com/coding endpoint. Kimi treats kimi-k3 and
kimi-k3[1m] as 256K-context models, while only bare k3 supports the
full 1M context window.
Normalize the upstream model by stripping the CLIProxyAPI kimi- prefix
and any Claude Code [1m] suffix while preserving a trailing thinking
suffix (e.g. (1024)), so that requests for kimi-k3, kimi-k3[1m],
kimi-k3(1024), and kimi-k3[1m](1024) are all sent to Kimi as k3 or
k3(1024). This applies to:
- Execute (Claude and OpenAI branches)
- ExecuteStream (Claude and OpenAI branches)
- CountTokens
Validation (using the stored Kimi token):
- GET /v1/models shows k3 with context_length 1048576.
- Direct /v1/messages calls with ~270k input tokens:
- model=k3 succeeds.
- model=k3[1m], kimi-k3, kimi-k3[1m] fail with:
'Your request exceeded model token limit: 262144 (requested: 270014)'.
Add unit tests for normalizeKimiUpstreamModel.
Closes#4418
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Added an `incomingHeaders` argument to `applyClaudeHeaders` to enable external header injection for flexibility.
- Updated Kimi executor to delegate header support to Claude executor, facilitating upstream request logging and beta header forwarding.
- Introduced tests for delegated configuration, header handling, and upstream request/response logging to improve coverage.