Skip to main content

VoiceRun Completions

Project description

voicerun_completions

A comprehensive, unified SDK for interacting with multiple LLM providers (OpenAI, Anthropic, Google, and Vertex Anthropic) through a single, consistent API. This library simplifies working with different providers by normalizing their APIs and providing powerful features like automatic fallbacks, retry logic, and advanced streaming options.

Quick Start

from primfunctions.events import Event, StartEvent, TextEvent, TextToSpeechEvent
from primfunctions.context import Context
from voicerun_completions import generate_chat_completion

async def handler(event: Event, context: Context):
    if isinstance(event, StartEvent):
        yield TextToSpeechEvent(
            text="Hello! Ask me anything and I'll answer your question.",
            voice="nova"
        )

    if isinstance(event, TextEvent):
        user_message = event.data.get("text", "")
        
        response = await generate_chat_completion({
            "provider": "openai",
            "api_key": context.variables.get("OPENAI_API_KEY"),
            "model": "gpt-5-mini",
            "messages": [
                {"role": "user", "content": user_message}
            ]
        })
        
        if response.message.content:
            yield TextToSpeechEvent(
                text=response.message.content,
                voice="nova"
            )

Documentation

Testing

Install dev dependencies:

uv pip install -e ".[dev]"

Run unit tests (no API keys required):

uv run pytest -m "not integration" -v

Run all tests including integration (requires API keys in environment):

uv run pytest -v

Run a specific test file:

uv run pytest tests/test_google_schema_sanitization.py -v

Integration tests require one or more of these environment variables:

  • OPENAI_API_KEY
  • ANTHROPIC_API_KEY
  • GEMINI_API_KEY
  • GCP_SERVICE_ACCOUNT_JSON / GCP_PROJECT_ID (for Vertex tests)

Tests missing the required key will be skipped automatically.

Features

  • Unified API - Single interface for OpenAI, Anthropic, Google, and Vertex Anthropic
  • Automatic Fallbacks - Seamlessly fallback to alternative providers on failure
  • Retry Logic - Built-in exponential backoff retry mechanism
  • Advanced Streaming - Token-based and sentence-based streaming for real-time applications
  • Tool Calling - Unified tool/function calling across all providers
  • Type Safety - Full type hints and support for both dict and object formats

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

voicerun_completions-0.3.3.tar.gz (62.4 kB view details)

Uploaded Source

Built Distribution

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

voicerun_completions-0.3.3-py3-none-any.whl (48.6 kB view details)

Uploaded Python 3

File details

Details for the file voicerun_completions-0.3.3.tar.gz.

File metadata

File hashes

Hashes for voicerun_completions-0.3.3.tar.gz
Algorithm Hash digest
SHA256 b44e402da698ef187b179961de038958b76c84e870951c18f2f80064dfc8e9e8
MD5 e41655b2ab3d64acd018ce2302700364
BLAKE2b-256 2fd944900da494c5f4eb20ad5b9b92cfc45d6bfafe3d9d1d1cc1a670d599b3b4

See more details on using hashes here.

File details

Details for the file voicerun_completions-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for voicerun_completions-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9e83bbf5332246c3bbafdd18fb8a3e165144f822774e1e986e68e9571ead522b
MD5 d701148e7174f9fe38e4ad270dc1e6c4
BLAKE2b-256 2219ff1bb2554dcd85816640b94b19087c112580d87f0e956dd929690f2c6352

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