voicemint 0.3.1__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.
- voicemint-0.3.1/LICENSE +21 -0
- voicemint-0.3.1/PKG-INFO +443 -0
- voicemint-0.3.1/README.md +408 -0
- voicemint-0.3.1/pyproject.toml +71 -0
- voicemint-0.3.1/setup.cfg +4 -0
- voicemint-0.3.1/src/voicemint/__init__.py +43 -0
- voicemint-0.3.1/src/voicemint/_client.py +407 -0
- voicemint-0.3.1/src/voicemint/_errors.py +172 -0
- voicemint-0.3.1/src/voicemint/_files.py +58 -0
- voicemint-0.3.1/src/voicemint/_ops.py +186 -0
- voicemint-0.3.1/src/voicemint/_version.py +1 -0
- voicemint-0.3.1/src/voicemint/py.typed +0 -0
- voicemint-0.3.1/src/voicemint/resources/__init__.py +77 -0
- voicemint-0.3.1/src/voicemint/resources/_base.py +59 -0
- voicemint-0.3.1/src/voicemint/resources/_polling.py +107 -0
- voicemint-0.3.1/src/voicemint/resources/agents.py +181 -0
- voicemint-0.3.1/src/voicemint/resources/audio.py +187 -0
- voicemint-0.3.1/src/voicemint/resources/calls.py +169 -0
- voicemint-0.3.1/src/voicemint/resources/campaigns.py +213 -0
- voicemint-0.3.1/src/voicemint/resources/credits.py +21 -0
- voicemint-0.3.1/src/voicemint/resources/knowledge.py +122 -0
- voicemint-0.3.1/src/voicemint/resources/live_sessions.py +35 -0
- voicemint-0.3.1/src/voicemint/resources/media.py +374 -0
- voicemint-0.3.1/src/voicemint/resources/meet.py +226 -0
- voicemint-0.3.1/src/voicemint/resources/music.py +195 -0
- voicemint-0.3.1/src/voicemint/resources/numbers.py +124 -0
- voicemint-0.3.1/src/voicemint/resources/speech.py +201 -0
- voicemint-0.3.1/src/voicemint/resources/translation.py +188 -0
- voicemint-0.3.1/src/voicemint/resources/voices.py +101 -0
- voicemint-0.3.1/src/voicemint/types.py +353 -0
- voicemint-0.3.1/src/voicemint.egg-info/PKG-INFO +443 -0
- voicemint-0.3.1/src/voicemint.egg-info/SOURCES.txt +40 -0
- voicemint-0.3.1/src/voicemint.egg-info/dependency_links.txt +1 -0
- voicemint-0.3.1/src/voicemint.egg-info/requires.txt +5 -0
- voicemint-0.3.1/src/voicemint.egg-info/top_level.txt +1 -0
- voicemint-0.3.1/tests/test_apps.py +453 -0
- voicemint-0.3.1/tests/test_async.py +117 -0
- voicemint-0.3.1/tests/test_client.py +124 -0
- voicemint-0.3.1/tests/test_errors.py +116 -0
- voicemint-0.3.1/tests/test_phone.py +259 -0
- voicemint-0.3.1/tests/test_resources.py +240 -0
- voicemint-0.3.1/tests/test_retries.py +122 -0
voicemint-0.3.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alpha AI Service Pvt Ltd
|
|
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.
|
voicemint-0.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: voicemint
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Official Python SDK for the VoiceMint public API
|
|
5
|
+
Author-email: Alpha AI Service Pvt Ltd <developers@alphaaiservice.com>
|
|
6
|
+
Maintainer-email: Alpha AI Service Pvt Ltd <developers@alphaaiservice.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://docs.voicemint.io
|
|
9
|
+
Project-URL: Documentation, https://docs.voicemint.io
|
|
10
|
+
Project-URL: Source, https://github.com/alphaaiservice/voicemint-python
|
|
11
|
+
Project-URL: Issues, https://github.com/alphaaiservice/voicemint-python/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/alphaaiservice/voicemint-python/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: voicemint,tts,text-to-speech,speech-to-text,speech,voice,voice-agents,agents,sdk,api-client
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
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
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: httpx<1,>=0.23
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
33
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# VoiceMint Python SDK
|
|
37
|
+
|
|
38
|
+
Official Python client for the VoiceMint public API, covering every app in
|
|
39
|
+
the product: **Voice Lab** (text to speech, speech to text, voice cloning,
|
|
40
|
+
voice changer and effects, voice isolation, translation and dubbing, audio
|
|
41
|
+
tools), **Music** (tracks and songs), **Video**, **Image**, **Meet** and
|
|
42
|
+
**Agents** (agents, knowledge bases, phone calls and numbers, campaigns,
|
|
43
|
+
live-voice tokens) — and any other endpoint through `client.request(...)`.
|
|
44
|
+
[API-COVERAGE.md](API-COVERAGE.md) lists every endpoint a key can call and
|
|
45
|
+
the method that wraps it.
|
|
46
|
+
|
|
47
|
+
- Python 3.9+, one dependency (`httpx`)
|
|
48
|
+
- Sync (`VoiceMint`) and asyncio (`AsyncVoiceMint`) clients
|
|
49
|
+
- Typed errors, automatic retries on rate limits and transient failures
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
The SDK is not on PyPI yet; install it from GitHub:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install "git+https://github.com/alphaaiservice/voicemint-python.git"
|
|
57
|
+
# a specific release
|
|
58
|
+
pip install "git+https://github.com/alphaaiservice/voicemint-python.git@v0.3.0"
|
|
59
|
+
# or from a local checkout
|
|
60
|
+
git clone https://github.com/alphaaiservice/voicemint-python.git
|
|
61
|
+
pip install ./voicemint-python
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Authentication
|
|
65
|
+
|
|
66
|
+
Create a secret key in the VoiceMint web app: **Settings → Developers → create
|
|
67
|
+
an app → New secret key**. It looks like `vm_sk_live_…` (or `vm_sk_test_…`)
|
|
68
|
+
and is shown once.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
export VOICEMINT_API_KEY=vm_sk_live_...
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from voicemint import VoiceMint
|
|
76
|
+
|
|
77
|
+
client = VoiceMint() # reads VOICEMINT_API_KEY
|
|
78
|
+
client = VoiceMint(api_key="vm_sk_live_...")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Requests run as the key's owner: the same agents, files, history and credits
|
|
82
|
+
as in the web app, limited to the products the key was given
|
|
83
|
+
(`agents`, `meet`, `media`, read-only or read/write).
|
|
84
|
+
|
|
85
|
+
> **Keep the key on your server.** A secret key can spend your credits. Never
|
|
86
|
+
> put it in a browser page, a mobile app, or a public repository. Call
|
|
87
|
+
> VoiceMint from your backend and pass only results to your front end. If a
|
|
88
|
+
> key leaks, revoke it under Settings → Developers; it stops working at once.
|
|
89
|
+
|
|
90
|
+
### Options
|
|
91
|
+
|
|
92
|
+
| argument | default | |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `api_key` | `$VOICEMINT_API_KEY` | secret key |
|
|
95
|
+
| `base_url` | `$VOICEMINT_BASE_URL` or `https://api.voicemint.io/api/v1` | override for a test environment |
|
|
96
|
+
| `timeout` | `60.0` | seconds (float or `httpx.Timeout`) |
|
|
97
|
+
| `max_retries` | `2` | see [Retries](#retries) |
|
|
98
|
+
| `default_headers` | — | extra headers on every request |
|
|
99
|
+
| `http_client` | — | your own `httpx.Client` / `httpx.AsyncClient` (proxies, mocks) |
|
|
100
|
+
|
|
101
|
+
Every request sends `Authorization: Bearer <key>` and
|
|
102
|
+
`User-Agent: voicemint-python/<version>`.
|
|
103
|
+
|
|
104
|
+
## Examples
|
|
105
|
+
|
|
106
|
+
### Chat with an agent
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
first = client.agents.chat("AGENT_ID", "Hi! What are your opening hours?")
|
|
110
|
+
print(first["reply"]) # the agent's answer
|
|
111
|
+
print(first["sources"]) # knowledge-base passages it used
|
|
112
|
+
|
|
113
|
+
# continue the same conversation
|
|
114
|
+
nxt = client.agents.chat("AGENT_ID", "And on Sundays?", session_id=first["session_id"])
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Manage agents:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
agent = client.agents.create(
|
|
121
|
+
"Support bot",
|
|
122
|
+
instructions="You answer customer questions briefly.",
|
|
123
|
+
llm={"provider": "openai", "model": "gpt-6.1-terra", "temperature": 0.3},
|
|
124
|
+
knowledge_base_ids=["KB_ID"],
|
|
125
|
+
status="active",
|
|
126
|
+
)
|
|
127
|
+
client.agents.models() # valid llm provider/model ids
|
|
128
|
+
client.agents.update(agent["id"], greeting="Hello! How can I help?")
|
|
129
|
+
page = client.agents.list(limit=20, q="support") # {"items": [...], "total": n}
|
|
130
|
+
client.agents.sessions(agent["id"]) # {"items": [...]}
|
|
131
|
+
client.agents.session_messages("SESSION_ID") # {"items": [...]}
|
|
132
|
+
client.agents.delete(agent["id"])
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Upload a file to a knowledge base
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
kb = client.knowledge.create("Product docs")
|
|
139
|
+
source = client.knowledge.upload_file(kb["id"], "handbook.pdf") # path, bytes or open file
|
|
140
|
+
print(source["status"]) # "processing" — ingestion runs in the background
|
|
141
|
+
|
|
142
|
+
import time
|
|
143
|
+
while client.knowledge.sources(kb["id"])["items"][0]["status"] == "processing":
|
|
144
|
+
time.sleep(2)
|
|
145
|
+
|
|
146
|
+
client.knowledge.add_text(kb["id"], "FAQ", "Refunds within 30 days.")
|
|
147
|
+
client.knowledge.add_url(kb["id"], "https://example.com/pricing")
|
|
148
|
+
hits = client.knowledge.search(kb["id"], "refund policy", top_k=3)["items"]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Files are limited to 25 MB.
|
|
152
|
+
|
|
153
|
+
### Text to speech, saved to a file
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
audio = client.text_to_speech.create(
|
|
157
|
+
"Thanks for calling VoiceMint!",
|
|
158
|
+
voice="alloy", # OpenAI voice; or provider="gemini", voice="Kore"
|
|
159
|
+
format="mp3", # mp3 | wav | ogg
|
|
160
|
+
speed=1.0,
|
|
161
|
+
)
|
|
162
|
+
audio.write_to_file("greeting.mp3")
|
|
163
|
+
print(audio.content_type, len(audio.content))
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`create` returns an `AudioResponse` with `content` (bytes), `content_type`,
|
|
167
|
+
and — when `save_to_history=True` — `audio_url` and `history_entry_id`.
|
|
168
|
+
|
|
169
|
+
### Speech to text
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
result = client.speech_to_text.transcribe("call.mp3", language="en")
|
|
173
|
+
print(result["text"], result["confidence"])
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Credits
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
client.credits.balance()["total_available"]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Phone calls
|
|
183
|
+
|
|
184
|
+
> Placing calls needs at least one phone number on the account and
|
|
185
|
+
> `agents.write`. Options marked † are **available after the phone
|
|
186
|
+
> release** (MR !116 / !118 / !121): older servers ignore them.
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
placed = client.calls.create(
|
|
190
|
+
"AGENT_ID",
|
|
191
|
+
"+919876543210", # E.164
|
|
192
|
+
from_number_id="NUMBER_ID", # optional: default number otherwise
|
|
193
|
+
variables={"name": "Asha", "order_id": "A-77"}, # † fills {name}, {order_id}
|
|
194
|
+
)
|
|
195
|
+
call = client.calls.wait(placed["call_id"], timeout=600)
|
|
196
|
+
print(call["status"], call["duration_sec"], call.get("transcript"))
|
|
197
|
+
|
|
198
|
+
client.calls.get("CALL_ID")
|
|
199
|
+
client.calls.list(agent_id="AGENT_ID", status="ended", date_from="2026-12-01")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`calls.wait` polls `GET /agents/calls/{id}` (every 3 s by default) until the
|
|
203
|
+
status is `ended`, `failed`, `busy`, `no_answer` or `canceled`, and raises
|
|
204
|
+
`voicemint.WaitTimeoutError` (with `.last`) when it runs out of time. Calls
|
|
205
|
+
are rate-limited per account (429 → `RateLimitError`, retried automatically).
|
|
206
|
+
|
|
207
|
+
### Phone numbers
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
client.telephony.providers() # {"items": [{"id", "can_search", "can_buy", ...}], "purchase_enabled"}
|
|
211
|
+
client.numbers.list() # your numbers
|
|
212
|
+
client.numbers.search("US", "Local", contains="415", provider="twilio")
|
|
213
|
+
num = client.numbers.buy("+14155550100", provider="twilio", agent_id="AGENT_ID")
|
|
214
|
+
client.numbers.assign(num["id"], "OTHER_AGENT_ID") # or None to unassign
|
|
215
|
+
client.numbers.release(num["id"])
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`search` and `buy` answer 403 unless number purchase is enabled for the
|
|
219
|
+
platform (`purchase_enabled`). Buying spends real money on the platform's
|
|
220
|
+
provider account.
|
|
221
|
+
|
|
222
|
+
### Campaigns
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
campaign = client.campaigns.create(
|
|
226
|
+
"contacts.csv", # path, bytes, open file or (name, bytes) tuple
|
|
227
|
+
{
|
|
228
|
+
"name": "Renewals",
|
|
229
|
+
"agent_id": "AGENT_ID",
|
|
230
|
+
"concurrency": 3,
|
|
231
|
+
"window": {"timezone": "Asia/Kolkata", "start": "10:00", "end": "18:00", "days": [0, 1, 2, 3, 4]},
|
|
232
|
+
"retry": {"max_attempts": 2, "delay_minutes": 30},
|
|
233
|
+
},
|
|
234
|
+
)
|
|
235
|
+
client.campaigns.action(campaign["id"], "start") # start | pause | resume | cancel
|
|
236
|
+
client.campaigns.get(campaign["id"])
|
|
237
|
+
client.campaigns.list(status="running")
|
|
238
|
+
client.campaigns.contacts(campaign["id"], status="failed")
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`campaigns.preview(file)` validates a CSV without saving it. CSV columns
|
|
242
|
+
become `{variables}` in the agent's prompt.
|
|
243
|
+
|
|
244
|
+
### Live voice tokens (for browsers and the widget)
|
|
245
|
+
|
|
246
|
+
A browser must never see your secret key. Your server mints a single-use,
|
|
247
|
+
60-second live-session token and hands it to the page — this is the token
|
|
248
|
+
endpoint the [`@voicemint/widget`](../widget/README.md) calls:
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
# e.g. FastAPI
|
|
252
|
+
@app.post("/voicemint-token")
|
|
253
|
+
def voicemint_token(body: dict, user=Depends(current_user)):
|
|
254
|
+
return client.live_sessions.create(body["agent_id"], variables={"name": user.first_name}) # † variables
|
|
255
|
+
# -> {"ws_url", "token", "expires_at", "expires_in", "subprotocol"}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Check that the signed-in user may talk to that agent before minting.
|
|
259
|
+
|
|
260
|
+
### Voice Lab: cloned voices
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
voice = client.voices.clone("my-voice.wav", "Asha", description="warm, Hindi")
|
|
264
|
+
audio = client.voices.speak(voice["voice_id"], "Namaste! Welcome back.")
|
|
265
|
+
audio.write_to_file("asha.mp3")
|
|
266
|
+
|
|
267
|
+
client.voices.list(status="completed")
|
|
268
|
+
client.voices.catalog() # premade voices by category
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Voice Lab: translation and dubbing
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
client.translation.text("Your order has shipped", "hi")["translated_text"]
|
|
275
|
+
|
|
276
|
+
dubbed = client.translation.audio("support-call.mp3", "es", source_language="en")
|
|
277
|
+
dubbed.write_to_file("support-call.es.mp3")
|
|
278
|
+
|
|
279
|
+
job = client.translation.create_audio_job("lecture.mp3", "ta")
|
|
280
|
+
client.translation.wait_job(job["job_id"]) # polls with backoff
|
|
281
|
+
result = client.translation.job_result(job["job_id"])
|
|
282
|
+
|
|
283
|
+
client.translation.dub("promo.mp3", "hi", "en").write_to_file("promo.hi.wav")
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Voice Lab: voice changer, isolation and audio tools
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
robot = client.audio.apply_effects("me.wav", ["robot", {"type": "pitch_shift", "parameters": {"semitones": 4}}])
|
|
290
|
+
robot.write_to_file("me.robot.wav")
|
|
291
|
+
|
|
292
|
+
job = client.audio.isolate("song.mp3", "vocals") # vocals | instrumental | karaoke | stems | drums_bass
|
|
293
|
+
done = client.audio.wait_job(job["jobId"])
|
|
294
|
+
for track in done["result"]["tracks"]:
|
|
295
|
+
client.audio.download_track(job["jobId"], track["id"]).write_to_file(f"{track['id']}.wav")
|
|
296
|
+
|
|
297
|
+
client.audio.convert("take.wav", "mp3").write_to_file("take.mp3")
|
|
298
|
+
client.audio.info("take.wav")["duration"]
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Music
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
track = client.music.generate("ambient", duration_seconds=30, mood="relaxed")
|
|
305
|
+
client.jobs.download(track["audio_url"], "ambient.wav")
|
|
306
|
+
|
|
307
|
+
song = client.music.songs.create("a monsoon love song", language="Hindi", genre="Bollywood")
|
|
308
|
+
song = client.music.songs.wait(song["id"]) # renders take a few minutes
|
|
309
|
+
client.jobs.download(song["audio_url"], "monsoon.mp3")
|
|
310
|
+
|
|
311
|
+
client.music.generate_lyria("lofi beats for studying", variant="clip")
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Video and Image
|
|
315
|
+
|
|
316
|
+
Generations run in the background: start one, then `jobs.wait` and
|
|
317
|
+
`jobs.download` (signed storage links are fetched without your key).
|
|
318
|
+
|
|
319
|
+
```python
|
|
320
|
+
job = client.video.generate("a paper boat sailing down a rainy street", duration=5, aspect_ratio="9:16")
|
|
321
|
+
done = client.jobs.wait(job["generation_id"], timeout=900)
|
|
322
|
+
client.jobs.download(done["output_url"], "boat.mp4")
|
|
323
|
+
|
|
324
|
+
img = client.image.generate("a fox in a misty forest, watercolour", width=1024, height=1024)
|
|
325
|
+
done = client.jobs.wait(img["generation_id"])
|
|
326
|
+
client.jobs.download(done["output_url"], "fox.png")
|
|
327
|
+
|
|
328
|
+
up = client.image.edit("upscale_2x", generation_id=img["generation_id"])
|
|
329
|
+
asset = client.image.upload("logo.png")
|
|
330
|
+
client.image.edit("remove_bg", asset_id=asset["id"])
|
|
331
|
+
|
|
332
|
+
client.video.models(), client.image.models() # pass an id as model_id
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
`jobs.wait` raises `voicemint.JobFailedError` when a job fails or is
|
|
336
|
+
cancelled and `voicemint.WaitTimeoutError` when it takes longer than
|
|
337
|
+
`timeout` (the job keeps running). Video dubbing projects live under
|
|
338
|
+
`client.video.dubbing` (`create_project`, `upload`, `dub`, `download`).
|
|
339
|
+
|
|
340
|
+
### Meet
|
|
341
|
+
|
|
342
|
+
Needs a key with `meet` permissions.
|
|
343
|
+
|
|
344
|
+
```python
|
|
345
|
+
personas = client.meet.personas(search="doctor")
|
|
346
|
+
expert = client.meet.experts.create(
|
|
347
|
+
category_id="health", character_id="<persona id>", name="Dr Rao", expertise="Nutrition"
|
|
348
|
+
)
|
|
349
|
+
meet = client.meet.experts.start_session(expert["id"])
|
|
350
|
+
client.meet.meets.add_source(meet["id"], url="https://example.com/diet-guide")
|
|
351
|
+
token = client.meet.meets.create_live_session(meet["id"]) # hand this to the browser
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Any other endpoint
|
|
355
|
+
|
|
356
|
+
Everything in the API reference is reachable with `request`:
|
|
357
|
+
|
|
358
|
+
```python
|
|
359
|
+
client.request("GET", "/text-to-speech/history", params={"limit": 10})
|
|
360
|
+
client.request("POST", "/some/endpoint", json={...})
|
|
361
|
+
client.request("POST", "/some/upload", files={"file": ("a.wav", data, "audio/wav")}, data={"name": "x"})
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
It returns parsed JSON, `bytes` for binary bodies, `str` for text, `None` for
|
|
365
|
+
an empty body, or the `httpx.Response` with `raw=True`.
|
|
366
|
+
|
|
367
|
+
### Async
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
import asyncio
|
|
371
|
+
from voicemint import AsyncVoiceMint
|
|
372
|
+
|
|
373
|
+
async def main():
|
|
374
|
+
async with AsyncVoiceMint() as client:
|
|
375
|
+
r = await client.agents.chat("AGENT_ID", "Hello")
|
|
376
|
+
print(r["reply"])
|
|
377
|
+
|
|
378
|
+
asyncio.run(main())
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Errors
|
|
382
|
+
|
|
383
|
+
Every API error is a `voicemint.APIError` with `status`, `message` (from the
|
|
384
|
+
response's `detail`), `body` (the parsed response) and `headers`.
|
|
385
|
+
|
|
386
|
+
| status | exception |
|
|
387
|
+
|---|---|
|
|
388
|
+
| 400 | `BadRequestError` |
|
|
389
|
+
| 401 | `AuthenticationError` — missing, wrong, revoked or expired key |
|
|
390
|
+
| 402 | `InsufficientCreditsError` |
|
|
391
|
+
| 403 | `PermissionDeniedError` — route not available to keys, outside the key's permissions, or owner inactive |
|
|
392
|
+
| 404 | `NotFoundError` |
|
|
393
|
+
| 422 | `ValidationError` — `message` lists the failing fields |
|
|
394
|
+
| 429 | `RateLimitError` — `retry_after` seconds |
|
|
395
|
+
| 5xx | `InternalServerError` |
|
|
396
|
+
| other | `APIError` |
|
|
397
|
+
| no response | `APIConnectionError`, `APITimeoutError` |
|
|
398
|
+
|
|
399
|
+
All inherit from `voicemint.VoiceMintError`.
|
|
400
|
+
|
|
401
|
+
```python
|
|
402
|
+
from voicemint import InsufficientCreditsError, RateLimitError, APIError
|
|
403
|
+
|
|
404
|
+
try:
|
|
405
|
+
client.agents.chat(agent_id, "Hi")
|
|
406
|
+
except InsufficientCreditsError:
|
|
407
|
+
notify_billing()
|
|
408
|
+
except RateLimitError as e:
|
|
409
|
+
schedule_retry(after=e.retry_after)
|
|
410
|
+
except APIError as e:
|
|
411
|
+
log.error("VoiceMint %s: %s", e.status, e.message)
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Keys can never reach `/admin`, `/applications`, `/users`, `/auth`, `/debug`,
|
|
415
|
+
`/subscriptions`, and can only read `/credits` (403).
|
|
416
|
+
|
|
417
|
+
## Retries
|
|
418
|
+
|
|
419
|
+
- **429**: retried for every method, after the server's `Retry-After`
|
|
420
|
+
(capped at 60 s). The limit is checked before the endpoint runs, so a
|
|
421
|
+
retried POST is never applied twice.
|
|
422
|
+
- **5xx and connection errors/timeouts**: retried only for idempotent
|
|
423
|
+
methods (`GET`, `HEAD`, `PUT`, `DELETE`) with exponential backoff and
|
|
424
|
+
jitter (0.5 s, 1 s, 2 s … up to 8 s).
|
|
425
|
+
- **POST and PATCH are never retried on 5xx or connection errors**: the
|
|
426
|
+
request may already have run (and spent credits).
|
|
427
|
+
|
|
428
|
+
`max_retries=2` (default) means up to 3 attempts; `max_retries=0` disables
|
|
429
|
+
retries.
|
|
430
|
+
|
|
431
|
+
## Development
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
pip install -e ".[dev]"
|
|
435
|
+
ruff check .
|
|
436
|
+
pytest -q
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
See `examples/quickstart.py` for an end-to-end script.
|
|
440
|
+
|
|
441
|
+
## License
|
|
442
|
+
|
|
443
|
+
MIT, see [LICENSE](LICENSE). Security issues: see [SECURITY.md](SECURITY.md).
|