Skip to main content

OpenAI Plugin for GetStream

This package provides OpenAI integration for the GetStream plugin ecosystem.

It enables features such as:

  • Real-time transcription and language processing using OpenAI models
  • Easy integration with other GetStream plugins and services
  • Function calling capabilities for dynamic interactions

Installation

pip install getstream-plugins-openai

Usage

from getstream.plugins.openai import OpenAIRealtime

# Initialize with API key
sts = OpenAIRealtime(api_key="your_openai_api_key", voice="alloy")

# Connect to a call
async with await sts.connect(call, agent_user_id="assistant") as connection:
    # Send user message
    await sts.send_user_message("Hello, how can you help me?")

    # Request assistant response
    await sts.request_assistant_response()

Function Calling

The OpenAI Realtime API supports function calling, allowing the assistant to invoke custom functions you define. This enables dynamic interactions like:

  • Database queries
  • API calls to external services
  • File operations
  • Custom business logic

Example with Function Calling

from getstream.plugins.openai import OpenAIRealtime

# Define your functions
def get_weather(location: str) -> str:
    """Get current weather for a location"""
    # Your weather API logic here
    return f"Weather in {location}: Sunny, 72°F"

def send_email(to: str, subject: str, body: str) -> str:
    """Send an email"""
    # Your email sending logic here
    return f"Email sent to {to} with subject: {subject}"

# Initialize with functions
sts = OpenAIRealtime(
    api_key="your_openai_api_key",
    voice="alloy",
    functions=[
        {
            "name": "get_weather",
            "description": "Get current weather information",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City name"}
                },
                "required": ["location"]
            }
        },
        {
            "name": "send_email",
            "description": "Send an email to someone",
            "parameters": {
                "type": "object",
                "properties": {
                    "to": {"type": "string", "description": "Recipient email"},
                    "subject": {"type": "string", "description": "Email subject"},
                    "body": {"type": "string", "description": "Email body"}
                },
                "required": ["to", "subject", "body"]
            }
        }
    ]
)

async with await sts.connect(call, agent_user_id="assistant") as connection:
    await sts.send_user_message("What's the weather like in San Francisco?")
    await sts.request_assistant_response()

    # The assistant can now call your functions and you can respond with results
    # await sts.send_function_call_output("call_id", "function_result")

Requirements

  • Python 3.10+
  • openai[realtime] api
  • GetStream SDK

License

MIT

Metadata

Release files for getstream-plugins-openai 0.1.1

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

Built distribution (wheel)

Table of built distributions (wheels) for getstream-plugins-openai 0.1.1
File Interpreter ABI Platform Actions
getstream_plugins_openai-0.1.1-py3-none-any.whl Python 3 none any Details for getstream_plugins_openai-0.1.1-py3-none-any.whl

Release files / getstream_plugins_openai-0.1.1-py3-none-any.whl

Download URL getstream_plugins_openai-0.1.1-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fb665286402dc631f1d36fb6761416b6310f1a984b76152eda90348556259a0
BLAKE2b-256 checksum
How to use checksums
0c7ec3f18ddb15e587e8e43496799fd6cb1d4a3b4c7381825e477325e4cc7bfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for getstream-plugins-openai 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

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