Skip to main content

A comprehensive Python client for the Venice.ai API with automatic parameter validation

Project description

PyVenice

Python Version PyPI Version License Tests Coverage Code Style

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

📦 Installation

pip install pyvenice

For development:

pip install pyvenice[dev]

🚀 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvenice-0.1.0.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvenice-0.1.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file pyvenice-0.1.0.tar.gz.

File metadata

  • Download URL: pyvenice-0.1.0.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pyvenice-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fb78d8e112df0e67558bb4e5faaa740c35fa4cafac30afee3f03d2a0e26cc460
MD5 bbc53618820d4ceb4126c4b785afdb68
BLAKE2b-256 182ca382c4f8d3d03fabaf33dd55e0a7200695e12670c4548cc094cc7f18f7ee

See more details on using hashes here.

File details

Details for the file pyvenice-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyvenice-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pyvenice-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e49a591f91f8215ddb9f216511398414d590b0ba52c25c2a0144d2160231c386
MD5 e85fbe5e19dad1aa60ea368e6528f70e
BLAKE2b-256 b97ad22b679c822edaad89147ce719c2942828b60fccbdec92cb802f58158608

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page