Allow a custom voice object for `openai_voice` on GPT-Live

Merged
PY
12d ago
+22-3

Closes #14160

Why we make these changes

GPT-Live selects a custom voice with an object, {'id': 'voice_...'}, as audio.output.voice. OpenAILiveModelSettings.openai_voice was annotated str, so passing that object worked at runtime but was a type error and undocumented. This widens the annotation to the OpenAI SDK's request type and documents the form, as the sibling OpenAIRealtimeModelSettings.openai_voice already does.

New public surface

None. OpenAILiveModelSettings.openai_voice widens from str to str | CustomVoiceParam (openai.types.live.CustomVoiceParam). The SDK type is not re-exported.

User-visible behavior

settings = OpenAILiveModelSettings(openai_voice={'id': 'voice_1234'})
# before: pyright error, value already sent as-is
# after: type-checks; sent as {"audio": {"output": {"voice": {"id": "voice_1234"}}}} in session.start

Verification

  • test_openai_voice_custom_voice_object_reaches_session_start_payload: the object reaches the session.start payload verbatim through connect(). Existing cedar tests cover the string form.
  • tests/realtime/test_openai_live.py and pyright on the changed files pass.
  • Not live-probed: a custom voice needs an OpenAI account eligible for custom voices. The wire shape follows OpenAI's custom voices guide and the SDK's CustomVoiceParam.

What changes for existing users

Nothing. OpenAILiveModel already passed the value through unchanged.

PR decisions

2026-11-22 · adopted PR #14165 at 2026-11-22 · iter -

  • Decision: Branch-context bootstrapped from existing PR + issue. No resolved threads to backfill.
  • Why: PR opened by pydanty before branch-context existed in this worktree
  • Source: https://github.com/pydantic/pydantic-ai/pull/14165
  • Session: f379144a-a6ce-4ca7-b116-1198859bc240

2026-11-22 · douwebot is the required review; merge on its approval · iter -

  • Decision: David turned on douwebot for this PR and wants it merged once douwebot approves. Fix douwebot's findings on this PR, the two gaps (docstring object form; realistic doc id) included, and re-run douwebot. No further second opinion at step 7. misc-mgr enqueues once the head meets the merge bar; this agent does not merge or enqueue.
  • Why: David's decision, relayed in misc-mgr dispatch 2026-11-22 (local-notes/dispatch-voice-20261122T235517Z.md)
  • Source: https://github.com/pydantic/pydantic-ai/pull/14165#pullrequestreview-6015196028
  • Session: f379144a-a6ce-4ca7-b116-1198859bc240

2026-11-22 · pre-push review 1 of 3 at 41959dacc2f56f25dc568bae76684e2533c304ad · iter -

2026-11-23 · pre-push review 1 of 3 at 41959dacc2f56f25dc568bae76684e2533c304ad · iter -

2026-11-23 · Apply pr-review-checks:run as dsfaccini · iter -

  • Decision: Standing overmanager rule for pydanty PRs a manager drives, quoted: 'You may apply pr-review-checks:run as dsfaccini on the pydanty PRs you drive'. Never push while pydanty:is-working is on the PR.
  • Why: An app author gets 'Awaiting maintainer' on PR Review Checks; rule source is the overmanager dispatch local-notes/dispatch-20261114T134309Z.md in the manager worktree, confirmed by misc-mgr dispatch 2026-11-23 (local-notes/dispatch-voice-20261123T000253Z.md)
  • Source: https://github.com/pydantic/pydantic-ai/pull/14165
  • Session: f379144a-a6ce-4ca7-b116-1198859bc240

2026-11-23 · CI flake on 41959dacc2: smolvm timeout teardown ResourceWarning · iter -

  • Decision: Reran failed jobs once (attempt 2 passed); filed flake issue routed to David (dsfaccini, pydanty:skip, p:3-mid); fix left to that issue
  • Why: Unrelated to this PR (test from 463a6d519b, PR changes no package versions); no prior flake issue named the test
  • Source: https://github.com/pydantic/pydantic-ai/issues/14188
  • Session: f379144a-a6ce-4ca7-b116-1198859bc240

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it. (None: additive annotation widening.)
  • PR title is fit for the release changelog.