A comprehensive Python client for the Venice.ai API with automatic parameter validation
Project description
PyVenice
A comprehensive Python client library for the Venice.ai API with automatic parameter validation, type safety, and support for all endpoints.
✨ Features
- 🔧 Automatic Parameter Validation - Removes unsupported parameters based on model capabilities
- 🛡️ Full Type Safety - Pydantic models for all requests and responses
- 📡 Complete API Coverage - All 16 Venice.ai endpoints implemented
- ⚡ Async Support - Both synchronous and asynchronous clients
- 🌊 Streaming Responses - Efficient streaming for chat completions and audio
- 🔒 Secure by Default - HTTPS only, credentials stay local
- ⚙️ Zero Configuration - Sensible defaults with full customization
- 🧪 Thoroughly Tested - 82% test coverage with comprehensive test suite
Looking for Venice.ai access? Consider using my referreal code https://venice.ai/chat?ref=0Y4qyR or register at venice.ai
📦 Installation
pip install pyvenice
For development:
pip install pyvenice[dev]
Troubleshooting Installation
If you encounter build errors (especially on ARM64 Android/Termux), see our Installation Troubleshooting Guide.
🚀 Quick Start
from pyvenice import VeniceClient, ChatCompletion
# Initialize client (uses VENICE_API_KEY env var by default)
client = VeniceClient()
# Create a chat completion
chat = ChatCompletion(client)
response = chat.create(
model="venice-uncensored",
messages=[{"role": "user", "content": "Hello, Venice!"}]
)
print(response.choices[0].message.content)
💡 Usage Examples
Chat Completions with Streaming
from pyvenice import VeniceClient, ChatCompletion
client = VeniceClient(api_key="your-api-key")
chat = ChatCompletion(client)
# Stream responses
for chunk in chat.create_streaming(
model="venice-coder",
messages=[{"role": "user", "content": "Write a Python function"}],
temperature=0.7
):
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Image Generation
from pyvenice import VeniceClient, ImageGeneration
client = VeniceClient()
image_gen = ImageGeneration(client)
response = image_gen.generate(
prompt="A serene lake at sunset",
model="flux-schnell",
width=1024,
height=1024,
steps=4
)
# Save the image
import base64
image_data = base64.b64decode(response.images[0])
with open("sunset.png", "wb") as f:
f.write(image_data)
Automatic Parameter Validation
PyVenice automatically removes parameters that aren't supported by specific models:
# This won't cause an error even if venice-uncensored doesn't support parallel_tool_calls
response = chat.create(
model="venice-uncensored",
messages=[{"role": "user", "content": "Hello!"}],
parallel_tool_calls=True # Automatically removed if unsupported
)
Async Support
import asyncio
from pyvenice import VeniceClient, ChatCompletion
async def main():
client = VeniceClient()
chat = ChatCompletion(client)
response = await chat.acreate(
model="venice-coder",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
asyncio.run(main())
🎯 Supported Endpoints
- 💬 Chat Completions -
/chat/completionswith streaming and web search - 🎨 Image Generation -
/image/generate,/images/generations - 🔍 Image Upscaling -
/image/upscale - 🔊 Text to Speech -
/audio/speechwith streaming - 📊 Embeddings -
/embeddings - 🤖 Model Management -
/models,/models/traits - 🔑 API Keys -
/api_keys, rate limits, and web3 key generation - 👤 Characters -
/charactersfor character-based interactions - 💰 Billing -
/billing/usagewith pagination
⚙️ Configuration
Environment Variables
export VENICE_API_KEY="your-api-key"
export VENICE_BASE_URL="https://api.venice.ai/api/v1" # Optional
Client Configuration
client = VeniceClient(
api_key="your-api-key",
base_url="https://api.venice.ai/api/v1",
timeout=30.0,
max_retries=3
)
🧪 Testing
The test suite is included with the package for verification:
# Basic installation (no test dependencies)
pip install pyvenice
# Installation with test dependencies
pip install pyvenice[test]
# Run tests after installing with [test]
pytest -m "not integration" # Unit tests only (no API key needed)
pytest --cov=pyvenice # With coverage
# For development (includes test + dev tools)
pip install -e .[dev]
🤝 Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
# Setup development environment
git clone https://github.com/TheLustriVA/PyVenice.git
cd PyVenice
pip install -e .[dev]
# Run tests before submitting PR
pytest
black .
ruff check .
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔒 Security
PyVenice prioritizes security:
- All communications use HTTPS with certificate verification
- API keys are never logged or included in error messages
- No telemetry or data collection
- Minimal dependencies, all well-maintained and audited
- Input validation prevents injection attacks
For security concerns, please email [kieran@bicheno.me] or open an issue on GitHub
📚 Documentation
For detailed documentation, visit our docs or check out the examples directory.
🙏 Acknowledgments
Built with ❤️ using:
📈 Project Status
PyVenice is under active development. We follow semantic versioning and maintain backwards compatibility for all minor releases.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyvenice-0.3.1.tar.gz.
File metadata
- Download URL: pyvenice-0.3.1.tar.gz
- Upload date:
- Size: 51.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96c89a4384ac74c508a86ef40706b39ba7f86bd2ce23dae4aa602980b0c20d4b
|
|
| MD5 |
023ae2ef8e6de0637417943ec7a5aaff
|
|
| BLAKE2b-256 |
fa5134ff980ab46c11c8d9a1e225a116f9e3a7947f151d7ec89c1b5d56be4935
|
Provenance
The following attestation bundles were made for pyvenice-0.3.1.tar.gz:
Publisher:
build-wheels.yml on TheLustriVA/PyVenice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyvenice-0.3.1.tar.gz -
Subject digest:
96c89a4384ac74c508a86ef40706b39ba7f86bd2ce23dae4aa602980b0c20d4b - Sigstore transparency entry: 274597503
- Sigstore integration time:
-
Permalink:
TheLustriVA/PyVenice@9f2d28a5e49130c26ae35bfc21bc344f1342df76 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/TheLustriVA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@9f2d28a5e49130c26ae35bfc21bc344f1342df76 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyvenice-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pyvenice-0.3.1-py3-none-any.whl
- Upload date:
- Size: 32.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a69b193ed841470522d68729d5c7c58b48dad35f80458b4d7d78678778007b41
|
|
| MD5 |
fea3b63ed1689230822c1e93b7716407
|
|
| BLAKE2b-256 |
fb038876831d650fcb85d411113a1979d82e975d5d4838d54ab108bdad2ad03f
|
Provenance
The following attestation bundles were made for pyvenice-0.3.1-py3-none-any.whl:
Publisher:
build-wheels.yml on TheLustriVA/PyVenice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyvenice-0.3.1-py3-none-any.whl -
Subject digest:
a69b193ed841470522d68729d5c7c58b48dad35f80458b4d7d78678778007b41 - Sigstore transparency entry: 274597505
- Sigstore integration time:
-
Permalink:
TheLustriVA/PyVenice@9f2d28a5e49130c26ae35bfc21bc344f1342df76 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/TheLustriVA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@9f2d28a5e49130c26ae35bfc21bc344f1342df76 -
Trigger Event:
push
-
Statement type: