MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _setup_openai

Function _setup_openai

uncommon_route/cli.py:1765–1802  ·  view source on GitHub ↗
(args: list[str])

Source from the content-addressed store, hash-verified

1763
1764
1765def _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
1804def _cmd_scene(args: list[str]) -> None:
1805 """Manage named routing scenes."""

Callers

nothing calls this directly

Calls 4

_parse_flagsFunction · 0.85
_detect_rc_fileFunction · 0.85
_setup_env_displayFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected