(args: list[str])
| 1763 | |
| 1764 | |
| 1765 | def _setup_openai(args: list[str]) -> None: |
| 1766 | from uncommon_route.proxy import DEFAULT_PORT |
| 1767 | |
| 1768 | flags, _ = _parse_flags(args, {"port": True}) |
| 1769 | port = int(flags.get("port", DEFAULT_PORT)) |
| 1770 | rc = _detect_rc_file() |
| 1771 | upstream_val, key_display, status = _setup_env_display() |
| 1772 | |
| 1773 | print(f""" |
| 1774 | UncommonRoute + OpenAI SDK / Cursor |
| 1775 | {'=' * 40} |
| 1776 | |
| 1777 | Add to {rc}: |
| 1778 | |
| 1779 | # --- UncommonRoute proxy --- |
| 1780 | export UNCOMMON_ROUTE_UPSTREAM="{upstream_val}" |
| 1781 | export UNCOMMON_ROUTE_API_KEY="{key_display}" |
| 1782 | |
| 1783 | Then: |
| 1784 | |
| 1785 | 1. source {rc} |
| 1786 | 2. uncommon-route serve |
| 1787 | |
| 1788 | Python usage: |
| 1789 | |
| 1790 | from openai import OpenAI |
| 1791 | client = OpenAI( |
| 1792 | base_url="http://localhost:{port}/v1", |
| 1793 | api_key="not-needed", |
| 1794 | ) |
| 1795 | client.chat.completions.create( |
| 1796 | model="uncommon-route/auto", # smart routing |
| 1797 | messages=[{{"role": "user", "content": "hello"}}], |
| 1798 | ) |
| 1799 | |
| 1800 | Cursor: set "OpenAI Base URL" to http://localhost:{port}/v1 in settings. |
| 1801 | """) |
| 1802 | print(f" Status: {status}") |
| 1803 | |
| 1804 | def _cmd_scene(args: list[str]) -> None: |
| 1805 | """Manage named routing scenes.""" |
nothing calls this directly
no test coverage detected