Skip to content

feat(api): Add Live API - #3846

Merged
apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-83
Sep 10, 2026
Merged

apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-83

Conversation

@apcha-oai

@apcha-oai apcha-oai commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor
  • Add Live API endpoints.
  • Add synchronous and asynchronous WebSocket helpers for primary, sideband, and fork connections.
  • Add TranscriptGrouper and AsyncTranscriptGrouper helpers.

Castiron-Internal-PR: openai/openai-python-internal#83
Castiron-Source-SHA: 211418be997d8866419baaf4d6c966f1a93767d6
Castiron-Public-Base-SHA: 802b334
@apcha-oai
apcha-oai marked this pull request as ready for review September 10, 2026 17:07
@apcha-oai
apcha-oai requested a review from a team as a code owner September 10, 2026 17:07
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Castiron custom code

Mixed files: 36 → 41

5 newly customized · 0 customizations removed · 0 existing customizations changed · 7 generated baselines changed

Compared 802b334928d8 → d3557967abc8. Generated baselines verified.

File Result Current custom patch
api.md Generated baseline changed +105 / −0
scripts/castiron/test_custom_code_report.py Generated baseline changed +344 / −32
src/openai/init.py Generated baseline changed +152 / −1
src/openai/_client.py Generated baseline changed +749 / −60
src/openai/resources/live/forks.py Newly customized +1 / −1
src/openai/resources/live/live.py Newly customized +1 / −1
src/openai/resources/live/sideband.py Newly customized +1 / −1
src/openai/types/webhooks/init.py Generated baseline changed +6 / −1
src/openai/types/webhooks/live_call_incoming_webhook_event.py Generated baseline changed +2 / −1
src/openai/types/webhooks/unwrap_webhook_event.py Generated baseline changed +2 / −2
31 existing customizations unchanged
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • src/openai/resources/audio/transcriptions.py
  • src/openai/resources/audio/translations.py
  • src/openai/resources/beta/beta.py
  • src/openai/resources/beta/responses/responses.py
  • src/openai/resources/beta/threads/runs/runs.py
  • src/openai/resources/beta/threads/threads.py
  • src/openai/resources/chat/completions/completions.py
  • src/openai/resources/embeddings.py
  • src/openai/resources/files.py
  • src/openai/resources/realtime/realtime.py
  • src/openai/resources/responses/responses.py
  • src/openai/resources/uploads/uploads.py
  • src/openai/resources/vector_stores/file_batches.py
  • src/openai/resources/vector_stores/files.py
  • src/openai/resources/videos.py
  • src/openai/resources/webhooks/init.py
  • src/openai/resources/webhooks/webhooks.py
  • src/openai/types/chat/init.py
  • src/openai/types/chat/chat_completion_message_tool_call.py
  • src/openai/types/fine_tuning/fine_tuning_job_integration.py
  • src/openai/types/responses/init.py
  • src/openai/types/responses/response.py
  • src/openai/types/responses/response_function_web_search.py
  • src/openai/types/responses/response_function_web_search_param.py
  • src/openai/types/responses/responses_client_event.py
  • src/openai/types/responses/responses_client_event_param.py
  • src/openai/types/responses/tool.py
  • src/openai/types/responses/tool_param.py
  • tests/api_resources/test_videos.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 34506356297 --repo openai/openai-python \
  --name castiron-custom-code-34506356297-1 --dir /tmp/castiron-custom-code-34506356297-1
git apply --stat /tmp/castiron-custom-code-34506356297-1/custom-code.patch
cat /tmp/castiron-custom-code-34506356297-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 802b334928d8f0c3e24e5fce15a0eaa1b28c61cd d3557967abc8c99100bc10838849cfb9be957c4b
python3 scripts/castiron/custom_code_report.py report \
  --base 802b334928d8f0c3e24e5fce15a0eaa1b28c61cd \
  --head d3557967abc8c99100bc10838849cfb9be957c4b --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-d3557967abc8
cat /tmp/castiron-custom-code-d3557967abc8/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T17:24:58.286784Z d355796 Draft marked ready
🔒 Security Review ✅ Completed 2026-09-10T17:19:58.568919Z d355796 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openai-sdks

openai-sdks Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

OkTest Summary

✅ 236/236 SDK tests passed in 12.149s for Python SDK PR #3846.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 172ms
tests/chat-completions-create.test.ts ✅ Passed 284ms
tests/chat-completions-stream.test.ts ✅ Passed 240ms
tests/files-content-binary.test.ts ✅ Passed 258ms
tests/files-create-multipart.test.ts ✅ Passed 217ms
tests/files-list-pagination.test.ts ✅ Passed 159ms
tests/initialize-config.test.ts ✅ Passed 172ms
tests/instance-isolation.test.ts ✅ Passed 209ms
tests/models-list.test.ts ✅ Passed 273ms
tests/responses-background-lifecycle.test.ts ✅ Passed 221ms
tests/responses-body-method-errors.test.ts ✅ Passed 312ms
tests/responses-cancel-timeout.test.ts ✅ Passed 221ms
tests/responses-cancel.test.ts ✅ Passed 233ms
tests/responses-compact-retries.test.ts ✅ Passed 321ms
tests/responses-compact.test.ts ✅ Passed 312ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 141ms
tests/responses-create-advanced.test.ts ✅ Passed 237ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.179s
tests/responses-create-errors.test.ts ✅ Passed 175ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 528ms
tests/responses-create-retries.test.ts ✅ Passed 276ms
tests/responses-create-stream-failures.test.ts ✅ Passed 220ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 212ms
tests/responses-create-stream-wire.test.ts ✅ Passed 3.966s
tests/responses-create-stream.test.ts ✅ Passed 326ms
tests/responses-create-terminal-states.test.ts ✅ Passed 242ms
tests/responses-create-timeout.test.ts ✅ Passed 260ms
tests/responses-create.test.ts ✅ Passed 374ms
tests/responses-delete.test.ts ✅ Passed 232ms
tests/responses-input-items-errors.test.ts ✅ Passed 475ms
tests/responses-input-items-list.test.ts ✅ Passed 438ms
tests/responses-input-items-options.test.ts ✅ Passed 308ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 258ms
tests/responses-input-tokens-count.test.ts ✅ Passed 347ms
tests/responses-malformed-inputs.test.ts ✅ Passed 3s
tests/responses-not-found-errors.test.ts ✅ Passed 287ms
tests/responses-parse.test.ts ✅ Passed 571ms
tests/responses-retrieve-retries.test.ts ✅ Passed 265ms
tests/responses-retrieve.test.ts ✅ Passed 329ms
tests/responses-stored-method-errors.test.ts ✅ Passed 530ms
tests/retry-behavior.test.ts ✅ Passed 3.187s
tests/sdk-error-shape.test.ts ✅ Passed 284ms

View OkTest run #34506314544

SDK merge (11de4258c5bd) · head (d3557967abc8) · base (802b334928d8) · OkTest (08ec4299e769)

with sync:
sync.push(text())
raise ValueError("body")
assert sync._state.closed

chat: Chat = ChatProxy().__as_proxied__()
beta: Beta = BetaProxy().__as_proxied__()
live: Live = LiveProxy().__as_proxied__()
self._listeners_lock = threading.Lock()

@overload
def on(self, event_type: Literal["segment.updated"], handler: Callable[[TranscriptSegment], _ReturnT]) -> Self: ...
@overload
def on(
self, event_type: Literal["segment.closed"], handler: Callable[[TranscriptSegmentClosedEvent], _ReturnT]
) -> Self: ...
@overload
def on(
self, event_type: Literal["segment.updated"]
) -> Callable[[Callable[[TranscriptSegment], _ReturnT]], Callable[[TranscriptSegment], _ReturnT]]: ...
self, event_type: Literal["segment.closed"]
) -> Callable[
[Callable[[TranscriptSegmentClosedEvent], _ReturnT]], Callable[[TranscriptSegmentClosedEvent], _ReturnT]
]: ...
@overload
def once(
self, event_type: Literal["segment.updated"], handler: Callable[[TranscriptSegment], _ReturnT]
) -> Self: ...
@overload
def once(
self, event_type: Literal["segment.closed"], handler: Callable[[TranscriptSegmentClosedEvent], _ReturnT]
) -> Self: ...
@overload
def once(
self, event_type: Literal["segment.updated"]
) -> Callable[[Callable[[TranscriptSegment], _ReturnT]], Callable[[TranscriptSegment], _ReturnT]]: ...
self, event_type: Literal["segment.closed"]
) -> Callable[
[Callable[[TranscriptSegmentClosedEvent], _ReturnT]], Callable[[TranscriptSegmentClosedEvent], _ReturnT]
]: ...
@apcha-oai
apcha-oai merged commit 0e4bfef into main Sep 10, 2026
28 checks passed
@apcha-oai
apcha-oai deleted the castiron/promotions/pr-83 branch September 10, 2026 17:10
@apcha-oai apcha-oai changed the title feat(api) Add Live API feat(api): Add Live API Sep 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3557967ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

then you can call `.parse_event(data)`.
"""
message = await self._connection.recv(decode=False)
log.debug(f"Received WebSocket message: %s", message)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop logging raw Live messages

When debug logging is enabled, every incoming frame is written verbatim, including user transcripts, reflected input audio, generated audio, and potentially sensitive response payloads. The same logging is duplicated in the sync, sideband, and fork connections, so these messages can persist customer data in application logs; log only sanitized metadata such as the event type.

AGENTS.md reference: AGENTS.md:L26-L30

Useful? React with 👍 / 👎.

},
extra_headers,
),
**self.__websocket_connection_options,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Disable the WebSocket library's default message cap

When callers use the default connection options, this delegates to websockets without overriding its 1 MiB max_size, so a legitimate larger Live JSON or streaming event causes the transport to close with code 1009 before recv() can return it. The sync, sideband, and fork connection paths have the same default; supply max_size=None unless explicitly overridden, or otherwise process large messages without imposing a fixed rejection limit.

AGENTS.md reference: AGENTS.md:L114-L120

Useful? React with 👍 / 👎.

SessionClosedEvent,
ErrorEvent,
InfoEvent,
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include sideband-only events in ConnectServerEvent

For a sideband connection, the server can emit session.input_audio.append and the transport.dtmf.*, transport.ringing, transport.answered, and transport.failed events, but this union ends without those variants even though SidebandConnection.parse_event() uses it. Because loose union construction falls back to the first variant for an unknown discriminator, such an event can be returned as a malformed SessionStartedEvent rather than its actual typed model, breaking isinstance dispatch and typed access to fields such as audio or event.

Useful? React with 👍 / 👎.

class AudioPCMU(TypedDict, total=False):
"""Raw, mono G.711 μ-law audio for a Live WebSocket connection."""

rate: Required[int]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict G.711 sample rates to 8000 Hz

For callers configuring a primary Live WebSocket with PCMU or PCMA audio, these request types accept any integer even though the API contract and adjacent documentation allow only 8000 Hz; for example, a type-checked {"type": "audio/pcmu", "rate": 16000} request is serialized normally and then rejected by the server. Model the rate field as Literal[8000] for both G.711 variants, as is already done for the supported PCM rates.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant