uplinkswitch 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
uplinkswitch/__init__.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""UplinkSwitch: one API key for Claude, GPT, Gemini, DeepSeek and more.
|
|
2
|
+
|
|
3
|
+
The API speaks the OpenAI, Anthropic and Gemini wire formats, so this package
|
|
4
|
+
only points the official SDKs at https://api.uplinkswitch.com/v1 and reads your
|
|
5
|
+
key from UPLINKSWITCH_API_KEY. The catalog helpers need no key.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import urllib.request
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
__version__ = "0.1.0"
|
|
16
|
+
|
|
17
|
+
BASE_URL = "https://api.uplinkswitch.com/v1"
|
|
18
|
+
ENV_KEY = "UPLINKSWITCH_API_KEY"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _key(api_key: str | None) -> str:
|
|
22
|
+
key = api_key or os.environ.get(ENV_KEY)
|
|
23
|
+
if not key:
|
|
24
|
+
raise ValueError(f"Pass api_key or set {ENV_KEY} (keys start with sk-uplink-).")
|
|
25
|
+
return key
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def openai_client(api_key: str | None = None, **kwargs: Any):
|
|
29
|
+
"""An openai.OpenAI client on UplinkSwitch. Needs `pip install uplinkswitch[openai]`."""
|
|
30
|
+
from openai import OpenAI
|
|
31
|
+
|
|
32
|
+
return OpenAI(api_key=_key(api_key), base_url=BASE_URL, **kwargs)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def async_openai_client(api_key: str | None = None, **kwargs: Any):
|
|
36
|
+
"""An openai.AsyncOpenAI client on UplinkSwitch."""
|
|
37
|
+
from openai import AsyncOpenAI
|
|
38
|
+
|
|
39
|
+
return AsyncOpenAI(api_key=_key(api_key), base_url=BASE_URL, **kwargs)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def anthropic_client(api_key: str | None = None, **kwargs: Any):
|
|
43
|
+
"""An anthropic.Anthropic client on UplinkSwitch. Needs `pip install uplinkswitch[anthropic]`."""
|
|
44
|
+
from anthropic import Anthropic
|
|
45
|
+
|
|
46
|
+
return Anthropic(api_key=_key(api_key), base_url=BASE_URL, **kwargs)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _get(path: str, timeout: float) -> Any:
|
|
50
|
+
req = urllib.request.Request(BASE_URL + path, headers={"User-Agent": f"uplinkswitch-python/{__version__}"})
|
|
51
|
+
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
52
|
+
return json.load(resp)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def models(timeout: float = 15) -> list[dict[str, Any]]:
|
|
56
|
+
"""Chat models with their price and the developer's list price, per 1M tokens. No key needed."""
|
|
57
|
+
return _get("/catalog", timeout)["data"]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def media_models(timeout: float = 15) -> list[dict[str, Any]]:
|
|
61
|
+
"""Image, video, speech and 3D models with prices. No key needed."""
|
|
62
|
+
return _get("/catalog/media", timeout)["data"]
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
"BASE_URL",
|
|
67
|
+
"ENV_KEY",
|
|
68
|
+
"openai_client",
|
|
69
|
+
"async_openai_client",
|
|
70
|
+
"anthropic_client",
|
|
71
|
+
"models",
|
|
72
|
+
"media_models",
|
|
73
|
+
]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: uplinkswitch
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: One API key for Claude, GPT, Gemini, DeepSeek and 80+ models, through the OpenAI and Anthropic SDKs.
|
|
5
|
+
Project-URL: Homepage, https://uplinkswitch.com
|
|
6
|
+
Project-URL: Documentation, https://uplinkswitch.com/guides/sdks
|
|
7
|
+
Project-URL: Models, https://uplinkswitch.com/models
|
|
8
|
+
Project-URL: Pricing, https://uplinkswitch.com/pricing-index
|
|
9
|
+
Author-email: Uplink Switch LLC <hello@uplinkswitch.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai gateway,anthropic,claude api,gemini api,gpt api,llm,llm api,openai compatible
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Provides-Extra: all
|
|
20
|
+
Requires-Dist: anthropic>=0.34; extra == 'all'
|
|
21
|
+
Requires-Dist: openai>=1.40; extra == 'all'
|
|
22
|
+
Provides-Extra: anthropic
|
|
23
|
+
Requires-Dist: anthropic>=0.34; extra == 'anthropic'
|
|
24
|
+
Provides-Extra: openai
|
|
25
|
+
Requires-Dist: openai>=1.40; extra == 'openai'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# uplinkswitch
|
|
29
|
+
|
|
30
|
+
Python client for [UplinkSwitch](https://uplinkswitch.com): one API key for Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, Grok and more, priced under each developer's list. The API speaks the OpenAI and Anthropic formats, so you keep the official SDKs.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install "uplinkswitch[openai]" # or [anthropic], or [all]
|
|
34
|
+
export UPLINKSWITCH_API_KEY="sk-uplink-live-..."
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Get a key at [uplinkswitch.com/console](https://uplinkswitch.com/console). New accounts get $1 of free credit.
|
|
38
|
+
|
|
39
|
+
## OpenAI SDK
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import uplinkswitch
|
|
43
|
+
|
|
44
|
+
client = uplinkswitch.openai_client()
|
|
45
|
+
reply = client.chat.completions.create(
|
|
46
|
+
model="claude-opus-5-5",
|
|
47
|
+
messages=[{"role": "user", "content": "Say hi in five words."}],
|
|
48
|
+
)
|
|
49
|
+
print(reply.choices[0].message.content)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Anthropic SDK
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import uplinkswitch
|
|
56
|
+
|
|
57
|
+
client = uplinkswitch.anthropic_client()
|
|
58
|
+
msg = client.messages.create(
|
|
59
|
+
model="claude-sonnet-5-5",
|
|
60
|
+
max_tokens=200,
|
|
61
|
+
messages=[{"role": "user", "content": "Say hi in five words."}],
|
|
62
|
+
)
|
|
63
|
+
print(msg.content[0].text)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Prices, no key needed
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import uplinkswitch
|
|
70
|
+
|
|
71
|
+
for m in uplinkswitch.models():
|
|
72
|
+
lp, p = m.get("list_pricing"), m["pricing"]
|
|
73
|
+
if lp:
|
|
74
|
+
print(f'{m["id"]:<28} ${p["input"]}/${p["output"]} per 1M (list ${lp["input"]}/${lp["output"]})')
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`uplinkswitch.media_models()` returns the image, video and speech models.
|
|
78
|
+
|
|
79
|
+
## Without this package
|
|
80
|
+
|
|
81
|
+
Set `OPENAI_BASE_URL` or `ANTHROPIC_BASE_URL` to `https://api.uplinkswitch.com/v1` and use your key. Setup for Claude Code, Cursor, Cline, Roo and OpenCode: [uplinkswitch.com/guides](https://uplinkswitch.com/guides).
|
|
82
|
+
|
|
83
|
+
- Models and prices: [uplinkswitch.com/models](https://uplinkswitch.com/models)
|
|
84
|
+
- Daily real-model check: [uplinkswitch.com/proof](https://uplinkswitch.com/proof)
|
|
85
|
+
- Contact: hello@uplinkswitch.com
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
uplinkswitch/__init__.py,sha256=zU_-i778xo_Y2SbZXpoWSL7W0wRt4Ndz5Y3o6y-cDVc,2284
|
|
2
|
+
uplinkswitch-0.1.0.dist-info/METADATA,sha256=wPYRqTD5GZ2bmlJuP7ym9zK9ClBBeuolPFQqqGnYozM,3002
|
|
3
|
+
uplinkswitch-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
4
|
+
uplinkswitch-0.1.0.dist-info/licenses/LICENSE,sha256=DrQcyyoSEWZUAbfSqGAEAc7tYkhhL52w7FSia7b_LR4,1074
|
|
5
|
+
uplinkswitch-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Uplink Switch LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|