Skip to main content

voicelayer

The VoiceLayer API client for Python: send and read messages on every channel, hand conversations between your code, the agent and people, and receive events by webhook, stream or pull. Generated from the public OpenAPI document with OpenAPI Generator, plus a short VoiceLayer client, webhook verification and a resuming event stream.

pip install voicelayer

Send a message

from voicelayer import VoiceLayer

vl = VoiceLayer()  # reads VOICELAYER_API_KEY (and VOICELAYER_API_URL)

sent = vl.messages.send(channel="sms", to="+15551234567", text="Your order shipped.")
vl.conversations.reply(str(sent.message.conversation_id), text="Thanks!")

Every operation of the API reference is a method under its resource (messages, conversations, events, webhooks, channels, test, logs), named after it in snake case: messages.list, conversations.get, webhooks.create_subscription. A path parameter is a positional argument; the query parameters and the body's fields are keyword arguments. A method returns the answer's model. Pass content= instead of text= to send media. Use with VoiceLayer() as vl: to close its connections when you are done.

Pass idempotency_key="order-1042-shipped" and a retry never sends twice.

Handle errors

A refusal raises VoiceLayerApiError with the API's code (output_refused, window_closed, ...), request_id, retryable and docs. It is an ApiException, so except ApiException still catches it.

from voicelayer import VoiceLayer, VoiceLayerApiError

vl = VoiceLayer()

try:
    vl.messages.send(channel="sms", to="+15551234567", text="Your order shipped.")
except VoiceLayerApiError as err:
    if not err.retryable:
        raise
    # retry with the same idempotency_key

Test mode

inbound = vl.test.create_inbound(channel="sms", from_="+15550101", text="Are you open?")
# inbound.conversation_id: a test conversation; replies in it go through the loopback and cost nothing

A test key (vl_test_…) simulates a person writing from a reserved address (+15550100–+15550199, test-<n>, <anything>@test.vlayers.ai). A workspace with no number or Binding on the channel gets a free test sender.

For agent frameworks (the Claude Agent SDK, OpenAI Agents, LangGraph) and direct mode (serve_direct), see voicelayer-agents.

Verify webhooks

from voicelayer.webhooks import verify_webhook, WebhookVerificationError

# the RAW request body, before any JSON parsing; the secret is VOICELAYER_WEBHOOK_SECRET
event = verify_webhook(raw_body, request.headers)

verify_webhook needs no client or API key, so a webhook receiver can import it alone. vl.webhooks.verify is the same function.

Stream events

for item in vl.events.stream(types=["message.*"]):
    print(item.event["type"], item.event["data"])
    save_cursor(item.cursor)  # pass it back as after= to resume

The iterator reconnects after a drop with Last-Event-ID and dedupes by event id.

Advanced: the generated classes

VoiceLayer is a thin layer over the package generated from the OpenAPI document, which stays intact underneath. vl.configuration and vl.api_client are the generated Configuration and ApiClient, so any generated API class works with them. Use those for the HTTP response (send_message_with_http_info) or the exact request model.

import os
import voicelayer

config = voicelayer.Configuration(access_token=os.environ["VOICELAYER_API_KEY"])
with voicelayer.ApiClient(config) as client:
    voicelayer.MessagesApi(client).send_message(
        voicelayer.SendMessageRequest.from_dict(
            {"channel": "sms", "to": "+15551234567", "content": {"type": "text", "text": "Your order shipped."}}
        ),
        idempotency_key="order-1042-shipped",
    )

The generated API reference is in docs/. Licence: Apache-2.0.

Metadata

Release files for voicelayer 0.1.0

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

Source distribution (sdist)

Source distribution for voicelayer 0.1.0
File Size Uploaded Provenance
voicelayer-0.1.0.tar.gz 77.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for voicelayer 0.1.0
File Interpreter ABI Platform
voicelayer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 272.7 kB

Release files / voicelayer-0.1.0.tar.gz

Download URL voicelayer-0.1.0.tar.gz
Size 77.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1155af62e49f4c3eabde7046ec72961693c648635261a307c4de3e8eb9fc55b1
BLAKE2b-256 checksum
How to use checksums
375b10daadb97d78c6fb51b0dfa6f97647702b39879ba6530fc0d5f01e4bb212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / voicelayer-0.1.0-py3-none-any.whl

Download URL voicelayer-0.1.0-py3-none-any.whl
Size 195.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02c08f45c75cc6aa2c93ed5469610bd4c6c33f9dbe993ed5dcd558b7ca6de782
BLAKE2b-256 checksum
How to use checksums
a6a853862218479d14fc5f9010205b304d9d326b5929f847ad7bc44766b89b49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for voicelayer 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for voicelayer-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full 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