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.client 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

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.2.2.tar.gz (39.5 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.2.2-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for voicerun_completions-0.2.2.tar.gz
Algorithm Hash digest
SHA256 66704f27721bb16ca3d6460649bca464a3126d1b068f10c2e4dd4d415aa98c11
MD5 2d8bef3bf0ac700a8d091c34095ca026
BLAKE2b-256 e5b08d19e875f9934a1941e2fd902268c26b002ee730fcc81df82d13c6e151e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for voicerun_completions-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 140906e7e29f09217b3a6d02d059a4f2d95f94a59b644c0f7942e1a96e121349
MD5 81d8422ab1b2a8f01b1dc5956a5b6e98
BLAKE2b-256 72447ebcf6e7719c066d378ca8b961d348c9548b9e4d8f5c5ab0aa44cc6f8b0d

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