(args: list[str])
| 1681 | |
| 1682 | |
| 1683 | def _setup_claude_code(args: list[str]) -> None: |
| 1684 | from uncommon_route.proxy import DEFAULT_PORT |
| 1685 | |
| 1686 | flags, _ = _parse_flags(args, {"port": True}) |
| 1687 | port = int(flags.get("port", DEFAULT_PORT)) |
| 1688 | rc = _detect_rc_file() |
| 1689 | upstream_val, key_display, status = _setup_env_display() |
| 1690 | |
| 1691 | print(f""" |
| 1692 | UncommonRoute + Claude Code |
| 1693 | {'=' * 40} |
| 1694 | |
| 1695 | Add to {rc}: |
| 1696 | |
| 1697 | # --- UncommonRoute proxy --- |
| 1698 | export UNCOMMON_ROUTE_UPSTREAM="{upstream_val}" |
| 1699 | export UNCOMMON_ROUTE_API_KEY="{key_display}" |
| 1700 | |
| 1701 | # --- Claude Code → UncommonRoute --- |
| 1702 | export ANTHROPIC_BASE_URL="http://localhost:{port}" |
| 1703 | export ANTHROPIC_AUTH_TOKEN="not-needed" |
| 1704 | export NO_PROXY="localhost,127.0.0.1,::1${{NO_PROXY:+,$NO_PROXY}}" |
| 1705 | export no_proxy="$NO_PROXY" |
| 1706 | |
| 1707 | Then: |
| 1708 | |
| 1709 | 1. source {rc} |
| 1710 | 2. uncommon-route serve (terminal 1) |
| 1711 | 3. claude (terminal 2) |
| 1712 | |
| 1713 | How it works: |
| 1714 | |
| 1715 | Claude Code --POST /v1/messages--> UncommonRoute --best model--> Upstream API |
| 1716 | (smart routing) |
| 1717 | |
| 1718 | - Auth is managed by the proxy. Claude Code does not need a real Anthropic key. |
| 1719 | - All requests are smart-routed to the best model automatically. |
| 1720 | - Responses are converted back to Anthropic format transparently. |
| 1721 | """) |
| 1722 | print(f" Status: {status}") |
| 1723 | |
| 1724 | |
| 1725 | def _setup_codex(args: list[str]) -> None: |
nothing calls this directly
no test coverage detected