veylox 0.1.0__tar.gz
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.
- veylox-0.1.0/.gitignore +11 -0
- veylox-0.1.0/CHANGELOG.md +29 -0
- veylox-0.1.0/LICENSE +21 -0
- veylox-0.1.0/PKG-INFO +214 -0
- veylox-0.1.0/README.md +173 -0
- veylox-0.1.0/pyproject.toml +79 -0
- veylox-0.1.0/src/veylox/__init__.py +102 -0
- veylox-0.1.0/src/veylox/_version.py +3 -0
- veylox-0.1.0/src/veylox/client.py +855 -0
- veylox-0.1.0/src/veylox/detect.py +78 -0
- veylox-0.1.0/src/veylox/errors.py +83 -0
- veylox-0.1.0/src/veylox/providers/__init__.py +3 -0
- veylox-0.1.0/src/veylox/providers/anthropic.py +90 -0
- veylox-0.1.0/src/veylox/providers/base.py +85 -0
- veylox-0.1.0/src/veylox/providers/gemini.py +134 -0
- veylox-0.1.0/src/veylox/providers/openai_compat.py +89 -0
- veylox-0.1.0/src/veylox/py.typed +0 -0
- veylox-0.1.0/src/veylox/registry.py +34 -0
- veylox-0.1.0/src/veylox/types.py +89 -0
- veylox-0.1.0/tests/test_client.py +281 -0
- veylox-0.1.0/tests/test_detect.py +45 -0
- veylox-0.1.0/tests/test_providers.py +292 -0
- veylox-0.1.0/tests/test_review_fixes.py +427 -0
veylox-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
### Fixed after code review
|
|
6
|
+
|
|
7
|
+
- `verify()` now catches bad OpenRouter keys (OpenRouter's model list is public, so it checks `/key` instead).
|
|
8
|
+
- Anthropic streams report input tokens (taken from `message_start`) as well as output tokens.
|
|
9
|
+
- A 404 or 400 is only `ModelNotFoundError` when the provider's message names the requested model. A bare 404, such as from a wrong `base_url`, is a `ProviderError` that includes the URL.
|
|
10
|
+
- Tighter matching of error messages, so an unrelated 400 isn't misread as a missing model or a bad key.
|
|
11
|
+
- New `PermissionDeniedError` for HTTP 403 (valid key, access refused). Previously 403s were reported as a rejected key.
|
|
12
|
+
- `"error": null` in a stream chunk is no longer treated as a failure.
|
|
13
|
+
- Extras that would overwrite veylox's own fields (`stream`, plus Gemini's `contents` and `systemInstruction`) are rejected. A Gemini `generationConfig` extra is merged instead of replacing veylox's settings.
|
|
14
|
+
- Clear `InvalidRequestError`s for `stop=5`, NaN or infinite `temperature`/`top_p`, a bad `timeout`, and a non-string `provider=`.
|
|
15
|
+
- `stream_async()` gives "did you mean" model suggestions like the other methods.
|
|
16
|
+
- Keys shorter than 16 characters are fully masked (`***`).
|
|
17
|
+
- `connect(verify=True)` closes its connection if verification fails.
|
|
18
|
+
- A prompt Gemini blocks raises `InvalidRequestError` instead of returning an empty reply.
|
|
19
|
+
- Gemini `tunedModels/...` names work.
|
|
20
|
+
- The publish workflow refuses a tag that doesn't match the package version.
|
|
21
|
+
- `timeout` accepts `None` (no limit) and `httpx.Timeout` objects as well as seconds.
|
|
22
|
+
- A model name is matched as a whole word, so short names and empty segments can't match unrelated text. A proxy 404 that echoes the request path is treated as a wrong URL, not a missing model.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- First release: `veylox.connect()` detects the provider from the key (OpenAI, Anthropic, Gemini, Groq, Mistral, OpenRouter).
|
|
27
|
+
- `chat`, `stream`, `list_models`, `verify` and their `_async` versions.
|
|
28
|
+
- `client.provider` / `client.provider_info` / `veylox.detect_provider()`.
|
|
29
|
+
- Typed errors with "did you mean" model suggestions.
|
veylox-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Paramveer Singh
|
|
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.
|
veylox-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: veylox
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: One key. Every model. Paste any LLM API key and get a client for every model behind it.
|
|
5
|
+
Project-URL: Homepage, https://github.com/GirmadaShaw/veylox
|
|
6
|
+
Project-URL: Documentation, https://github.com/GirmadaShaw/veylox/tree/main/docs
|
|
7
|
+
Project-URL: Source, https://github.com/GirmadaShaw/veylox
|
|
8
|
+
Project-URL: Changelog, https://github.com/GirmadaShaw/veylox/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Paramveer Singh
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,anthropic,api,claude,gemini,groq,llm,mistral,openai,openrouter
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: httpx>=0.24
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
31
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
34
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
35
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
36
|
+
Requires-Dist: twine>=5; extra == 'dev'
|
|
37
|
+
Provides-Extra: docs
|
|
38
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
39
|
+
Requires-Dist: mkdocstrings[python]>=0.25; extra == 'docs'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# veylox
|
|
43
|
+
|
|
44
|
+
**One key. Every model.**
|
|
45
|
+
|
|
46
|
+
Paste in an API key from any major LLM provider. veylox works out which provider it belongs to and gives you a client for every model behind it, using the same simple methods no matter the provider.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import veylox
|
|
50
|
+
|
|
51
|
+
client = veylox.connect("sk-ant-...") # any supported key
|
|
52
|
+
print(client.provider) # "anthropic"
|
|
53
|
+
|
|
54
|
+
reply = client.chat("Explain recursion in one sentence.", model="claude-sonnet-4-5")
|
|
55
|
+
print(reply)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- **No provider setup.** The key decides the provider. No `"openai/..."` model prefixes, no per-provider SDKs.
|
|
59
|
+
- **Same methods everywhere.** `chat`, `stream`, `list_models`, `verify`, with async versions of each.
|
|
60
|
+
- **Clear errors.** Missing parameters are caught before any request is sent, and a mistyped model name comes back with "did you mean" suggestions.
|
|
61
|
+
- **Lightweight.** One dependency (`httpx`). Fully typed.
|
|
62
|
+
- **Safe by default.** Your full key never appears in printed objects, logs or error messages.
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install veylox
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Python 3.10 or newer.
|
|
71
|
+
|
|
72
|
+
## Supported providers
|
|
73
|
+
|
|
74
|
+
| Provider | Key looks like | `client.provider` |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| OpenAI | `sk-...`, `sk-proj-...` | `"openai"` |
|
|
77
|
+
| Anthropic | `sk-ant-...` | `"anthropic"` |
|
|
78
|
+
| Google Gemini | `AIza...` | `"gemini"` |
|
|
79
|
+
| Groq | `gsk_...` | `"groq"` |
|
|
80
|
+
| Mistral | 32 letters and digits | `"mistral"` |
|
|
81
|
+
| OpenRouter | `sk-or-...` | `"openrouter"` |
|
|
82
|
+
|
|
83
|
+
If your key has another format, tell veylox which provider it belongs to: `veylox.connect(key, provider="gemini")`.
|
|
84
|
+
|
|
85
|
+
## Usage
|
|
86
|
+
|
|
87
|
+
### Which provider is my key for?
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
client = veylox.connect(key)
|
|
91
|
+
client.provider # "groq"
|
|
92
|
+
client.provider_info # ProviderInfo(id='groq', name='Groq', base_url='https://api.groq.com/openai/v1',
|
|
93
|
+
# key_hint='gsk_...x9Q2', detected_by='prefix')
|
|
94
|
+
|
|
95
|
+
veylox.detect_provider("AIza...") # "gemini", without making a client or a network call
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Chat
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
reply = client.chat(
|
|
102
|
+
[
|
|
103
|
+
{"role": "system", "content": "You are a concise assistant."},
|
|
104
|
+
{"role": "user", "content": "What is the capital of Japan?"},
|
|
105
|
+
],
|
|
106
|
+
model="gpt-4o-mini",
|
|
107
|
+
temperature=0.2,
|
|
108
|
+
max_tokens=100,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
reply.text # "Tokyo."
|
|
112
|
+
reply.usage # Usage(input_tokens=24, output_tokens=3, total_tokens=27)
|
|
113
|
+
reply.finish_reason # "stop"
|
|
114
|
+
reply.raw # the provider's full JSON response
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`messages` can be a plain string (one user message) or a list of `{"role", "content"}` dicts. `model` is required. Everything else is optional:
|
|
118
|
+
|
|
119
|
+
| Parameter | Meaning |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `system` | Instructions for the model |
|
|
122
|
+
| `max_tokens` | Maximum reply length (veylox sends 4096 to Anthropic if you leave it out, because Anthropic requires it) |
|
|
123
|
+
| `temperature` | Randomness: 0 is focused, higher is more creative |
|
|
124
|
+
| `top_p` | Nucleus sampling, 0 to 1 |
|
|
125
|
+
| `stop` | A string or list of strings that ends the reply |
|
|
126
|
+
| `**extra` | Any provider-specific option, passed through unchanged |
|
|
127
|
+
|
|
128
|
+
### Stream
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
for chunk in client.stream("Write a short poem about the sea.", model="gemini-2.5-flash"):
|
|
132
|
+
print(chunk, end="", flush=True)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### List models
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
client.list_models() # ['gpt-4o', 'gpt-4o-mini', ...]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Check a key works
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
client = veylox.connect(key, verify=True) # raises AuthenticationError if the key is rejected
|
|
145
|
+
# or later:
|
|
146
|
+
client.verify() # True
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Async
|
|
150
|
+
|
|
151
|
+
Every method has an `_async` version:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
reply = await client.chat_async("Hi!", model="llama-3.3-70b-versatile")
|
|
155
|
+
|
|
156
|
+
async for chunk in client.stream_async("Hi!", model="llama-3.3-70b-versatile"):
|
|
157
|
+
print(chunk, end="")
|
|
158
|
+
|
|
159
|
+
models = await client.list_models_async()
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Errors
|
|
163
|
+
|
|
164
|
+
Everything veylox raises inherits from `veylox.VeyloxError`:
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
try:
|
|
168
|
+
client.chat("Hi", model="gpt-4o-mnii")
|
|
169
|
+
except veylox.ModelNotFoundError as e:
|
|
170
|
+
print(e.suggestions) # ['gpt-4o-mini', ...]
|
|
171
|
+
except veylox.AuthenticationError:
|
|
172
|
+
print("Bad or revoked key")
|
|
173
|
+
except veylox.PermissionDeniedError:
|
|
174
|
+
print("Key is fine, but this model or region isn't allowed")
|
|
175
|
+
except veylox.RateLimitError:
|
|
176
|
+
print("Slow down, or top up your quota")
|
|
177
|
+
except veylox.VeyloxError as e:
|
|
178
|
+
print(e)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
| Error | When |
|
|
182
|
+
|---|---|
|
|
183
|
+
| `UnknownKeyError` | The key's provider can't be detected |
|
|
184
|
+
| `InvalidRequestError` | A parameter is missing or invalid |
|
|
185
|
+
| `AuthenticationError` | The provider rejected the key |
|
|
186
|
+
| `PermissionDeniedError` | The key is valid but access was refused (model, plan or region) |
|
|
187
|
+
| `ModelNotFoundError` | The model doesn't exist (`.suggestions` has close matches) |
|
|
188
|
+
| `RateLimitError` | Too many requests, or out of quota |
|
|
189
|
+
| `ProviderError` | The provider failed, timed out, couldn't be reached, or the URL was wrong (404) |
|
|
190
|
+
|
|
191
|
+
## Documentation
|
|
192
|
+
|
|
193
|
+
The guides live in the [`docs/`](https://github.com/GirmadaShaw/veylox/tree/main/docs) folder and read fine on GitHub:
|
|
194
|
+
|
|
195
|
+
- [Getting started](https://github.com/GirmadaShaw/veylox/blob/main/docs/getting-started.md)
|
|
196
|
+
- [Keys and providers](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/providers.md)
|
|
197
|
+
- [Chatting](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/chat.md)
|
|
198
|
+
- [Streaming](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/streaming.md)
|
|
199
|
+
- [Models](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/models.md)
|
|
200
|
+
- [Async](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/async.md)
|
|
201
|
+
- [Handling errors](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/errors.md)
|
|
202
|
+
|
|
203
|
+
Every public function and class also has a full docstring, so `help(veylox.connect)` or your editor's hover shows the details.
|
|
204
|
+
|
|
205
|
+
To browse the full docs site, including the generated API reference, on your own machine:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
pip install -e ".[docs]"
|
|
209
|
+
mkdocs serve # then open http://127.0.0.1:8000
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
MIT
|
veylox-0.1.0/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# veylox
|
|
2
|
+
|
|
3
|
+
**One key. Every model.**
|
|
4
|
+
|
|
5
|
+
Paste in an API key from any major LLM provider. veylox works out which provider it belongs to and gives you a client for every model behind it, using the same simple methods no matter the provider.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import veylox
|
|
9
|
+
|
|
10
|
+
client = veylox.connect("sk-ant-...") # any supported key
|
|
11
|
+
print(client.provider) # "anthropic"
|
|
12
|
+
|
|
13
|
+
reply = client.chat("Explain recursion in one sentence.", model="claude-sonnet-4-5")
|
|
14
|
+
print(reply)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- **No provider setup.** The key decides the provider. No `"openai/..."` model prefixes, no per-provider SDKs.
|
|
18
|
+
- **Same methods everywhere.** `chat`, `stream`, `list_models`, `verify`, with async versions of each.
|
|
19
|
+
- **Clear errors.** Missing parameters are caught before any request is sent, and a mistyped model name comes back with "did you mean" suggestions.
|
|
20
|
+
- **Lightweight.** One dependency (`httpx`). Fully typed.
|
|
21
|
+
- **Safe by default.** Your full key never appears in printed objects, logs or error messages.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install veylox
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Python 3.10 or newer.
|
|
30
|
+
|
|
31
|
+
## Supported providers
|
|
32
|
+
|
|
33
|
+
| Provider | Key looks like | `client.provider` |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| OpenAI | `sk-...`, `sk-proj-...` | `"openai"` |
|
|
36
|
+
| Anthropic | `sk-ant-...` | `"anthropic"` |
|
|
37
|
+
| Google Gemini | `AIza...` | `"gemini"` |
|
|
38
|
+
| Groq | `gsk_...` | `"groq"` |
|
|
39
|
+
| Mistral | 32 letters and digits | `"mistral"` |
|
|
40
|
+
| OpenRouter | `sk-or-...` | `"openrouter"` |
|
|
41
|
+
|
|
42
|
+
If your key has another format, tell veylox which provider it belongs to: `veylox.connect(key, provider="gemini")`.
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
### Which provider is my key for?
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
client = veylox.connect(key)
|
|
50
|
+
client.provider # "groq"
|
|
51
|
+
client.provider_info # ProviderInfo(id='groq', name='Groq', base_url='https://api.groq.com/openai/v1',
|
|
52
|
+
# key_hint='gsk_...x9Q2', detected_by='prefix')
|
|
53
|
+
|
|
54
|
+
veylox.detect_provider("AIza...") # "gemini", without making a client or a network call
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Chat
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
reply = client.chat(
|
|
61
|
+
[
|
|
62
|
+
{"role": "system", "content": "You are a concise assistant."},
|
|
63
|
+
{"role": "user", "content": "What is the capital of Japan?"},
|
|
64
|
+
],
|
|
65
|
+
model="gpt-4o-mini",
|
|
66
|
+
temperature=0.2,
|
|
67
|
+
max_tokens=100,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
reply.text # "Tokyo."
|
|
71
|
+
reply.usage # Usage(input_tokens=24, output_tokens=3, total_tokens=27)
|
|
72
|
+
reply.finish_reason # "stop"
|
|
73
|
+
reply.raw # the provider's full JSON response
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`messages` can be a plain string (one user message) or a list of `{"role", "content"}` dicts. `model` is required. Everything else is optional:
|
|
77
|
+
|
|
78
|
+
| Parameter | Meaning |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `system` | Instructions for the model |
|
|
81
|
+
| `max_tokens` | Maximum reply length (veylox sends 4096 to Anthropic if you leave it out, because Anthropic requires it) |
|
|
82
|
+
| `temperature` | Randomness: 0 is focused, higher is more creative |
|
|
83
|
+
| `top_p` | Nucleus sampling, 0 to 1 |
|
|
84
|
+
| `stop` | A string or list of strings that ends the reply |
|
|
85
|
+
| `**extra` | Any provider-specific option, passed through unchanged |
|
|
86
|
+
|
|
87
|
+
### Stream
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
for chunk in client.stream("Write a short poem about the sea.", model="gemini-2.5-flash"):
|
|
91
|
+
print(chunk, end="", flush=True)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### List models
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
client.list_models() # ['gpt-4o', 'gpt-4o-mini', ...]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Check a key works
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
client = veylox.connect(key, verify=True) # raises AuthenticationError if the key is rejected
|
|
104
|
+
# or later:
|
|
105
|
+
client.verify() # True
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Async
|
|
109
|
+
|
|
110
|
+
Every method has an `_async` version:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
reply = await client.chat_async("Hi!", model="llama-3.3-70b-versatile")
|
|
114
|
+
|
|
115
|
+
async for chunk in client.stream_async("Hi!", model="llama-3.3-70b-versatile"):
|
|
116
|
+
print(chunk, end="")
|
|
117
|
+
|
|
118
|
+
models = await client.list_models_async()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Errors
|
|
122
|
+
|
|
123
|
+
Everything veylox raises inherits from `veylox.VeyloxError`:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
try:
|
|
127
|
+
client.chat("Hi", model="gpt-4o-mnii")
|
|
128
|
+
except veylox.ModelNotFoundError as e:
|
|
129
|
+
print(e.suggestions) # ['gpt-4o-mini', ...]
|
|
130
|
+
except veylox.AuthenticationError:
|
|
131
|
+
print("Bad or revoked key")
|
|
132
|
+
except veylox.PermissionDeniedError:
|
|
133
|
+
print("Key is fine, but this model or region isn't allowed")
|
|
134
|
+
except veylox.RateLimitError:
|
|
135
|
+
print("Slow down, or top up your quota")
|
|
136
|
+
except veylox.VeyloxError as e:
|
|
137
|
+
print(e)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
| Error | When |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `UnknownKeyError` | The key's provider can't be detected |
|
|
143
|
+
| `InvalidRequestError` | A parameter is missing or invalid |
|
|
144
|
+
| `AuthenticationError` | The provider rejected the key |
|
|
145
|
+
| `PermissionDeniedError` | The key is valid but access was refused (model, plan or region) |
|
|
146
|
+
| `ModelNotFoundError` | The model doesn't exist (`.suggestions` has close matches) |
|
|
147
|
+
| `RateLimitError` | Too many requests, or out of quota |
|
|
148
|
+
| `ProviderError` | The provider failed, timed out, couldn't be reached, or the URL was wrong (404) |
|
|
149
|
+
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
The guides live in the [`docs/`](https://github.com/GirmadaShaw/veylox/tree/main/docs) folder and read fine on GitHub:
|
|
153
|
+
|
|
154
|
+
- [Getting started](https://github.com/GirmadaShaw/veylox/blob/main/docs/getting-started.md)
|
|
155
|
+
- [Keys and providers](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/providers.md)
|
|
156
|
+
- [Chatting](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/chat.md)
|
|
157
|
+
- [Streaming](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/streaming.md)
|
|
158
|
+
- [Models](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/models.md)
|
|
159
|
+
- [Async](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/async.md)
|
|
160
|
+
- [Handling errors](https://github.com/GirmadaShaw/veylox/blob/main/docs/guide/errors.md)
|
|
161
|
+
|
|
162
|
+
Every public function and class also has a full docstring, so `help(veylox.connect)` or your editor's hover shows the details.
|
|
163
|
+
|
|
164
|
+
To browse the full docs site, including the generated API reference, on your own machine:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
pip install -e ".[docs]"
|
|
168
|
+
mkdocs serve # then open http://127.0.0.1:8000
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "veylox"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "One key. Every model. Paste any LLM API key and get a client for every model behind it."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
authors = [{ name = "Paramveer Singh" }]
|
|
14
|
+
keywords = ["llm", "openai", "anthropic", "claude", "gemini", "groq", "mistral", "openrouter", "api", "ai"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
"Programming Language :: Python :: 3.15",
|
|
27
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
29
|
+
"Typing :: Typed",
|
|
30
|
+
]
|
|
31
|
+
dependencies = ["httpx>=0.24"]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/GirmadaShaw/veylox"
|
|
35
|
+
Documentation = "https://github.com/GirmadaShaw/veylox/tree/main/docs"
|
|
36
|
+
Source = "https://github.com/GirmadaShaw/veylox"
|
|
37
|
+
Changelog = "https://github.com/GirmadaShaw/veylox/blob/main/CHANGELOG.md"
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = [
|
|
41
|
+
"pytest>=7",
|
|
42
|
+
"pytest-asyncio>=0.23",
|
|
43
|
+
"respx>=0.21",
|
|
44
|
+
"ruff>=0.6",
|
|
45
|
+
"mypy>=1.10",
|
|
46
|
+
"build>=1.2",
|
|
47
|
+
"twine>=5",
|
|
48
|
+
]
|
|
49
|
+
docs = [
|
|
50
|
+
"mkdocs-material>=9.5",
|
|
51
|
+
"mkdocstrings[python]>=0.25",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[tool.hatch.version]
|
|
55
|
+
path = "src/veylox/_version.py"
|
|
56
|
+
|
|
57
|
+
[tool.hatch.build.targets.wheel]
|
|
58
|
+
packages = ["src/veylox"]
|
|
59
|
+
|
|
60
|
+
[tool.hatch.build.targets.sdist]
|
|
61
|
+
include = ["src/veylox", "tests", "README.md", "LICENSE", "CHANGELOG.md"]
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
asyncio_mode = "auto"
|
|
66
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
67
|
+
|
|
68
|
+
[tool.ruff]
|
|
69
|
+
line-length = 110
|
|
70
|
+
target-version = "py310"
|
|
71
|
+
|
|
72
|
+
[tool.ruff.lint]
|
|
73
|
+
select = ["E", "F", "W", "I", "UP", "B", "SIM"]
|
|
74
|
+
ignore = ["UP007", "UP006", "UP035", "UP045"]
|
|
75
|
+
|
|
76
|
+
[tool.mypy]
|
|
77
|
+
python_version = "3.10"
|
|
78
|
+
strict = true
|
|
79
|
+
files = ["src/veylox"]
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""veylox: one key, every model.
|
|
2
|
+
|
|
3
|
+
Pass in any supported LLM API key. veylox works out which provider it belongs to
|
|
4
|
+
and gives you a client for every model behind it::
|
|
5
|
+
|
|
6
|
+
import veylox
|
|
7
|
+
|
|
8
|
+
client = veylox.connect("sk-ant-...")
|
|
9
|
+
client.provider # "anthropic"
|
|
10
|
+
print(client.chat("Hello!", model="claude-sonnet-4-5"))
|
|
11
|
+
|
|
12
|
+
Supported providers: OpenAI, Anthropic, Google Gemini, Groq, Mistral, OpenRouter.
|
|
13
|
+
"""
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Optional, Union
|
|
17
|
+
|
|
18
|
+
import httpx
|
|
19
|
+
|
|
20
|
+
from ._version import __version__
|
|
21
|
+
from .client import DEFAULT_TIMEOUT, Client
|
|
22
|
+
from .detect import detect_provider
|
|
23
|
+
from .errors import (
|
|
24
|
+
AuthenticationError,
|
|
25
|
+
InvalidRequestError,
|
|
26
|
+
ModelNotFoundError,
|
|
27
|
+
PermissionDeniedError,
|
|
28
|
+
ProviderError,
|
|
29
|
+
RateLimitError,
|
|
30
|
+
UnknownKeyError,
|
|
31
|
+
VeyloxError,
|
|
32
|
+
)
|
|
33
|
+
from .registry import supported_providers
|
|
34
|
+
from .types import ChatResponse, Messages, ProviderInfo, StreamChunk, Usage
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"__version__",
|
|
38
|
+
"connect",
|
|
39
|
+
"Client",
|
|
40
|
+
"detect_provider",
|
|
41
|
+
"supported_providers",
|
|
42
|
+
# data types
|
|
43
|
+
"ChatResponse",
|
|
44
|
+
"StreamChunk",
|
|
45
|
+
"Usage",
|
|
46
|
+
"ProviderInfo",
|
|
47
|
+
"Messages",
|
|
48
|
+
# errors
|
|
49
|
+
"VeyloxError",
|
|
50
|
+
"UnknownKeyError",
|
|
51
|
+
"InvalidRequestError",
|
|
52
|
+
"AuthenticationError",
|
|
53
|
+
"PermissionDeniedError",
|
|
54
|
+
"ModelNotFoundError",
|
|
55
|
+
"RateLimitError",
|
|
56
|
+
"ProviderError",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def connect(
|
|
61
|
+
api_key: str,
|
|
62
|
+
*,
|
|
63
|
+
provider: Optional[str] = None,
|
|
64
|
+
verify: bool = False,
|
|
65
|
+
base_url: Optional[str] = None,
|
|
66
|
+
timeout: Union[float, httpx.Timeout, None] = DEFAULT_TIMEOUT,
|
|
67
|
+
) -> Client:
|
|
68
|
+
"""Connect with any supported API key and get a client for its provider's models.
|
|
69
|
+
|
|
70
|
+
Examples:
|
|
71
|
+
>>> client = veylox.connect("gsk_...")
|
|
72
|
+
>>> client.provider
|
|
73
|
+
'groq'
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
api_key: An API key from OpenAI, Anthropic, Google Gemini, Groq, Mistral
|
|
77
|
+
or OpenRouter.
|
|
78
|
+
provider: Skip auto-detection and use this provider. Use it for keys whose
|
|
79
|
+
format veylox doesn't recognise.
|
|
80
|
+
verify: If ``True``, make one free call (listing models) to confirm the key
|
|
81
|
+
works before returning. Off by default, so connecting never touches the network.
|
|
82
|
+
base_url: Send requests to a different address, such as a proxy or gateway
|
|
83
|
+
that speaks the provider's API.
|
|
84
|
+
timeout: Seconds to wait for a provider before giving up (default 60).
|
|
85
|
+
``None`` means no limit; an ``httpx.Timeout`` sets separate connect/read limits.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
A :class:`Client`. Check ``client.provider`` to see which provider the key belongs to.
|
|
89
|
+
|
|
90
|
+
Raises:
|
|
91
|
+
UnknownKeyError: The key's provider couldn't be detected (pass ``provider=``).
|
|
92
|
+
AuthenticationError: ``verify=True`` and the provider rejected the key.
|
|
93
|
+
"""
|
|
94
|
+
client = Client(api_key, provider=provider, base_url=base_url, timeout=timeout)
|
|
95
|
+
if verify:
|
|
96
|
+
try:
|
|
97
|
+
client.verify()
|
|
98
|
+
except BaseException:
|
|
99
|
+
# The caller never receives this client, so close its connection here.
|
|
100
|
+
client.close()
|
|
101
|
+
raise
|
|
102
|
+
return client
|