agentbill-py-sdk 1.0.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.
- agentbill_py_sdk-1.0.0/LICENSE +21 -0
- agentbill_py_sdk-1.0.0/PKG-INFO +270 -0
- agentbill_py_sdk-1.0.0/README.md +233 -0
- agentbill_py_sdk-1.0.0/agentbill/__init__.py +11 -0
- agentbill_py_sdk-1.0.0/agentbill/client.py +436 -0
- agentbill_py_sdk-1.0.0/agentbill/tracer.py +153 -0
- agentbill_py_sdk-1.0.0/agentbill/types.py +17 -0
- agentbill_py_sdk-1.0.0/agentbill_py_sdk.egg-info/PKG-INFO +270 -0
- agentbill_py_sdk-1.0.0/agentbill_py_sdk.egg-info/SOURCES.txt +15 -0
- agentbill_py_sdk-1.0.0/agentbill_py_sdk.egg-info/dependency_links.txt +1 -0
- agentbill_py_sdk-1.0.0/agentbill_py_sdk.egg-info/requires.txt +8 -0
- agentbill_py_sdk-1.0.0/agentbill_py_sdk.egg-info/top_level.txt +1 -0
- agentbill_py_sdk-1.0.0/pyproject.toml +94 -0
- agentbill_py_sdk-1.0.0/setup.cfg +4 -0
- agentbill_py_sdk-1.0.0/setup.py +36 -0
- agentbill_py_sdk-1.0.0/tests/test_agentbill.py +115 -0
- agentbill_py_sdk-1.0.0/tests/test_tracer.py +70 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AgentBill
|
|
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,270 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentbill-py-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: OpenTelemetry-based SDK for tracking and billing AI agent usage
|
|
5
|
+
Home-page: https://github.com/Agent-Bill/python
|
|
6
|
+
Author: AgentBill
|
|
7
|
+
Author-email: AgentBill Team <support@agentbill.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/Agent-Bill/python
|
|
10
|
+
Project-URL: Documentation, https://github.com/Agent-Bill/python#readme
|
|
11
|
+
Project-URL: Repository, https://github.com/Agent-Bill/python.git
|
|
12
|
+
Project-URL: Issues, https://github.com/Agent-Bill/python/issues
|
|
13
|
+
Keywords: ai,billing,tracking,opentelemetry,llm,agents
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: httpx>=0.24.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pylint>=2.17.0; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
33
|
+
Dynamic: author
|
|
34
|
+
Dynamic: home-page
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: requires-python
|
|
37
|
+
|
|
38
|
+
# AgentBill Python SDK
|
|
39
|
+
|
|
40
|
+
OpenTelemetry-based SDK for automatically tracking and billing AI agent usage.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
### From GitHub (Recommended)
|
|
45
|
+
```bash
|
|
46
|
+
pip install git+https://github.com/Agent-Bill/python.git
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### From PyPI (Coming Soon)
|
|
50
|
+
```bash
|
|
51
|
+
pip install agentbill
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### From Source
|
|
55
|
+
```bash
|
|
56
|
+
git clone https://github.com/Agent-Bill/python.git
|
|
57
|
+
cd python
|
|
58
|
+
pip install -e .
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## File Structure
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
agentbill-python/
|
|
65
|
+
├── agentbill/
|
|
66
|
+
│ ├── __init__.py
|
|
67
|
+
│ ├── client.py
|
|
68
|
+
│ ├── tracer.py
|
|
69
|
+
│ └── types.py
|
|
70
|
+
├── examples/
|
|
71
|
+
│ ├── openai_basic.py
|
|
72
|
+
│ ├── anthropic_basic.py
|
|
73
|
+
│ ├── bedrock_basic.py
|
|
74
|
+
│ ├── azure_openai_basic.py
|
|
75
|
+
│ ├── mistral_basic.py
|
|
76
|
+
│ └── google_ai_basic.py
|
|
77
|
+
├── tests/
|
|
78
|
+
│ ├── test_agentbill.py
|
|
79
|
+
│ └── test_tracer.py
|
|
80
|
+
├── README.md
|
|
81
|
+
├── setup.py
|
|
82
|
+
├── pyproject.toml
|
|
83
|
+
├── pytest.ini
|
|
84
|
+
├── Makefile
|
|
85
|
+
├── CHANGELOG.md
|
|
86
|
+
├── CONTRIBUTING.md
|
|
87
|
+
├── SECURITY.md
|
|
88
|
+
└── LICENSE
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Quick Start
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from agentbill import AgentBill
|
|
95
|
+
import openai
|
|
96
|
+
|
|
97
|
+
# Initialize AgentBill
|
|
98
|
+
agentbill = AgentBill.init({
|
|
99
|
+
"api_key": "your-api-key",
|
|
100
|
+
"customer_id": "customer-123",
|
|
101
|
+
"debug": True
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
# Wrap your OpenAI client
|
|
105
|
+
client = agentbill.wrap_openai(openai.OpenAI(
|
|
106
|
+
api_key="sk-..."
|
|
107
|
+
))
|
|
108
|
+
|
|
109
|
+
# Use normally - all calls are automatically tracked!
|
|
110
|
+
response = client.chat.completions.create(
|
|
111
|
+
model="gpt-4",
|
|
112
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
113
|
+
)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Features
|
|
117
|
+
|
|
118
|
+
- ✅ Zero-config instrumentation
|
|
119
|
+
- ✅ Accurate token & cost tracking
|
|
120
|
+
- ✅ Multi-provider support (OpenAI, Anthropic, Bedrock, Azure OpenAI, Mistral, Google AI)
|
|
121
|
+
- ✅ Rich metadata capture
|
|
122
|
+
- ✅ OpenTelemetry-based
|
|
123
|
+
|
|
124
|
+
## Supported Providers
|
|
125
|
+
|
|
126
|
+
- **OpenAI** - GPT-4, GPT-5, Embeddings, DALL-E, Whisper, TTS
|
|
127
|
+
- **Anthropic** - Claude Sonnet, Claude Opus
|
|
128
|
+
- **AWS Bedrock** - Claude, Titan, and other Bedrock models
|
|
129
|
+
- **Azure OpenAI** - GPT models via Azure
|
|
130
|
+
- **Mistral AI** - Mistral models
|
|
131
|
+
- **Google AI** - Gemini Pro, Gemini Flash
|
|
132
|
+
|
|
133
|
+
## Provider Examples
|
|
134
|
+
|
|
135
|
+
### OpenAI
|
|
136
|
+
```python
|
|
137
|
+
from agentbill import AgentBill
|
|
138
|
+
import openai
|
|
139
|
+
|
|
140
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
141
|
+
client = agentbill.wrap_openai(openai.OpenAI(api_key="sk-..."))
|
|
142
|
+
|
|
143
|
+
response = client.chat.completions.create(
|
|
144
|
+
model="gpt-4",
|
|
145
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
146
|
+
)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Anthropic
|
|
150
|
+
```python
|
|
151
|
+
from agentbill import AgentBill
|
|
152
|
+
import anthropic
|
|
153
|
+
|
|
154
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
155
|
+
client = agentbill.wrap_anthropic(anthropic.Anthropic(api_key="sk-ant-..."))
|
|
156
|
+
|
|
157
|
+
response = client.messages.create(
|
|
158
|
+
model="claude-sonnet-4-20250514",
|
|
159
|
+
max_tokens=1024,
|
|
160
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### AWS Bedrock
|
|
165
|
+
```python
|
|
166
|
+
from agentbill import AgentBill
|
|
167
|
+
import boto3
|
|
168
|
+
|
|
169
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
170
|
+
bedrock = agentbill.wrap_bedrock(boto3.client('bedrock-runtime'))
|
|
171
|
+
|
|
172
|
+
response = bedrock.invoke_model(
|
|
173
|
+
modelId='anthropic.claude-v2',
|
|
174
|
+
body=json.dumps({
|
|
175
|
+
"prompt": "Hello!",
|
|
176
|
+
"max_tokens_to_sample": 300
|
|
177
|
+
})
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Azure OpenAI
|
|
182
|
+
```python
|
|
183
|
+
from agentbill import AgentBill
|
|
184
|
+
from openai import AzureOpenAI
|
|
185
|
+
|
|
186
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
187
|
+
client = agentbill.wrap_azure_openai(AzureOpenAI(
|
|
188
|
+
api_key="your-azure-key",
|
|
189
|
+
api_version="2024-02-01",
|
|
190
|
+
azure_endpoint="https://your-resource.openai.azure.com"
|
|
191
|
+
))
|
|
192
|
+
|
|
193
|
+
response = client.chat.completions.create(
|
|
194
|
+
model="gpt-4",
|
|
195
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
196
|
+
)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Mistral AI
|
|
200
|
+
```python
|
|
201
|
+
from agentbill import AgentBill
|
|
202
|
+
from mistralai import Mistral
|
|
203
|
+
|
|
204
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
205
|
+
client = agentbill.wrap_mistral(Mistral(api_key="your-mistral-key"))
|
|
206
|
+
|
|
207
|
+
response = client.chat.complete(
|
|
208
|
+
model="mistral-large-latest",
|
|
209
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
210
|
+
)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Google AI (Gemini)
|
|
214
|
+
```python
|
|
215
|
+
from agentbill import AgentBill
|
|
216
|
+
import google.generativeai as genai
|
|
217
|
+
|
|
218
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
219
|
+
genai.configure(api_key="your-google-key")
|
|
220
|
+
model = genai.GenerativeModel('gemini-pro')
|
|
221
|
+
wrapped_model = agentbill.wrap_google_ai(model)
|
|
222
|
+
|
|
223
|
+
response = wrapped_model.generate_content("Hello!")
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Configuration
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
config = {
|
|
230
|
+
"api_key": "your-api-key", # Required
|
|
231
|
+
"base_url": "https://...", # Optional
|
|
232
|
+
"customer_id": "customer-123", # Optional
|
|
233
|
+
"debug": True # Optional
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
agentbill = AgentBill.init(config)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Publishing to PyPI
|
|
240
|
+
|
|
241
|
+
### Prerequisites
|
|
242
|
+
1. Create a PyPI account at https://pypi.org/account/register/
|
|
243
|
+
2. Generate an API token at https://pypi.org/manage/account/token/
|
|
244
|
+
3. Create `~/.pypirc` file with your token:
|
|
245
|
+
```ini
|
|
246
|
+
[pypi]
|
|
247
|
+
username = __token__
|
|
248
|
+
password = pypi-YOUR_API_TOKEN_HERE
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Publishing Steps
|
|
252
|
+
```bash
|
|
253
|
+
# Build the package
|
|
254
|
+
python setup.py sdist bdist_wheel
|
|
255
|
+
|
|
256
|
+
# Upload to PyPI
|
|
257
|
+
pip install twine
|
|
258
|
+
twine upload dist/*
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## GitHub Repository Setup
|
|
262
|
+
|
|
263
|
+
1. Create repository: `https://github.com/Agent-Bill/python`
|
|
264
|
+
2. Push all files (agentbill/, examples/, LICENSE, setup.py, README.md)
|
|
265
|
+
3. Tag releases: `git tag v1.0.0 && git push origin v1.0.0`
|
|
266
|
+
4. Users can install with: `pip install git+https://github.com/Agent-Bill/python.git`
|
|
267
|
+
|
|
268
|
+
## License
|
|
269
|
+
|
|
270
|
+
MIT
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# AgentBill Python SDK
|
|
2
|
+
|
|
3
|
+
OpenTelemetry-based SDK for automatically tracking and billing AI agent usage.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### From GitHub (Recommended)
|
|
8
|
+
```bash
|
|
9
|
+
pip install git+https://github.com/Agent-Bill/python.git
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### From PyPI (Coming Soon)
|
|
13
|
+
```bash
|
|
14
|
+
pip install agentbill
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### From Source
|
|
18
|
+
```bash
|
|
19
|
+
git clone https://github.com/Agent-Bill/python.git
|
|
20
|
+
cd python
|
|
21
|
+
pip install -e .
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## File Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
agentbill-python/
|
|
28
|
+
├── agentbill/
|
|
29
|
+
│ ├── __init__.py
|
|
30
|
+
│ ├── client.py
|
|
31
|
+
│ ├── tracer.py
|
|
32
|
+
│ └── types.py
|
|
33
|
+
├── examples/
|
|
34
|
+
│ ├── openai_basic.py
|
|
35
|
+
│ ├── anthropic_basic.py
|
|
36
|
+
│ ├── bedrock_basic.py
|
|
37
|
+
│ ├── azure_openai_basic.py
|
|
38
|
+
│ ├── mistral_basic.py
|
|
39
|
+
│ └── google_ai_basic.py
|
|
40
|
+
├── tests/
|
|
41
|
+
│ ├── test_agentbill.py
|
|
42
|
+
│ └── test_tracer.py
|
|
43
|
+
├── README.md
|
|
44
|
+
├── setup.py
|
|
45
|
+
├── pyproject.toml
|
|
46
|
+
├── pytest.ini
|
|
47
|
+
├── Makefile
|
|
48
|
+
├── CHANGELOG.md
|
|
49
|
+
├── CONTRIBUTING.md
|
|
50
|
+
├── SECURITY.md
|
|
51
|
+
└── LICENSE
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from agentbill import AgentBill
|
|
58
|
+
import openai
|
|
59
|
+
|
|
60
|
+
# Initialize AgentBill
|
|
61
|
+
agentbill = AgentBill.init({
|
|
62
|
+
"api_key": "your-api-key",
|
|
63
|
+
"customer_id": "customer-123",
|
|
64
|
+
"debug": True
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
# Wrap your OpenAI client
|
|
68
|
+
client = agentbill.wrap_openai(openai.OpenAI(
|
|
69
|
+
api_key="sk-..."
|
|
70
|
+
))
|
|
71
|
+
|
|
72
|
+
# Use normally - all calls are automatically tracked!
|
|
73
|
+
response = client.chat.completions.create(
|
|
74
|
+
model="gpt-4",
|
|
75
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Features
|
|
80
|
+
|
|
81
|
+
- ✅ Zero-config instrumentation
|
|
82
|
+
- ✅ Accurate token & cost tracking
|
|
83
|
+
- ✅ Multi-provider support (OpenAI, Anthropic, Bedrock, Azure OpenAI, Mistral, Google AI)
|
|
84
|
+
- ✅ Rich metadata capture
|
|
85
|
+
- ✅ OpenTelemetry-based
|
|
86
|
+
|
|
87
|
+
## Supported Providers
|
|
88
|
+
|
|
89
|
+
- **OpenAI** - GPT-4, GPT-5, Embeddings, DALL-E, Whisper, TTS
|
|
90
|
+
- **Anthropic** - Claude Sonnet, Claude Opus
|
|
91
|
+
- **AWS Bedrock** - Claude, Titan, and other Bedrock models
|
|
92
|
+
- **Azure OpenAI** - GPT models via Azure
|
|
93
|
+
- **Mistral AI** - Mistral models
|
|
94
|
+
- **Google AI** - Gemini Pro, Gemini Flash
|
|
95
|
+
|
|
96
|
+
## Provider Examples
|
|
97
|
+
|
|
98
|
+
### OpenAI
|
|
99
|
+
```python
|
|
100
|
+
from agentbill import AgentBill
|
|
101
|
+
import openai
|
|
102
|
+
|
|
103
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
104
|
+
client = agentbill.wrap_openai(openai.OpenAI(api_key="sk-..."))
|
|
105
|
+
|
|
106
|
+
response = client.chat.completions.create(
|
|
107
|
+
model="gpt-4",
|
|
108
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Anthropic
|
|
113
|
+
```python
|
|
114
|
+
from agentbill import AgentBill
|
|
115
|
+
import anthropic
|
|
116
|
+
|
|
117
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
118
|
+
client = agentbill.wrap_anthropic(anthropic.Anthropic(api_key="sk-ant-..."))
|
|
119
|
+
|
|
120
|
+
response = client.messages.create(
|
|
121
|
+
model="claude-sonnet-4-20250514",
|
|
122
|
+
max_tokens=1024,
|
|
123
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
124
|
+
)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### AWS Bedrock
|
|
128
|
+
```python
|
|
129
|
+
from agentbill import AgentBill
|
|
130
|
+
import boto3
|
|
131
|
+
|
|
132
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
133
|
+
bedrock = agentbill.wrap_bedrock(boto3.client('bedrock-runtime'))
|
|
134
|
+
|
|
135
|
+
response = bedrock.invoke_model(
|
|
136
|
+
modelId='anthropic.claude-v2',
|
|
137
|
+
body=json.dumps({
|
|
138
|
+
"prompt": "Hello!",
|
|
139
|
+
"max_tokens_to_sample": 300
|
|
140
|
+
})
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Azure OpenAI
|
|
145
|
+
```python
|
|
146
|
+
from agentbill import AgentBill
|
|
147
|
+
from openai import AzureOpenAI
|
|
148
|
+
|
|
149
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
150
|
+
client = agentbill.wrap_azure_openai(AzureOpenAI(
|
|
151
|
+
api_key="your-azure-key",
|
|
152
|
+
api_version="2024-02-01",
|
|
153
|
+
azure_endpoint="https://your-resource.openai.azure.com"
|
|
154
|
+
))
|
|
155
|
+
|
|
156
|
+
response = client.chat.completions.create(
|
|
157
|
+
model="gpt-4",
|
|
158
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
159
|
+
)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Mistral AI
|
|
163
|
+
```python
|
|
164
|
+
from agentbill import AgentBill
|
|
165
|
+
from mistralai import Mistral
|
|
166
|
+
|
|
167
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
168
|
+
client = agentbill.wrap_mistral(Mistral(api_key="your-mistral-key"))
|
|
169
|
+
|
|
170
|
+
response = client.chat.complete(
|
|
171
|
+
model="mistral-large-latest",
|
|
172
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
173
|
+
)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Google AI (Gemini)
|
|
177
|
+
```python
|
|
178
|
+
from agentbill import AgentBill
|
|
179
|
+
import google.generativeai as genai
|
|
180
|
+
|
|
181
|
+
agentbill = AgentBill.init({"api_key": "your-api-key"})
|
|
182
|
+
genai.configure(api_key="your-google-key")
|
|
183
|
+
model = genai.GenerativeModel('gemini-pro')
|
|
184
|
+
wrapped_model = agentbill.wrap_google_ai(model)
|
|
185
|
+
|
|
186
|
+
response = wrapped_model.generate_content("Hello!")
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Configuration
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
config = {
|
|
193
|
+
"api_key": "your-api-key", # Required
|
|
194
|
+
"base_url": "https://...", # Optional
|
|
195
|
+
"customer_id": "customer-123", # Optional
|
|
196
|
+
"debug": True # Optional
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
agentbill = AgentBill.init(config)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Publishing to PyPI
|
|
203
|
+
|
|
204
|
+
### Prerequisites
|
|
205
|
+
1. Create a PyPI account at https://pypi.org/account/register/
|
|
206
|
+
2. Generate an API token at https://pypi.org/manage/account/token/
|
|
207
|
+
3. Create `~/.pypirc` file with your token:
|
|
208
|
+
```ini
|
|
209
|
+
[pypi]
|
|
210
|
+
username = __token__
|
|
211
|
+
password = pypi-YOUR_API_TOKEN_HERE
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Publishing Steps
|
|
215
|
+
```bash
|
|
216
|
+
# Build the package
|
|
217
|
+
python setup.py sdist bdist_wheel
|
|
218
|
+
|
|
219
|
+
# Upload to PyPI
|
|
220
|
+
pip install twine
|
|
221
|
+
twine upload dist/*
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## GitHub Repository Setup
|
|
225
|
+
|
|
226
|
+
1. Create repository: `https://github.com/Agent-Bill/python`
|
|
227
|
+
2. Push all files (agentbill/, examples/, LICENSE, setup.py, README.md)
|
|
228
|
+
3. Tag releases: `git tag v1.0.0 && git push origin v1.0.0`
|
|
229
|
+
4. Users can install with: `pip install git+https://github.com/Agent-Bill/python.git`
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AgentBill Python SDK
|
|
3
|
+
OpenTelemetry-based SDK for tracking AI agent usage and billing
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .client import AgentBill
|
|
7
|
+
from .tracer import AgentBillTracer
|
|
8
|
+
from .types import AgentBillConfig, TraceContext
|
|
9
|
+
|
|
10
|
+
__version__ = "1.0.0"
|
|
11
|
+
__all__ = ["AgentBill", "AgentBillTracer", "AgentBillConfig", "TraceContext"]
|