(args: list[str])
| 1723 | |
| 1724 | |
| 1725 | def _setup_codex(args: list[str]) -> None: |
| 1726 | from uncommon_route.proxy import DEFAULT_PORT |
| 1727 | |
| 1728 | flags, _ = _parse_flags(args, {"port": True}) |
| 1729 | port = int(flags.get("port", DEFAULT_PORT)) |
| 1730 | rc = _detect_rc_file() |
| 1731 | upstream_val, key_display, status = _setup_env_display() |
| 1732 | |
| 1733 | print(f""" |
| 1734 | UncommonRoute + OpenAI Codex |
| 1735 | {'=' * 40} |
| 1736 | |
| 1737 | Add to {rc}: |
| 1738 | |
| 1739 | # --- UncommonRoute proxy --- |
| 1740 | export UNCOMMON_ROUTE_UPSTREAM="{upstream_val}" |
| 1741 | export UNCOMMON_ROUTE_API_KEY="{key_display}" |
| 1742 | |
| 1743 | # --- Codex → UncommonRoute --- |
| 1744 | export OPENAI_BASE_URL="http://localhost:{port}/v1" |
| 1745 | export OPENAI_API_KEY="not-needed" |
| 1746 | |
| 1747 | Then: |
| 1748 | |
| 1749 | 1. source {rc} |
| 1750 | 2. uncommon-route serve (terminal 1) |
| 1751 | 3. codex (terminal 2) |
| 1752 | |
| 1753 | How it works: |
| 1754 | |
| 1755 | Codex --POST /v1/chat/completions--> UncommonRoute --best model--> Upstream API |
| 1756 | (smart routing) |
| 1757 | |
| 1758 | - Set model to "uncommon-route/auto" for smart routing. |
| 1759 | - Auth is managed by the proxy. Codex does not need a real API key. |
| 1760 | - Non-virtual model names are passed through unchanged. |
| 1761 | """) |
| 1762 | print(f" Status: {status}") |
| 1763 | |
| 1764 | |
| 1765 | def _setup_openai(args: list[str]) -> None: |
nothing calls this directly
no test coverage detected