argosvix 0.4.0a1__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.
- argosvix-0.4.0a1/.gitignore +10 -0
- argosvix-0.4.0a1/CHANGELOG.md +46 -0
- argosvix-0.4.0a1/LICENSE +21 -0
- argosvix-0.4.0a1/PKG-INFO +224 -0
- argosvix-0.4.0a1/README.md +154 -0
- argosvix-0.4.0a1/argosvix/__init__.py +46 -0
- argosvix-0.4.0a1/argosvix/client.py +745 -0
- argosvix-0.4.0a1/argosvix/pricing.py +148 -0
- argosvix-0.4.0a1/argosvix/recorder.py +158 -0
- argosvix-0.4.0a1/argosvix/types.py +159 -0
- argosvix-0.4.0a1/pyproject.toml +65 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `argosvix` (Python SDK) are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres to [PEP 440](https://peps.python.org/pep-0440/) versioning.
|
|
6
|
+
|
|
7
|
+
## [0.4.0a1] - 2026-05-29
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **Async wrap for Gemini and Mistral**: complete the async matrix for all four providers.
|
|
11
|
+
- Gemini = `client.aio.models.generate_content` (google-genai) is now detected and wrapped alongside the sync API. A single `wrap()` call covers both code paths.
|
|
12
|
+
- Mistral = `client.chat.complete_async` (mistralai 1.x) is wrapped in addition to `chat.complete`. The same Mistral client object exposes both, so both get patched.
|
|
13
|
+
- Provider-table in README updated to reflect full async support; Phase 5 backlog now lists streaming + Responses API only.
|
|
14
|
+
|
|
15
|
+
## [0.3.0a1] - 2026-05-29
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- **Async wrap for OpenAI and Anthropic**: `inspect.iscoroutinefunction` detection auto-dispatches to async or sync wrapper. AsyncOpenAI / AsyncAnthropic clients are wrapped seamlessly.
|
|
19
|
+
- Stream-mode safety check on async path: `stream=True` calls warn once per provider and skip recording (instead of silently posting 0-token records).
|
|
20
|
+
- `__version__` and `User-Agent` header bumped accordingly.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Dashboard MCP onboarding hint clarifies that some MCP clients prefix tool names with `argosvix::` instead of hardcoding `argosvix__` (cross-client convention difference).
|
|
24
|
+
|
|
25
|
+
## [0.2.0a1] - 2026-05-29
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- **Phase 2 providers**: Anthropic, Google Gemini, and Mistral sync wrap.
|
|
29
|
+
- Anthropic = `client.messages.create`
|
|
30
|
+
- Gemini = `client.models.generate_content` (google-genai), with fallback to legacy `GenerativeModel.generate_content`
|
|
31
|
+
- Mistral = `client.chat.complete`
|
|
32
|
+
- Shape-based provider detection fallback for adapter or proxy clients whose constructor name doesn't include the provider keyword.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- `wrap()` is now genuinely idempotent: each `_wrap_<provider>` returns a boolean indicating whether monkeypatching succeeded, and the wrap marker is only set on success. Previous behavior could mark a client as wrapped even after a no-op fall-through, blocking a re-wrap attempt.
|
|
36
|
+
- All providers warn once and skip recording when called with `stream=True` (previously silent 0-token records).
|
|
37
|
+
|
|
38
|
+
## [0.1.0a1] - 2026-05-29
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
- Initial Phase 1 alpha release.
|
|
42
|
+
- OpenAI sync `client.chat.completions.create` wrap.
|
|
43
|
+
- Buffered ingest to `https://ingest.argosvix.com/v1/ingest` with periodic flush, retry on 5xx, and `atexit` flush for short-lived processes.
|
|
44
|
+
- Pricing table mirroring `@argosvix/sdk` (JS) across all four providers.
|
|
45
|
+
- `LlmCallRecord` dataclass with camelCase wire-format serialization that matches the backend ingest contract.
|
|
46
|
+
- 27 pytest cases covering pricing, type serialization, and wrap behavior.
|
argosvix-0.4.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yuto Makihara (Argosvix)
|
|
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.
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: argosvix
|
|
3
|
+
Version: 0.4.0a1
|
|
4
|
+
Summary: Argosvix Python SDK = AI agent observability (cost / latency / tokens / errors) for OpenAI / Anthropic / Gemini / Mistral
|
|
5
|
+
Project-URL: Homepage, https://argosvix.com
|
|
6
|
+
Project-URL: Documentation, https://github.com/argosvix/Argosvix/tree/main/packages/sdk-python
|
|
7
|
+
Project-URL: Repository, https://github.com/argosvix/Argosvix
|
|
8
|
+
Project-URL: Issues, https://github.com/argosvix/Argosvix/issues
|
|
9
|
+
Author-email: Yuto Makihara <hello@argosvix.com>
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Yuto Makihara (Argosvix)
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: ai-agent,anthropic,gemini,llm,mistral,observability,openai
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
|
+
Classifier: Topic :: System :: Monitoring
|
|
44
|
+
Requires-Python: >=3.10
|
|
45
|
+
Provides-Extra: all
|
|
46
|
+
Requires-Dist: anthropic>=0.30; extra == 'all'
|
|
47
|
+
Requires-Dist: google-genai>=0.3; extra == 'all'
|
|
48
|
+
Requires-Dist: mistralai>=1.0; extra == 'all'
|
|
49
|
+
Requires-Dist: openai>=1.0; extra == 'all'
|
|
50
|
+
Provides-Extra: anthropic
|
|
51
|
+
Requires-Dist: anthropic>=0.30; extra == 'anthropic'
|
|
52
|
+
Provides-Extra: dev
|
|
53
|
+
Requires-Dist: anthropic>=0.30; extra == 'dev'
|
|
54
|
+
Requires-Dist: google-genai>=0.3; extra == 'dev'
|
|
55
|
+
Requires-Dist: mistralai>=1.0; extra == 'dev'
|
|
56
|
+
Requires-Dist: openai>=1.0; extra == 'dev'
|
|
57
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
58
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
59
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
60
|
+
Provides-Extra: gemini
|
|
61
|
+
Requires-Dist: google-genai>=0.3; extra == 'gemini'
|
|
62
|
+
Provides-Extra: mistral
|
|
63
|
+
Requires-Dist: mistralai>=1.0; extra == 'mistral'
|
|
64
|
+
Provides-Extra: openai
|
|
65
|
+
Requires-Dist: openai>=1.0; extra == 'openai'
|
|
66
|
+
Provides-Extra: test
|
|
67
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'test'
|
|
68
|
+
Requires-Dist: pytest>=8.0; extra == 'test'
|
|
69
|
+
Description-Content-Type: text/markdown
|
|
70
|
+
|
|
71
|
+
# Argosvix Python SDK
|
|
72
|
+
|
|
73
|
+
AI agent observability (cost / latency / tokens / errors) for OpenAI / Anthropic / Gemini / Mistral. **Phase 4 alpha — sync + async wrap for all 4 providers.** Streaming + Responses API are Phase 5 backlog.
|
|
74
|
+
|
|
75
|
+
[](https://pypi.org/project/argosvix/)
|
|
76
|
+
[](https://opensource.org/licenses/MIT)
|
|
77
|
+
|
|
78
|
+
## Install
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install argosvix
|
|
82
|
+
# OR include a specific provider SDK as extra
|
|
83
|
+
pip install "argosvix[openai]"
|
|
84
|
+
pip install "argosvix[anthropic]"
|
|
85
|
+
pip install "argosvix[gemini]"
|
|
86
|
+
pip install "argosvix[mistral]"
|
|
87
|
+
# all 4 at once
|
|
88
|
+
pip install "argosvix[all]"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Quickstart
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from openai import OpenAI
|
|
95
|
+
from argosvix import wrap, ArgosvixConfig
|
|
96
|
+
|
|
97
|
+
client = wrap(
|
|
98
|
+
OpenAI(),
|
|
99
|
+
ArgosvixConfig(
|
|
100
|
+
api_key="argosvix_live_...", # get from https://dashboard.argosvix.com/api-keys
|
|
101
|
+
tags={"service": "my-app", "env": "prod"},
|
|
102
|
+
),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
resp = client.chat.completions.create(
|
|
106
|
+
model="gpt-5.5",
|
|
107
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
108
|
+
)
|
|
109
|
+
# The call is automatically recorded (cost / tokens / latency / model) and
|
|
110
|
+
# batched to https://ingest.argosvix.com/v1/ingest within 5 seconds.
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Visit https://dashboard.argosvix.com after a few seconds to see the call appear.
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
`ArgosvixConfig` accepts:
|
|
118
|
+
|
|
119
|
+
| Field | Default | Description |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `api_key` | `None` | Argosvix API key. **Required** for record submission. |
|
|
122
|
+
| `endpoint` | `https://ingest.argosvix.com/v1/ingest` | Ingest endpoint. |
|
|
123
|
+
| `tags` | `{}` | Tags attached to every record (e.g. `{"service": "bot"}`). |
|
|
124
|
+
| `disabled` | `False` | Disable record submission entirely (e.g. local dev). |
|
|
125
|
+
| `flush_interval_ms` | `5000` | Buffer flush interval. |
|
|
126
|
+
| `buffer_max_size` | `100` | Max records before auto-flush. |
|
|
127
|
+
| `flush_retry_attempts` | `2` | Total retry attempts including the initial try. |
|
|
128
|
+
| `provider` | `None` | Explicit provider override (`"openai"` / etc). Auto-detected from client class name. |
|
|
129
|
+
| `trace_id` | `None` | OTel-subset trace ID. Attached to all records from this client. |
|
|
130
|
+
| `span_id` | `None` | OTel-subset span ID. |
|
|
131
|
+
| `parent_span_id` | `None` | OTel-subset parent span ID. |
|
|
132
|
+
|
|
133
|
+
## Short-lived processes (Lambda / Cron / CLI)
|
|
134
|
+
|
|
135
|
+
The SDK auto-registers `atexit` to flush remaining records when the process exits. But for Lambda / Edge Functions / Workers-style short-lived runtimes where `atexit` may not fire, explicitly flush:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from argosvix import get_recorder
|
|
139
|
+
|
|
140
|
+
rec = get_recorder(client)
|
|
141
|
+
if rec is not None:
|
|
142
|
+
rec.flush_blocking() # blocks until all buffered records are POSTed
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Supported providers (Phase 4)
|
|
146
|
+
|
|
147
|
+
| Provider | Sync | Async | Streaming | Notes |
|
|
148
|
+
|---|---|---|---|---|
|
|
149
|
+
| **OpenAI** | ✅ | ✅ | 🔄 P5 | `client.chat.completions.create` (sync + AsyncOpenAI) |
|
|
150
|
+
| **Anthropic** | ✅ | ✅ | 🔄 P5 | `client.messages.create` (sync + AsyncAnthropic) |
|
|
151
|
+
| **Google Gemini** | ✅ | ✅ | 🔄 P5 | `client.models.generate_content` + `client.aio.models.generate_content` (google-genai) |
|
|
152
|
+
| **Mistral** | ✅ | ✅ | 🔄 P5 | `client.chat.complete` + `client.chat.complete_async` (mistralai 1.x) |
|
|
153
|
+
|
|
154
|
+
OpenAI Responses API support is also Phase 3 backlog. Need a provider sooner? File an issue at https://github.com/argosvix/Argosvix/issues.
|
|
155
|
+
|
|
156
|
+
### Multi-provider example
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from openai import OpenAI
|
|
160
|
+
from anthropic import Anthropic
|
|
161
|
+
from google import genai
|
|
162
|
+
from mistralai import Mistral
|
|
163
|
+
from argosvix import wrap, ArgosvixConfig
|
|
164
|
+
|
|
165
|
+
cfg = ArgosvixConfig(api_key="argosvix_live_...", tags={"app": "comparison-bot"})
|
|
166
|
+
oa = wrap(OpenAI(), cfg)
|
|
167
|
+
an = wrap(Anthropic(), cfg)
|
|
168
|
+
gm = wrap(genai.Client(), cfg)
|
|
169
|
+
ms = wrap(Mistral(api_key="..."), cfg)
|
|
170
|
+
|
|
171
|
+
# All calls are recorded to the same Argosvix account, distinguishable by provider.
|
|
172
|
+
oa.chat.completions.create(model="gpt-5.5", messages=[{"role": "user", "content": "Hi"}])
|
|
173
|
+
an.messages.create(model="claude-opus-4", messages=[{"role": "user", "content": "Hi"}], max_tokens=512)
|
|
174
|
+
gm.models.generate_content(model="gemini-2.5-flash", contents="Hi")
|
|
175
|
+
ms.chat.complete(model="mistral-large-latest", messages=[{"role": "user", "content": "Hi"}])
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Trace correlation
|
|
179
|
+
|
|
180
|
+
Group related LLM calls into a single trace by passing `trace_id` to `wrap()`:
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
import uuid
|
|
184
|
+
|
|
185
|
+
trace_id = uuid.uuid4().hex
|
|
186
|
+
client = wrap(
|
|
187
|
+
OpenAI(),
|
|
188
|
+
ArgosvixConfig(api_key="...", trace_id=trace_id),
|
|
189
|
+
)
|
|
190
|
+
# All calls from this client share trace_id and appear together in the
|
|
191
|
+
# dashboard's traces waterfall view.
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Privacy
|
|
195
|
+
|
|
196
|
+
The SDK records **metadata only** (= tokens, cost, latency, model name, error info, your tags). **Prompts and completions are NOT recorded** by default. Opt-in plain-text storage (with PII redaction + AES-256 encryption + 7-30 day retention + 1-click delete) is planned for v1.5 — see https://argosvix.com/privacy for details.
|
|
197
|
+
|
|
198
|
+
## Pricing table
|
|
199
|
+
|
|
200
|
+
`PRICING` is a snapshot updated quarterly from each provider's official pricing page. Unknown models return `0.0` cost + a warning. To verify a model is known:
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from argosvix import calculate_cost
|
|
204
|
+
|
|
205
|
+
cost = calculate_cost("openai", "gpt-5.5", prompt_tokens=1000, completion_tokens=500)
|
|
206
|
+
print(cost) # 0.0125 USD
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Development
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# install with dev deps
|
|
213
|
+
pip install -e ".[dev]"
|
|
214
|
+
|
|
215
|
+
# run tests
|
|
216
|
+
pytest
|
|
217
|
+
|
|
218
|
+
# lint
|
|
219
|
+
ruff check argosvix tests
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT © Yuto Makihara (Argosvix). See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Argosvix Python SDK
|
|
2
|
+
|
|
3
|
+
AI agent observability (cost / latency / tokens / errors) for OpenAI / Anthropic / Gemini / Mistral. **Phase 4 alpha — sync + async wrap for all 4 providers.** Streaming + Responses API are Phase 5 backlog.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/argosvix/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install argosvix
|
|
12
|
+
# OR include a specific provider SDK as extra
|
|
13
|
+
pip install "argosvix[openai]"
|
|
14
|
+
pip install "argosvix[anthropic]"
|
|
15
|
+
pip install "argosvix[gemini]"
|
|
16
|
+
pip install "argosvix[mistral]"
|
|
17
|
+
# all 4 at once
|
|
18
|
+
pip install "argosvix[all]"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quickstart
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from openai import OpenAI
|
|
25
|
+
from argosvix import wrap, ArgosvixConfig
|
|
26
|
+
|
|
27
|
+
client = wrap(
|
|
28
|
+
OpenAI(),
|
|
29
|
+
ArgosvixConfig(
|
|
30
|
+
api_key="argosvix_live_...", # get from https://dashboard.argosvix.com/api-keys
|
|
31
|
+
tags={"service": "my-app", "env": "prod"},
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
resp = client.chat.completions.create(
|
|
36
|
+
model="gpt-5.5",
|
|
37
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
38
|
+
)
|
|
39
|
+
# The call is automatically recorded (cost / tokens / latency / model) and
|
|
40
|
+
# batched to https://ingest.argosvix.com/v1/ingest within 5 seconds.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Visit https://dashboard.argosvix.com after a few seconds to see the call appear.
|
|
44
|
+
|
|
45
|
+
## Configuration
|
|
46
|
+
|
|
47
|
+
`ArgosvixConfig` accepts:
|
|
48
|
+
|
|
49
|
+
| Field | Default | Description |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `api_key` | `None` | Argosvix API key. **Required** for record submission. |
|
|
52
|
+
| `endpoint` | `https://ingest.argosvix.com/v1/ingest` | Ingest endpoint. |
|
|
53
|
+
| `tags` | `{}` | Tags attached to every record (e.g. `{"service": "bot"}`). |
|
|
54
|
+
| `disabled` | `False` | Disable record submission entirely (e.g. local dev). |
|
|
55
|
+
| `flush_interval_ms` | `5000` | Buffer flush interval. |
|
|
56
|
+
| `buffer_max_size` | `100` | Max records before auto-flush. |
|
|
57
|
+
| `flush_retry_attempts` | `2` | Total retry attempts including the initial try. |
|
|
58
|
+
| `provider` | `None` | Explicit provider override (`"openai"` / etc). Auto-detected from client class name. |
|
|
59
|
+
| `trace_id` | `None` | OTel-subset trace ID. Attached to all records from this client. |
|
|
60
|
+
| `span_id` | `None` | OTel-subset span ID. |
|
|
61
|
+
| `parent_span_id` | `None` | OTel-subset parent span ID. |
|
|
62
|
+
|
|
63
|
+
## Short-lived processes (Lambda / Cron / CLI)
|
|
64
|
+
|
|
65
|
+
The SDK auto-registers `atexit` to flush remaining records when the process exits. But for Lambda / Edge Functions / Workers-style short-lived runtimes where `atexit` may not fire, explicitly flush:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from argosvix import get_recorder
|
|
69
|
+
|
|
70
|
+
rec = get_recorder(client)
|
|
71
|
+
if rec is not None:
|
|
72
|
+
rec.flush_blocking() # blocks until all buffered records are POSTed
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Supported providers (Phase 4)
|
|
76
|
+
|
|
77
|
+
| Provider | Sync | Async | Streaming | Notes |
|
|
78
|
+
|---|---|---|---|---|
|
|
79
|
+
| **OpenAI** | ✅ | ✅ | 🔄 P5 | `client.chat.completions.create` (sync + AsyncOpenAI) |
|
|
80
|
+
| **Anthropic** | ✅ | ✅ | 🔄 P5 | `client.messages.create` (sync + AsyncAnthropic) |
|
|
81
|
+
| **Google Gemini** | ✅ | ✅ | 🔄 P5 | `client.models.generate_content` + `client.aio.models.generate_content` (google-genai) |
|
|
82
|
+
| **Mistral** | ✅ | ✅ | 🔄 P5 | `client.chat.complete` + `client.chat.complete_async` (mistralai 1.x) |
|
|
83
|
+
|
|
84
|
+
OpenAI Responses API support is also Phase 3 backlog. Need a provider sooner? File an issue at https://github.com/argosvix/Argosvix/issues.
|
|
85
|
+
|
|
86
|
+
### Multi-provider example
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from openai import OpenAI
|
|
90
|
+
from anthropic import Anthropic
|
|
91
|
+
from google import genai
|
|
92
|
+
from mistralai import Mistral
|
|
93
|
+
from argosvix import wrap, ArgosvixConfig
|
|
94
|
+
|
|
95
|
+
cfg = ArgosvixConfig(api_key="argosvix_live_...", tags={"app": "comparison-bot"})
|
|
96
|
+
oa = wrap(OpenAI(), cfg)
|
|
97
|
+
an = wrap(Anthropic(), cfg)
|
|
98
|
+
gm = wrap(genai.Client(), cfg)
|
|
99
|
+
ms = wrap(Mistral(api_key="..."), cfg)
|
|
100
|
+
|
|
101
|
+
# All calls are recorded to the same Argosvix account, distinguishable by provider.
|
|
102
|
+
oa.chat.completions.create(model="gpt-5.5", messages=[{"role": "user", "content": "Hi"}])
|
|
103
|
+
an.messages.create(model="claude-opus-4", messages=[{"role": "user", "content": "Hi"}], max_tokens=512)
|
|
104
|
+
gm.models.generate_content(model="gemini-2.5-flash", contents="Hi")
|
|
105
|
+
ms.chat.complete(model="mistral-large-latest", messages=[{"role": "user", "content": "Hi"}])
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Trace correlation
|
|
109
|
+
|
|
110
|
+
Group related LLM calls into a single trace by passing `trace_id` to `wrap()`:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
import uuid
|
|
114
|
+
|
|
115
|
+
trace_id = uuid.uuid4().hex
|
|
116
|
+
client = wrap(
|
|
117
|
+
OpenAI(),
|
|
118
|
+
ArgosvixConfig(api_key="...", trace_id=trace_id),
|
|
119
|
+
)
|
|
120
|
+
# All calls from this client share trace_id and appear together in the
|
|
121
|
+
# dashboard's traces waterfall view.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Privacy
|
|
125
|
+
|
|
126
|
+
The SDK records **metadata only** (= tokens, cost, latency, model name, error info, your tags). **Prompts and completions are NOT recorded** by default. Opt-in plain-text storage (with PII redaction + AES-256 encryption + 7-30 day retention + 1-click delete) is planned for v1.5 — see https://argosvix.com/privacy for details.
|
|
127
|
+
|
|
128
|
+
## Pricing table
|
|
129
|
+
|
|
130
|
+
`PRICING` is a snapshot updated quarterly from each provider's official pricing page. Unknown models return `0.0` cost + a warning. To verify a model is known:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from argosvix import calculate_cost
|
|
134
|
+
|
|
135
|
+
cost = calculate_cost("openai", "gpt-5.5", prompt_tokens=1000, completion_tokens=500)
|
|
136
|
+
print(cost) # 0.0125 USD
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Development
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# install with dev deps
|
|
143
|
+
pip install -e ".[dev]"
|
|
144
|
+
|
|
145
|
+
# run tests
|
|
146
|
+
pytest
|
|
147
|
+
|
|
148
|
+
# lint
|
|
149
|
+
ruff check argosvix tests
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT © Yuto Makihara (Argosvix). See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Argosvix Python SDK = AI agent observability for OpenAI / Anthropic / Gemini / Mistral.
|
|
2
|
+
|
|
3
|
+
Phase 4 (= 2026-05): sync + async wrap for all 4 providers (OpenAI / Anthropic / Gemini / Mistral)。
|
|
4
|
+
streaming + Responses API は Phase 5 backlog。
|
|
5
|
+
|
|
6
|
+
Quickstart:
|
|
7
|
+
from openai import OpenAI
|
|
8
|
+
from argosvix import wrap, ArgosvixConfig
|
|
9
|
+
|
|
10
|
+
client = wrap(
|
|
11
|
+
OpenAI(),
|
|
12
|
+
ArgosvixConfig(
|
|
13
|
+
api_key="argosvix_live_...",
|
|
14
|
+
tags={"service": "my-app", "env": "prod"},
|
|
15
|
+
),
|
|
16
|
+
)
|
|
17
|
+
resp = client.chat.completions.create(
|
|
18
|
+
model="gpt-5.5",
|
|
19
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
20
|
+
)
|
|
21
|
+
# The call is automatically recorded (cost / tokens / latency / model) and
|
|
22
|
+
# batched to https://ingest.argosvix.com/v1/ingest within 5 seconds.
|
|
23
|
+
|
|
24
|
+
Visit https://argosvix.com for dashboards + alerts.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from argosvix.client import get_recorder, wrap
|
|
28
|
+
from argosvix.pricing import PRICING, calculate_cost
|
|
29
|
+
from argosvix.recorder import Recorder
|
|
30
|
+
from argosvix.types import ArgosvixConfig, ErrorDetails, LlmCallRecord, Provider, RequestMeta
|
|
31
|
+
|
|
32
|
+
__version__ = "0.4.0a1"
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"ArgosvixConfig",
|
|
36
|
+
"ErrorDetails",
|
|
37
|
+
"LlmCallRecord",
|
|
38
|
+
"PRICING",
|
|
39
|
+
"Provider",
|
|
40
|
+
"Recorder",
|
|
41
|
+
"RequestMeta",
|
|
42
|
+
"__version__",
|
|
43
|
+
"calculate_cost",
|
|
44
|
+
"get_recorder",
|
|
45
|
+
"wrap",
|
|
46
|
+
]
|