Skip to main content

PyVenice

Python Version PyPI Version License Tests Code Style

A comprehensive Python client library for the Venice.ai API with automatic parameter validation, type safety, and support for all endpoints.

PyVenice Banner

✨ 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/completions with streaming and web search
  • 🎨 Image Generation - /image/generate, /images/generations
  • 🔍 Image Upscaling - /image/upscale
  • 🔊 Text to Speech - /audio/speech with streaming
  • 📊 Embeddings - /embeddings
  • 🤖 Model Management - /models, /models/traits
  • 🔑 API Keys - /api_keys, rate limits, and web3 key generation
  • 👤 Characters - /characters for character-based interactions
  • 💰 Billing - /billing/usage with 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.

Star History Chart

Release files for pyvenice 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvenice 0.3.1
File Size Uploaded
pyvenice-0.3.1.tar.gz 51.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyvenice 0.3.1
File Interpreter ABI Platform
pyvenice-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 83.4 kB

Release files / pyvenice-0.3.1.tar.gz

Download URL pyvenice-0.3.1.tar.gz
Size 51.4 kB
Tags Source
SHA-256 checksum
How to use checksums
96c89a4384ac74c508a86ef40706b39ba7f86bd2ce23dae4aa602980b0c20d4b
BLAKE2b-256 checksum
How to use checksums
fa5134ff980ab46c11c8d9a1e225a116f9e3a7947f151d7ec89c1b5d56be4935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 15, 2025.

Transparency log

Release files / pyvenice-0.3.1-py3-none-any.whl

Download URL pyvenice-0.3.1-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a69b193ed841470522d68729d5c7c58b48dad35f80458b4d7d78678778007b41
BLAKE2b-256 checksum
How to use checksums
fb038876831d650fcb85d411113a1979d82e975d5d4838d54ab108bdad2ad03f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 15, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page