venice-sdk 0.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- venice_sdk/__init__.py +297 -0
- venice_sdk/_http.py +67 -0
- venice_sdk/account.py +905 -0
- venice_sdk/audio.py +762 -0
- venice_sdk/augment.py +221 -0
- venice_sdk/characters.py +441 -0
- venice_sdk/chat.py +511 -0
- venice_sdk/cli.py +302 -0
- venice_sdk/client.py +493 -0
- venice_sdk/config.py +214 -0
- venice_sdk/crypto.py +61 -0
- venice_sdk/decisions.py +173 -0
- venice_sdk/embeddings.py +461 -0
- venice_sdk/endpoints.py +136 -0
- venice_sdk/errors.py +289 -0
- venice_sdk/images.py +827 -0
- venice_sdk/logging_config.py +74 -0
- venice_sdk/metrics.py +205 -0
- venice_sdk/models.py +270 -0
- venice_sdk/models_advanced.py +609 -0
- venice_sdk/responses.py +165 -0
- venice_sdk/tee.py +70 -0
- venice_sdk/utils.py +181 -0
- venice_sdk/venice_client.py +212 -0
- venice_sdk/video.py +954 -0
- venice_sdk/voice_changer.py +226 -0
- venice_sdk/x402.py +247 -0
- venice_sdk-0.3.3.dist-info/METADATA +648 -0
- venice_sdk-0.3.3.dist-info/RECORD +32 -0
- venice_sdk-0.3.3.dist-info/WHEEL +4 -0
- venice_sdk-0.3.3.dist-info/entry_points.txt +2 -0
- venice_sdk-0.3.3.dist-info/licenses/LICENSE +477 -0
venice_sdk/__init__.py
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Venice SDK for Python.
|
|
3
|
+
|
|
4
|
+
This module provides a comprehensive Python interface to the Venice AI API.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
from .client import HTTPClient
|
|
10
|
+
from .venice_client import VeniceClient, create_client
|
|
11
|
+
from .config import Config, load_config
|
|
12
|
+
from .errors import (
|
|
13
|
+
VeniceError,
|
|
14
|
+
VeniceAPIError,
|
|
15
|
+
VeniceConnectionError,
|
|
16
|
+
RateLimitError,
|
|
17
|
+
UnauthorizedError,
|
|
18
|
+
InsufficientBalanceError,
|
|
19
|
+
InvalidRequestError,
|
|
20
|
+
ModelNotFoundError,
|
|
21
|
+
CharacterNotFoundError,
|
|
22
|
+
ImageGenerationError,
|
|
23
|
+
AudioGenerationError,
|
|
24
|
+
VideoGenerationError,
|
|
25
|
+
BillingError,
|
|
26
|
+
APIKeyError,
|
|
27
|
+
EmbeddingError,
|
|
28
|
+
)
|
|
29
|
+
from .models import (
|
|
30
|
+
Model,
|
|
31
|
+
ModelCapabilities,
|
|
32
|
+
ModelsAPI,
|
|
33
|
+
get_models,
|
|
34
|
+
get_model_by_id,
|
|
35
|
+
get_text_models,
|
|
36
|
+
)
|
|
37
|
+
from .chat import (
|
|
38
|
+
Message,
|
|
39
|
+
Choice,
|
|
40
|
+
Usage,
|
|
41
|
+
ChatCompletion,
|
|
42
|
+
ChatAPI,
|
|
43
|
+
chat_complete,
|
|
44
|
+
)
|
|
45
|
+
from .images import (
|
|
46
|
+
ImageGeneration,
|
|
47
|
+
ImageEditResult,
|
|
48
|
+
ImageUpscaleResult,
|
|
49
|
+
ImageStyle,
|
|
50
|
+
ImageAPI,
|
|
51
|
+
ImageEditAPI,
|
|
52
|
+
ImageUpscaleAPI,
|
|
53
|
+
ImageStylesAPI,
|
|
54
|
+
generate_image,
|
|
55
|
+
get_image_model_constraints,
|
|
56
|
+
edit_image,
|
|
57
|
+
upscale_image,
|
|
58
|
+
multi_edit_image,
|
|
59
|
+
remove_background,
|
|
60
|
+
)
|
|
61
|
+
from .audio import (
|
|
62
|
+
Voice,
|
|
63
|
+
AudioResult,
|
|
64
|
+
TranscriptionResult,
|
|
65
|
+
AudioAPI,
|
|
66
|
+
MusicJob,
|
|
67
|
+
MusicAPI,
|
|
68
|
+
AudioBatchProcessor,
|
|
69
|
+
text_to_speech,
|
|
70
|
+
text_to_speech_file,
|
|
71
|
+
)
|
|
72
|
+
from .video import (
|
|
73
|
+
VideoMetadata,
|
|
74
|
+
VideoJob,
|
|
75
|
+
VideoQuote,
|
|
76
|
+
VideoAPI,
|
|
77
|
+
)
|
|
78
|
+
from .characters import (
|
|
79
|
+
Character,
|
|
80
|
+
CharactersAPI,
|
|
81
|
+
CharacterManager,
|
|
82
|
+
get_character,
|
|
83
|
+
list_characters,
|
|
84
|
+
search_characters,
|
|
85
|
+
)
|
|
86
|
+
from .account import (
|
|
87
|
+
APIKey,
|
|
88
|
+
Web3APIKey,
|
|
89
|
+
RateLimits,
|
|
90
|
+
RateLimitLog,
|
|
91
|
+
UsageInfo,
|
|
92
|
+
ModelUsage,
|
|
93
|
+
APIKeysAPI,
|
|
94
|
+
BillingAPI,
|
|
95
|
+
AccountManager,
|
|
96
|
+
get_account_usage,
|
|
97
|
+
get_rate_limits,
|
|
98
|
+
list_api_keys,
|
|
99
|
+
)
|
|
100
|
+
from .models_advanced import (
|
|
101
|
+
ModelTraits,
|
|
102
|
+
CompatibilityMapping,
|
|
103
|
+
ModelsTraitsAPI,
|
|
104
|
+
ModelsCompatibilityAPI,
|
|
105
|
+
ModelRecommendationEngine,
|
|
106
|
+
get_model_traits,
|
|
107
|
+
get_compatibility_mapping,
|
|
108
|
+
find_models_by_capability,
|
|
109
|
+
)
|
|
110
|
+
from .embeddings import (
|
|
111
|
+
Embedding,
|
|
112
|
+
EmbeddingResult,
|
|
113
|
+
EmbeddingsAPI,
|
|
114
|
+
EmbeddingSimilarity,
|
|
115
|
+
SemanticSearch,
|
|
116
|
+
EmbeddingClustering,
|
|
117
|
+
generate_embedding,
|
|
118
|
+
calculate_similarity,
|
|
119
|
+
generate_embeddings,
|
|
120
|
+
)
|
|
121
|
+
from .tee import TEEAPI
|
|
122
|
+
from .augment import (
|
|
123
|
+
AugmentAPI,
|
|
124
|
+
SearchHit,
|
|
125
|
+
SearchResponse,
|
|
126
|
+
ScrapeResponse,
|
|
127
|
+
ParsedDocument,
|
|
128
|
+
)
|
|
129
|
+
from .responses import ResponsesAPI, Response, ResponseOutputItem
|
|
130
|
+
from .crypto import CryptoAPI
|
|
131
|
+
from .x402 import (
|
|
132
|
+
X402API,
|
|
133
|
+
X402Balance,
|
|
134
|
+
X402TopUpResult,
|
|
135
|
+
X402Transactions,
|
|
136
|
+
PaymentSigner,
|
|
137
|
+
build_payment_payload,
|
|
138
|
+
encode_payment_signature,
|
|
139
|
+
decode_payment_signature,
|
|
140
|
+
)
|
|
141
|
+
from .decisions import DecisionsAPI, DecisionAnswer, DecisionResult
|
|
142
|
+
from .voice_changer import VoiceChangerAPI, VoiceChangerJob
|
|
143
|
+
from .logging_config import setup_logging
|
|
144
|
+
|
|
145
|
+
_root_logger = logging.getLogger("venice_sdk")
|
|
146
|
+
if not any(isinstance(handler, logging.NullHandler) for handler in _root_logger.handlers):
|
|
147
|
+
_root_logger.addHandler(logging.NullHandler())
|
|
148
|
+
|
|
149
|
+
__version__ = "0.3.3"
|
|
150
|
+
|
|
151
|
+
__all__ = [
|
|
152
|
+
# Core client
|
|
153
|
+
"HTTPClient",
|
|
154
|
+
"VeniceClient",
|
|
155
|
+
"create_client",
|
|
156
|
+
"Config",
|
|
157
|
+
"load_config",
|
|
158
|
+
|
|
159
|
+
# Errors
|
|
160
|
+
"VeniceError",
|
|
161
|
+
"VeniceAPIError",
|
|
162
|
+
"VeniceConnectionError",
|
|
163
|
+
"RateLimitError",
|
|
164
|
+
"UnauthorizedError",
|
|
165
|
+
"InsufficientBalanceError",
|
|
166
|
+
"InvalidRequestError",
|
|
167
|
+
"ModelNotFoundError",
|
|
168
|
+
"CharacterNotFoundError",
|
|
169
|
+
"ImageGenerationError",
|
|
170
|
+
"AudioGenerationError",
|
|
171
|
+
"VideoGenerationError",
|
|
172
|
+
"BillingError",
|
|
173
|
+
"APIKeyError",
|
|
174
|
+
"EmbeddingError",
|
|
175
|
+
|
|
176
|
+
# Models
|
|
177
|
+
"Model",
|
|
178
|
+
"ModelCapabilities",
|
|
179
|
+
"ModelsAPI",
|
|
180
|
+
"get_models",
|
|
181
|
+
"get_model_by_id",
|
|
182
|
+
"get_text_models",
|
|
183
|
+
|
|
184
|
+
# Chat
|
|
185
|
+
"Message",
|
|
186
|
+
"Choice",
|
|
187
|
+
"Usage",
|
|
188
|
+
"ChatCompletion",
|
|
189
|
+
"ChatAPI",
|
|
190
|
+
"chat_complete",
|
|
191
|
+
|
|
192
|
+
# Images
|
|
193
|
+
"ImageGeneration",
|
|
194
|
+
"ImageEditResult",
|
|
195
|
+
"ImageUpscaleResult",
|
|
196
|
+
"ImageStyle",
|
|
197
|
+
"ImageAPI",
|
|
198
|
+
"ImageEditAPI",
|
|
199
|
+
"ImageUpscaleAPI",
|
|
200
|
+
"ImageStylesAPI",
|
|
201
|
+
"generate_image",
|
|
202
|
+
"get_image_model_constraints",
|
|
203
|
+
"edit_image",
|
|
204
|
+
"upscale_image",
|
|
205
|
+
"multi_edit_image",
|
|
206
|
+
"remove_background",
|
|
207
|
+
|
|
208
|
+
# Audio
|
|
209
|
+
"Voice",
|
|
210
|
+
"AudioResult",
|
|
211
|
+
"TranscriptionResult",
|
|
212
|
+
"AudioAPI",
|
|
213
|
+
"MusicJob",
|
|
214
|
+
"MusicAPI",
|
|
215
|
+
"AudioBatchProcessor",
|
|
216
|
+
"text_to_speech",
|
|
217
|
+
"text_to_speech_file",
|
|
218
|
+
|
|
219
|
+
# Video
|
|
220
|
+
"VideoMetadata",
|
|
221
|
+
"VideoJob",
|
|
222
|
+
"VideoQuote",
|
|
223
|
+
"VideoAPI",
|
|
224
|
+
|
|
225
|
+
# Characters
|
|
226
|
+
"Character",
|
|
227
|
+
"CharactersAPI",
|
|
228
|
+
"CharacterManager",
|
|
229
|
+
"get_character",
|
|
230
|
+
"list_characters",
|
|
231
|
+
"search_characters",
|
|
232
|
+
|
|
233
|
+
# Account
|
|
234
|
+
"APIKey",
|
|
235
|
+
"Web3APIKey",
|
|
236
|
+
"RateLimits",
|
|
237
|
+
"RateLimitLog",
|
|
238
|
+
"UsageInfo",
|
|
239
|
+
"ModelUsage",
|
|
240
|
+
"APIKeysAPI",
|
|
241
|
+
"BillingAPI",
|
|
242
|
+
"AccountManager",
|
|
243
|
+
"get_account_usage",
|
|
244
|
+
"get_rate_limits",
|
|
245
|
+
"list_api_keys",
|
|
246
|
+
|
|
247
|
+
# Advanced Models
|
|
248
|
+
"ModelTraits",
|
|
249
|
+
"CompatibilityMapping",
|
|
250
|
+
"ModelsTraitsAPI",
|
|
251
|
+
"ModelsCompatibilityAPI",
|
|
252
|
+
"ModelRecommendationEngine",
|
|
253
|
+
"get_model_traits",
|
|
254
|
+
"get_compatibility_mapping",
|
|
255
|
+
"find_models_by_capability",
|
|
256
|
+
|
|
257
|
+
# Embeddings
|
|
258
|
+
"Embedding",
|
|
259
|
+
"EmbeddingResult",
|
|
260
|
+
"EmbeddingsAPI",
|
|
261
|
+
"EmbeddingSimilarity",
|
|
262
|
+
"SemanticSearch",
|
|
263
|
+
"EmbeddingClustering",
|
|
264
|
+
"generate_embedding",
|
|
265
|
+
"calculate_similarity",
|
|
266
|
+
"generate_embeddings",
|
|
267
|
+
|
|
268
|
+
# TEE
|
|
269
|
+
"TEEAPI",
|
|
270
|
+
|
|
271
|
+
# Augment / Responses / Crypto / x402
|
|
272
|
+
"AugmentAPI",
|
|
273
|
+
"SearchHit",
|
|
274
|
+
"SearchResponse",
|
|
275
|
+
"ScrapeResponse",
|
|
276
|
+
"ParsedDocument",
|
|
277
|
+
"ResponsesAPI",
|
|
278
|
+
"Response",
|
|
279
|
+
"ResponseOutputItem",
|
|
280
|
+
"CryptoAPI",
|
|
281
|
+
"X402API",
|
|
282
|
+
"X402Balance",
|
|
283
|
+
"X402TopUpResult",
|
|
284
|
+
"X402Transactions",
|
|
285
|
+
"PaymentSigner",
|
|
286
|
+
"build_payment_payload",
|
|
287
|
+
"encode_payment_signature",
|
|
288
|
+
"decode_payment_signature",
|
|
289
|
+
"DecisionsAPI",
|
|
290
|
+
"DecisionAnswer",
|
|
291
|
+
"DecisionResult",
|
|
292
|
+
"VoiceChangerAPI",
|
|
293
|
+
"VoiceChangerJob",
|
|
294
|
+
|
|
295
|
+
# Logging
|
|
296
|
+
"setup_logging",
|
|
297
|
+
]
|
venice_sdk/_http.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Callable, Dict, Optional
|
|
4
|
+
|
|
5
|
+
from .client import HTTPClient, get_http_client_manager
|
|
6
|
+
|
|
7
|
+
_manual_override_client: Optional[HTTPClient] = None
|
|
8
|
+
_factory_http_clients: Dict[int, HTTPClient] = {}
|
|
9
|
+
_http_client_manager = get_http_client_manager()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def set_shared_http_client(client: Optional[HTTPClient]) -> None:
|
|
13
|
+
"""Override the cached shared HTTP client (primarily for testing)."""
|
|
14
|
+
global _manual_override_client
|
|
15
|
+
_manual_override_client = client
|
|
16
|
+
if client is None:
|
|
17
|
+
_http_client_manager.clear()
|
|
18
|
+
_factory_http_clients.clear()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def reset_shared_http_client() -> None:
|
|
22
|
+
"""Clear the cached shared HTTP client so it will be recreated when needed."""
|
|
23
|
+
set_shared_http_client(None)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _default_http_client_factory(config: Optional["Config"] = None) -> HTTPClient:
|
|
27
|
+
"""Build an HTTPClient via the unified VeniceClient for compatibility."""
|
|
28
|
+
from .venice_client import VeniceClient
|
|
29
|
+
from .config import Config as _Config # Local import to avoid cycles
|
|
30
|
+
|
|
31
|
+
cfg: Optional[_Config] = config
|
|
32
|
+
venice_client = VeniceClient(cfg)
|
|
33
|
+
http_client = getattr(venice_client, "http_client", None)
|
|
34
|
+
if isinstance(http_client, HTTPClient):
|
|
35
|
+
return http_client
|
|
36
|
+
if isinstance(venice_client, HTTPClient):
|
|
37
|
+
return venice_client
|
|
38
|
+
# Tests commonly patch VeniceClient to return a mock; fall back to that mock.
|
|
39
|
+
return venice_client
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
_http_client_manager.set_builder(_default_http_client_factory)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_shared_http_client(
|
|
46
|
+
factory: Optional[Callable[[], HTTPClient]] = None
|
|
47
|
+
) -> HTTPClient:
|
|
48
|
+
"""Return the cached shared HTTP client, creating it on first use."""
|
|
49
|
+
if factory is None:
|
|
50
|
+
if _manual_override_client is not None:
|
|
51
|
+
return _manual_override_client
|
|
52
|
+
return _http_client_manager.get_client()
|
|
53
|
+
|
|
54
|
+
key = id(factory)
|
|
55
|
+
if key not in _factory_http_clients:
|
|
56
|
+
_factory_http_clients[key] = factory()
|
|
57
|
+
return _factory_http_clients[key]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def ensure_http_client(
|
|
61
|
+
client: Optional[HTTPClient],
|
|
62
|
+
factory: Optional[Callable[[], HTTPClient]] = None,
|
|
63
|
+
) -> HTTPClient:
|
|
64
|
+
"""Return a concrete HTTPClient, instantiating one if necessary."""
|
|
65
|
+
if client is not None:
|
|
66
|
+
return client
|
|
67
|
+
return get_shared_http_client(factory=factory)
|