Connect a voice agent with keel-voice-sidecar
keel-voice-sidecar is a Python library that runs inside your voice
gateway. It records signed observations of a live voice call, sends them to
Keel, and asks Keel for an attestation when the call ends. Your gateway keeps
the provider connection, the audio and the provider credentials.
Experimental and unqualified. keel-voice-sidecar 0.2.1 (PyPI, Apache-2.0)
is an experimental, uncertified observation SDK. Its adapters have been
exercised against mocked provider connections only. Live provider sandbox
qualification and a fresh-customer end-to-end run have not been done yet, and
every integration profile is unqualified. Use it for evaluation, not as a
certified production path.
The realtime conversation itself is not Keel-governed. The sidecar records what your gateway observed; it does not control audio or text streaming. For the limits of voice evidence and the money-moving tool boundary, read Voice Tool Calls and Evidence first.
What the sidecar supports
| Provider connection | Sidecar setting |
|---|---|
| OpenAI Realtime (WebSocket) | provider="openai", openai_protocol="realtime" (the default) |
| OpenAI GPT-Live (WebSocket) | provider="openai", openai_protocol="live"; input and output audio must use one format |
| ElevenLabs Agents | provider="elevenlabs" with provider_api_key and provider_agent_id |
Twilio, Vapi and Deepgram agent adapters are not shipped. The sidecar has no helper for placing phone calls.
What you need
- Python 3.11 or 3.12 and a gateway you operate.
- A Keel project admin key for the one-time setup steps.
- A Keel client key for the gateway, bound to a registered agent. See Verify an agent.
- Each tool the voice agent may call, registered as a managed MCP tool with a verified tool contract. See Integration Coverage.
- Consent and any customer authorization your calls require, obtained before capture or provider start. That stays your responsibility.
Right now the dashboard covers only Compliance → Voice (voice rules for calls that start from then on). The key and gateway-profile steps below are API-only at this stage.
One-time setup
1. Prepare the sidecar signing key
Generate a stable Ed25519 key inside the gateway. The private key never leaves it; the command prints only the public enrollment record.
python -m pip install keel-voice-sidecar==0.2.1
umask 077
keel-voice-prepare-key --path evidence/sidecar.pem --key-id gateway-1 > enrollment.jsonenrollment.json contains key_id, algorithm (ed25519) and
public_key_b64url.
2. Enroll the public key with Keel
A project admin enrolls that record. Keel checks sidecar event signatures against it.
curl --fail-with-body -sS -X POST https://api.keelapi.com/v1/voice/sidecar-keys \
-H "Authorization: Bearer $KEEL_ADMIN_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @enrollment.jsonGET /v1/voice/sidecar-keys lists enrolled keys and
DELETE /v1/voice/sidecar-keys/{key_id} revokes one. All three need the admin
key.
3. Optional: enroll a contract price
If you pay your voice provider under a contract price, an admin can enroll it
with POST /v1/voice/pricing-profiles (read it with
GET /v1/voice/pricing-profiles/{profile_id}; DELETE stops future calls from
using it). A pricing profile cannot be edited once enrolled. Pricing profiles are
for ElevenLabs and outbound calling services; a gateway profile names one with
pricing_profile_id and pricing_profile_digest, supplied together.
4. Bind the gateway’s client key to a voice gateway profile
PUT /v1/voice/gateway-profiles/{api_key_id} freezes what that client key may
do as a voice gateway. It needs the admin key, and the target must be a live
client key (not revoked or expired) bound to a live registered agent;
otherwise Keel returns 409 voice.runtime_credential_required or
409 voice.agent_identity_required.
{
"profile_id": "openai_realtime_gateway_ws_v1",
"gateway_id": "support-gateway",
"gateway_release_sha": "0123456789abcdef0123456789abcdef01234567",
"configuration_digest": "<sha256 hex of your gateway's provider configuration>",
"managed_tools": [
{
"server_id": "<managed MCP server id>",
"tool_name": "refund_order",
"schema_hash": "<sha256 hex of the verified tool schema>"
}
],
"tool_catalog_digest": "<sha256 hex of the managed_tools catalog>",
"privacy_profile_digest": "<sha256 hex of your privacy settings>",
"signing_key_id": "gateway-1",
"max_duration_seconds": 900,
"max_concurrent_sessions": 5
}Required fields: profile_id, gateway_id, gateway_release_sha (a 40-hex
commit), configuration_digest, managed_tools, tool_catalog_digest,
privacy_profile_digest, signing_key_id, max_duration_seconds (1–3600) and
max_concurrent_sessions (1–100). Digests are lowercase 64-hex SHA-256.
profile_idisopenai_realtime_gateway_ws_v1orelevenlabs_agents_gateway_ws_v1for a conversation. There is no separate GPT-Live profile kind right now.- A conversation profile needs at least one managed tool, at most 64. Each tool
must be on an enabled managed MCP server whose tool contract is verified and
matches
schema_hash.tool_catalog_digestmust match the catalog exactly. - ElevenLabs profiles must pin
provider_agent_id. - The profile cannot be changed. Sending a different profile for the same key
returns
409 voice.profile_immutable. To change it, rotate the client key and bind the new key.
Per call
-
Start a session. The gateway calls
POST /v1/sessionswith its client key. Keel issues the session-start Permit under the frozen profile. -
Get provider-start admission. Before connecting to the provider, the gateway calls
POST /v1/sessions/{session_id}/voice-admissionwith a newdispatch_id, the profile’sconfiguration_digest, andprovider_request_digestequal to that same digest. Keel returns a signed admission that expires after 30 seconds and can be used once; a second call returns409 voice.admission_consumed. Keel returns409 voice.profile_binding_requiredwhen the digests do not match the frozen profile. -
Run the sidecar. Configure it with the session ID, the client key, the provider key and the signing key. It sends signed events to
POST /v1/voice/sessions/{session_id}/events.from pathlib import Path from keel_voice_sidecar import VoiceSidecar, VoiceSidecarConfig, to_file def configure(session_id: str, keel_key: str, provider_key: str) -> VoiceSidecarConfig: return VoiceSidecarConfig( session_id=session_id, keel_base_url="https://api.keelapi.com", keel_api_key=keel_key, provider="openai", openai_protocol="realtime", provider_api_key=provider_key, signing_private_key_path=Path("evidence/sidecar.pem"), signing_key_id="gateway-1", wal_path=Path("evidence/events.sqlite3"), ) async def observe(sidecar: VoiceSidecar, output: Path): try: await sidecar.start() await sidecar.run() artifact = await sidecar.end_session() return to_file(artifact, output) finally: await sidecar.close()Evidence delivery is awaited on the audio path and can delay audio forwarding. Finish all caller input and tool calls before the provider receive loop ends.
-
End the call.
end_session()callsPOST /v1/sessions/{session_id}/endand returns the attestation. -
Reconcile if needed. If final evidence delivery or settlement is uncertain, keep the local event database and call
POST /v1/sessions/{session_id}/voice-reconciliationwith the same client key to retry settlement from the evidence Keel already verified.
What leaves the gateway
The sidecar sends media and transcript digests, bounded identifiers and codes, counts, timestamps and signatures to Keel. Raw audio goes to the voice provider, not to Keel. A digest or a short identifier can still be linkable, so use opaque IDs and fixed vocabularies for names, reason codes and labels.
The separate request_tool_permit(...) helper sends its tool arguments to Keel
in full. See Session action arguments.
The local SQLite database stores signed event JSON, identifiers and delivery state. Treat it, its journal files, exported JSONL and attestations as sensitive, and keep it until reconciliation and verification finish.
Verify the attestation
Get Keel’s issuer public key from a source you trust, then run the bundled verifier:
keel-voice-verify attestation.json --ca-key issuer.pem --format=jsonTo also check the sidecar’s own signatures, export the committed events for that session only and pass them with the enrollment record:
keel-voice-verify attestation.json --ca-key issuer.pem --events events.jsonl \
--sidecar-key enrollment.json --strict --format=jsonRead each status separately. keel-voice-verify does not authenticate RFC 3161
timestamp tokens; a structurally consistent receipt reads UNCHECKED. An
attestation records what the gateway reported. It does not establish that the
whole conversation was captured, that a notice or consent reached a person,
that speech was suppressed, or that a provider executed anything.