[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80614":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":12,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":8,"rankLanguage":8,"license":8,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":17,"hasPages":17,"topics":19,"createdAt":8,"pushedAt":8,"updatedAt":20,"readmeContent":21,"aiSummary":22,"trendingCount":14,"starSnapshotCount":14,"syncStatus":23,"lastSyncTime":24,"discoverSource":25},80614,"CodexSwitch","AIDotNet\u002FCodexSwitch","AIDotNet",null,"C#",119,22,1,3,0,7,39.29,false,"master",[],"2026-06-12 04:01:29","# CodexSwitch\n\n[English](README.md) | [简体中文](README.zh-CN.md)\n\n[![GitHub stars](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002FAIDotNet\u002FCodexSwitch?style=social)](https:\u002F\u002Fgithub.com\u002FAIDotNet\u002FCodexSwitch\u002Fstargazers)\n[![CI](https:\u002F\u002Fgithub.com\u002FAIDotNet\u002FCodexSwitch\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002FAIDotNet\u002FCodexSwitch\u002Factions\u002Fworkflows\u002Fci.yml)\n[![.NET 10](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F.NET-10.0-512BD4)](https:\u002F\u002Fdotnet.microsoft.com\u002F)\n[![Avalonia](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAvalonia-12.0.3-8B44AC)](https:\u002F\u002Favaloniaui.net\u002F)\n\nCodexSwitch is a cross-platform Avalonia desktop app that turns Codex into a local, switchable AI provider workstation. It runs an OpenAI Responses-compatible proxy on your machine, writes a managed Codex configuration, routes requests across multiple upstream providers, converts protocol dialects when needed, and keeps local usage and cost records.\n\nThe default local endpoint is:\n\n```text\nhttp:\u002F\u002F127.0.0.1:12785\u002Fv1\n```\n\n## What It Does\n\nCodex talks to CodexSwitch as if it were an OpenAI Responses API endpoint. CodexSwitch then selects the right provider for the requested model, rewrites model and service-tier settings, converts requests and streaming responses for providers that use different APIs, and records token usage in a local JSONL log.\n\n```mermaid\nflowchart LR\n    Codex[\"Codex client\"] --> Proxy[\"CodexSwitch local \u002Fv1 proxy\"]\n    Proxy --> Router[\"Provider and model routing\"]\n    Router --> OpenAI[\"OpenAI Responses\"]\n    Router --> Chat[\"OpenAI-compatible Chat\"]\n    Router --> Anthropic[\"Anthropic Messages\"]\n    OpenAI --> Usage[\"Usage and cost log\"]\n    Chat --> Usage\n    Anthropic --> Usage\n```\n\n## Features\n\n- Local proxy with `\u002Fhealth`, `\u002Fv1\u002Fmodels`, and `\u002Fv1\u002Fresponses` endpoints.\n- One-click active provider switching from the desktop UI.\n- Built-in provider templates for RoutinAI, RoutinAI Plan, OpenAI Official, Anthropic Messages, DeepSeek, and Xiaomi MiMo.\n- Dedicated Codex OAuth login flow for the ChatGPT Codex backend, including multi-account management.\n- Custom provider support with configurable base URL, API key, protocol, model routes, upstream model names, and service tiers.\n- Protocol adapters for OpenAI Responses, OpenAI-compatible Chat Completions, and Anthropic Messages.\n- Streaming support with Responses-style SSE events where the upstream protocol allows it.\n- Model routing by requested model, including aliases and upstream model remapping.\n- Local model pricing catalog with tiered pricing, cache-read pricing, Claude cache-creation billing, and fast-mode multipliers.\n- Usage dashboard with request logs, provider statistics, model statistics, 24-hour, 7-day, and 30-day trends.\n- Managed Codex config and auth file writing with backup and restore support.\n- Optional Codex App auth preservation so ChatGPT-login-only plugin features can stay available while routing through the local proxy.\n- Light, dark, and system themes with localized UI resources.\n- GitHub Release update checks with automatic system-specific installer downloads.\n\n## Supported Protocols\n\n| Provider protocol | Upstream endpoint | Notes |\n| --- | --- | --- |\n| `OpenAiResponses` | `\u002Fresponses` | Passes Responses requests through with model, service-tier, and request override handling. |\n| `OpenAiChat` | `\u002Fchat\u002Fcompletions` | Converts inbound Responses requests to Chat Completions and converts the result back to Responses shape. |\n| `AnthropicMessages` | `\u002Fmessages` | Converts inbound Responses requests to Anthropic Messages, including tool calls, thinking\u002Freasoning mapping, and usage normalization where supported. |\n\nCodexSwitch currently exposes Responses-style inbound routes. It does not expose `\u002Fv1\u002Fchat\u002Fcompletions` as a public inbound API.\n\n## Built-In Providers\n\n| Provider | Default protocol | Example default model |\n| --- | --- | --- |\n| RoutinAI | OpenAI Responses | `gpt-5.5` |\n| RoutinAI Plan | OpenAI Responses | `gpt-5.5` |\n| OpenAI Official | OpenAI Responses | `gpt-5.5` |\n| Anthropic Messages | Anthropic Messages | `claude-sonnet-4-5` |\n| DeepSeek | OpenAI Chat | `deepseek-v4-flash` |\n| Xiaomi MiMo | OpenAI Chat | `mimo-v2.5-pro` |\n| Codex OAuth | OpenAI Responses | `gpt-5.1-codex` |\n\nYou can add custom providers when an upstream service is OpenAI Responses-compatible, OpenAI Chat-compatible, or Anthropic Messages-compatible.\n\n## Installation\n\nDownload published builds from [GitHub Releases](https:\u002F\u002Fgithub.com\u002FAIDotNet\u002FCodexSwitch\u002Freleases) when release artifacts are available.\n\nCurrent CI publish artifacts are Native AOT, self-contained packages:\n\n- `CodexSwitch-vX.Y.Z-win-x64-setup.exe`\n- `CodexSwitch-vX.Y.Z-linux-x64.AppImage`\n- `CodexSwitch-vX.Y.Z-osx-arm64.dmg`\n\n## Run From Source\n\nPrerequisite: .NET SDK `10.0.203`, as pinned by `global.json`.\n\n```powershell\ngit clone https:\u002F\u002Fgithub.com\u002FAIDotNet\u002FCodexSwitch.git\ncd CodexSwitch\ndotnet restore CodexSwitch.Tests\u002FCodexSwitch.Tests.csproj\ndotnet run --project CodexSwitch\u002FCodexSwitch.csproj\n```\n\n## First Run\n\n1. Open CodexSwitch.\n2. Choose a built-in provider template or create a custom provider.\n3. Add the provider API key, or use the Codex OAuth login button for the Codex OAuth provider.\n4. Set the provider as active.\n5. Keep the local proxy enabled. Codex clients can use `http:\u002F\u002F127.0.0.1:12785\u002Fv1`.\n\nWhen the proxy starts, CodexSwitch writes managed `.codex` and `.claude` files and keeps the originals as same-name `.bak` backups. When the proxy stops, the originals are restored from those `.bak` files.\n\nIf you need Codex App plugins, sign in to Codex App with ChatGPT first, then enable **Settings > Auth > Preserve Codex App ChatGPT login for plugins** before applying the proxy configuration. In that mode CodexSwitch still writes `config.toml`, but leaves the original `auth.json` login state in place.\n\n## Local Files\n\nCodexSwitch stores application state in the user's application data folder.\n\nOn Windows, the main files are:\n\n| File | Purpose |\n| --- | --- |\n| `%APPDATA%\\CodexSwitch\\config.json` | Providers, routing, UI, proxy, OAuth account metadata, and local settings. |\n| `%APPDATA%\\CodexSwitch\\model-pricing.json` | Editable pricing catalog used for cost estimates. |\n| `%APPDATA%\\CodexSwitch\\usage-logs\\yyyy\\MM\\usage-yyyy-MM-dd.jsonl` | Partitioned local request usage logs. |\n| `%APPDATA%\\CodexSwitch\\icons\\` | Cached provider and model icons. |\n| `%USERPROFILE%\\.codex\\config.toml` | Managed Codex config while the proxy is enabled; the original file is kept as `config.toml.bak`. |\n| `%USERPROFILE%\\.codex\\auth.json` | Managed Codex auth while the proxy is enabled, unless Codex App auth preservation is enabled; the original file is kept as `auth.json.bak`. |\n| `%USERPROFILE%\\.claude\\settings.json` | Managed Claude Code settings while the proxy is enabled; the original file is kept as `settings.json.bak`. |\n\nTreat the config files as sensitive because they can contain API keys and OAuth tokens.\n\n## Development\n\nRestore, build, and test:\n\n```powershell\ndotnet restore CodexSwitch.Tests\u002FCodexSwitch.Tests.csproj\ndotnet build CodexSwitch.Tests\u002FCodexSwitch.Tests.csproj -c Release --no-restore\ndotnet test CodexSwitch.Tests\u002FCodexSwitch.Tests.csproj -c Release --no-build --no-restore\n```\n\nPublish a self-contained Native AOT build:\n\n```powershell\ndotnet publish CodexSwitch\u002FCodexSwitch.csproj -c Release -r win-x64 --self-contained true -p:PublishAot=true\n```\n\nValidate the changelog before release work:\n\n```powershell\n.\u002Fbuild\u002FValidate-Changelog.ps1\n```\n\n## Project Structure\n\n```text\nCodexSwitch\u002F\n  Controls\u002F        Reusable Avalonia controls\n  I18n\u002F            Runtime localization services and markup extension\n  Models\u002F          App config, provider, pricing, and usage models\n  Proxy\u002F           Local proxy host, routing, protocol adapters, payload builders\n  Services\u002F        Config storage, Codex config writing, usage, pricing, icons, updates\n  Styles\u002F          Avalonia theme and component styles\n  ViewModels\u002F      Main desktop application state and commands\n  Views\u002F           Windows, pages, dialogs, and shell components\nCodexSwitch.Tests\u002F xUnit coverage for routing, pricing, config writing, usage, i18n, and updates\nbuild\u002F             Release and validation scripts\ndocs\u002F              Release process notes\n```\n\n## CI and Release Flow\n\nThe `ci` workflow validates the changelog, restores packages, builds the test project, runs xUnit tests, and publishes Native AOT platform installers for Windows, Linux, and macOS runners. When the workflow runs on a `vX.Y.Z` tag, it also creates the GitHub Release and uploads the generated artifacts automatically. See [docs\u002Frelease.md](docs\u002Frelease.md).\n\n## Current Scope\n\n- The Claude Code page exists, but this build does not write Claude-specific local configuration yet.\n- Keep the proxy host on `127.0.0.1` unless you intentionally want to expose it beyond your machine.\n- Cost estimates depend on the local pricing catalog and should be treated as estimates, not billing statements.\n\n## Contributing\n\nIssues and pull requests are welcome. For changes that affect routing, protocol conversion, pricing, usage accounting, or config writing, please include focused tests in `CodexSwitch.Tests`.\n\nBefore opening a pull request:\n\n```powershell\ndotnet test CodexSwitch.Tests\u002FCodexSwitch.Tests.csproj -c Release\n.\u002Fbuild\u002FValidate-Changelog.ps1\n```\n\n## License\n\nThis repository does not currently declare a license. Add a `LICENSE` file before distributing the project as open-source software or accepting external contributions.\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=AIDotNet\u002FCodexSwitch&type=Date)](https:\u002F\u002Fwww.star-history.com\u002F#AIDotNet\u002FCodexSwitch&Date)\n","CodexSwitch 是一个跨平台的桌面应用程序，旨在将 Codex 转换为本地可切换的 AI 服务工作站。它通过在用户机器上运行一个与 OpenAI Responses 兼容的代理，实现对多个上游 AI 提供商的请求路由、协议转换以及本地使用记录和成本跟踪等功能。项目采用 C# 开发，并基于 Avalonia UI 框架构建，确保了良好的跨平台兼容性。适用于需要集成多种 AI 服务或希望对 AI 服务进行更精细控制的应用场景，如开发人员工具、自动化脚本环境等。此外，它还提供了详细的使用统计信息及可视化界面，便于管理和监控。",2,"2026-06-11 04:01:23","CREATED_QUERY"]