Skip to main content

OpenAI Realtime API Python Utils

If you want to base your application/agent on OpenAI's realtime api, but:

then this package is for you.

Example

with hook_handlers(
    connection, 
    server_event_handlers = [
        track_config.server_event_handler,  # views session.updated
        track_conversation.server_event_handler,    # views various events
        *iap_server_handlers,   # views e.g. response.output_audio.delta
        stream_mic.server_event_handler,    # views session.updated
        print_events.server_event_handler, # views all events
        f, 
    ], 
    client_event_handlers = [
        middlewares.GiveClientEventId().client_event_handler, # alter all events without ID
        track_config.client_event_handler,  # views session.update
        track_conversation.client_event_handler,    # views various events
        print_events.client_event_handler, # views all events
    ],
) as (keep_receiving, send):
    iap_register_send_with_handlers(send)   # needs to send interrupt events
    stream_mic.register_send_with_handlers(send)    # needs to send audio input
    
    asyncio.create_task(keep_receiving())
...

Utilities & Middlewares

  • openai_realtime_api_utils.hook_handlers: run a session with your handlers.
  • openai_realtime_api_utils.middlewares
    • .TrackConfig: Keep track of session config.
    • .TrackConversation: Client-side representation of the conversation(s), synced by events.
    • .GiveClientEventId: Auto-fill client event id.
    • .Interrupt: The user may interrupt assistant speech.
    • .AudioPlayer: Host system audio playback.
    • .interruptable_audio_player: .Interrupt and .AudioPlayer in gift wraps.
    • .StreamMic: Host system audio capture.
    • .PrintEvents: Print events for debug.

Style

  • Functional programming.
  • Dependency injection.
  • Middleware event handlers.

Metadata

Release files for openai-realtime-api-utils 0.1.2

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

Source distribution (sdist)

Source distribution for openai-realtime-api-utils 0.1.2
File Size Uploaded
openai_realtime_api_utils-0.1.2.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openai-realtime-api-utils 0.1.2
File Interpreter ABI Platform
openai_realtime_api_utils-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 46.1 kB

Release files / openai_realtime_api_utils-0.1.2.tar.gz

Download URL openai_realtime_api_utils-0.1.2.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
221615a196a54aed92afd09a957464195830640bc1fcd0b2592372b680a4e45a
BLAKE2b-256 checksum
How to use checksums
7c2b003e37d2bb31c9266f2cbd5bd6f5ecdc0e4df5261c354d2a7a3b84cdd52c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / openai_realtime_api_utils-0.1.2-py3-none-any.whl

Download URL openai_realtime_api_utils-0.1.2-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1495bb8213dbbd7ad0d59337db5c2daf39d86a663cf830262f05d188a41de9dd
BLAKE2b-256 checksum
How to use checksums
70385e355508346ab2ce3011c0c6d6d88ea2efa0a5c8d2b4a96fdf44be233531
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.1.2 This release

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