Skip to content

feat(api): support backend-mediated Realtime WebRTC calls - #2469

Merged
apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-79
Aug 25, 2026
Merged

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

Conversation

@apcha-oai

Copy link
Copy Markdown
Contributor

Summary

Add client.realtime.calls.create so server-side applications can exchange an SDP offer and optional session configuration for an SDP answer.

This makes WebRTC signaling available through the SDK instead of requiring a handwritten HTTP request. The request preserves the API’s SDP and JSON content types, and the returned Response exposes the SDP answer for the browser.

Castiron-Internal-PR: openai/openai-node-internal#79
Castiron-Source-SHA: 2871e2b19388f9a0ec13476d3ee31eeac98ec458
Castiron-Public-Base-SHA: a90581e
@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

32 mixed files remain; 0 existing customizations changed.

Compared a90581ed85f2 → 0917b92069c7. Generated baselines verified.

32 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/client.ts
  • src/resources/audio/transcriptions.ts
  • src/resources/audio/translations.ts
  • src/resources/beta/assistants.ts
  • src/resources/beta/beta.ts
  • src/resources/beta/index.ts
  • src/resources/beta/responses/internal-base.ts
  • src/resources/beta/responses/responses.ts
  • src/resources/beta/threads/index.ts
  • src/resources/beta/threads/runs/index.ts
  • src/resources/beta/threads/runs/runs.ts
  • src/resources/beta/threads/threads.ts
  • src/resources/chat/completions/completions.ts
  • src/resources/chat/completions/index.ts
  • src/resources/conversations/index.ts
  • src/resources/embeddings.ts
  • src/resources/files.ts
  • src/resources/fine-tuning/checkpoints/permissions.ts
  • src/resources/images.ts
  • src/resources/responses/internal-base.ts
  • src/resources/responses/responses.ts
  • src/resources/skills/skills.ts
  • src/resources/skills/versions/versions.ts
  • src/resources/vector-stores/file-batches.ts
  • src/resources/vector-stores/files.ts
  • src/resources/webhooks/index.ts
  • src/resources/webhooks/webhooks.ts
  • tests/lib/data-residency.test.ts

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 32890174854 --repo openai/openai-node \
  --name castiron-custom-code-32890174854-1 --dir /tmp/castiron-custom-code-32890174854-1
git apply --stat /tmp/castiron-custom-code-32890174854-1/custom-code.patch
cat /tmp/castiron-custom-code-32890174854-1/custom-code.patch

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

git fetch --no-tags origin a90581ed85f236a2440102fe64320f1831844b50 0917b92069c79776fa847331b43131f711245683
python3 scripts/castiron/custom_code_report.py report \
  --base a90581ed85f236a2440102fe64320f1831844b50 \
  --head 0917b92069c79776fa847331b43131f711245683 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-0917b92069c7
cat /tmp/castiron-custom-code-0917b92069c7/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

describe('resource calls', () => {
// binary tests are currently broken
test.skip('create: required and optional params', async () => {
const response = await client.realtime.calls.create({
@apcha-oai
apcha-oai marked this pull request as ready for review August 25, 2026 19:32
@apcha-oai
apcha-oai requested a review from a team as a code owner August 25, 2026 19:32
@apcha-oai
apcha-oai enabled auto-merge August 25, 2026 19:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 25, 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-08-25T19:35:01.108889Z 0917b92 Draft marked ready
🔒 Security Review ✅ Completed 2026-08-25T19:35:09.113203Z 0917b92 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 Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

OkTest Summary

✅ 237/237 SDK tests passed in 9.047s for Node SDK PR #2469.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 130ms
tests/chat-completions-create.test.ts ✅ Passed 163ms
tests/chat-completions-stream.test.ts ✅ Passed 158ms
tests/files-content-binary.test.ts ✅ Passed 138ms
tests/files-create-multipart.test.ts ✅ Passed 120ms
tests/files-list-pagination.test.ts ✅ Passed 146ms
tests/initialize-config.test.ts ✅ Passed 118ms
tests/instance-isolation.test.ts ✅ Passed 83ms
tests/models-list.test.ts ✅ Passed 104ms
tests/responses-background-lifecycle.test.ts ✅ Passed 194ms
tests/responses-body-method-errors.test.ts ✅ Passed 263ms
tests/responses-cancel-timeout.test.ts ✅ Passed 221ms
tests/responses-cancel.test.ts ✅ Passed 168ms
tests/responses-compact-retries.test.ts ✅ Passed 168ms
tests/responses-compact.test.ts ✅ Passed 165ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 61ms
tests/responses-create-advanced.test.ts ✅ Passed 127ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.067s
tests/responses-create-errors.test.ts ✅ Passed 168ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 156ms
tests/responses-create-retries.test.ts ✅ Passed 285ms
tests/responses-create-stream-failures.test.ts ✅ Passed 150ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.169s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.201s
tests/responses-create-stream.test.ts ✅ Passed 76ms
tests/responses-create-terminal-states.test.ts ✅ Passed 206ms
tests/responses-create-timeout.test.ts ✅ Passed 221ms
tests/responses-create.test.ts ✅ Passed 109ms
tests/responses-delete.test.ts ✅ Passed 94ms
tests/responses-input-items-errors.test.ts ✅ Passed 159ms
tests/responses-input-items-list.test.ts ✅ Passed 216ms
tests/responses-input-items-options.test.ts ✅ Passed 86ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 199ms
tests/responses-input-tokens-count.test.ts ✅ Passed 176ms
tests/responses-malformed-inputs.test.ts ✅ Passed 1.814s
tests/responses-not-found-errors.test.ts ✅ Passed 245ms
tests/responses-parse.test.ts ✅ Passed 135ms
tests/responses-retrieve-retries.test.ts ✅ Passed 250ms
tests/responses-retrieve.test.ts ✅ Passed 170ms
tests/responses-stored-method-errors.test.ts ✅ Passed 474ms
tests/retry-behavior.test.ts ✅ Passed 3.023s
tests/sdk-error-shape.test.ts ✅ Passed 266ms

View OkTest run #32890145802

SDK merge (08d952a31239) · head (0917b92069c7) · base (a90581ed85f2) · OkTest (2b1bdfd25e98)

@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: 0917b92069

ℹ️ 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".

Comment on lines +19 to +21
rawBodyField !== null &&
Object.keys(body).length === 1 &&
Object.prototype.hasOwnProperty.call(body, rawBodyField)

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 Keep project-API-key SDP calls multipart

When a caller uses a normal project API key and omits the optional session field—as in the new create({ sdp }) JSDoc example—this condition switches the request to raw application/sdp. The checked-in schema at api_reference/openapi.transformed.yml:16013-16019 reserves that alternative for authentication with a previously created ephemeral session token, whereas the multipart schema permits an omitted session. The ordinary minimal SDK call is therefore sent in the wrong authentication mode; default it to multipart or require an explicit raw/ephemeral selection instead of inferring the mode from object cardinality.

AGENTS.md reference: AGENTS.md:L12-L21

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked this against the live API with a normal project API key (not an ephemeral token). The proposed authentication restriction does not match the observed behavior: raw application/sdp works with project-key authentication.

With a valid WebRTC offer saved as offer.sdp and a project key in OPENAI_API_KEY, these requests both omit session:

# Raw SDP: 201 Created, SDP answer, and Location header.
curl -i 'https://api.openai.com/v1/realtime/calls?model=gpt-realtime' \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H 'Content-Type: application/sdp' \
  --data-binary @offer.sdp

# Multipart with only an SDP part: same successful result.
curl -i 'https://api.openai.com/v1/realtime/calls?model=gpt-realtime' \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -F 'sdp=<offer.sdp;type=application/sdp'

Repeating both requests without ?model=gpt-realtime produces the same 400 / missing_model error:

Format, session omitted No model Query model supplied
Raw SDP 400 missing_model 201 Created
Multipart 400 missing_model 201 Created

The successful test calls were hung up afterward. To clean up a reproduction, POST to the call's Location URL with /hangup appended, using the same authorization.

So the minimal project-key example needs a model; changing its encoding to multipart does not fix that. The schema's ephemeral-token guidance should not be interpreted as an exclusive authentication requirement.

The JSDoc example is incomplete for project-key use because it supplies neither session configuration nor a query model. That is a documentation issue, not evidence that the raw request uses the wrong authentication mode. I don't think this finding warrants changing the encoder or adding an explicit ephemeral-auth selection.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes for the existing P1 discussion at src/internal/multipart-encoding.ts:21. The documented minimal client.realtime.calls.create({ sdp }) with a normal project API key is encoded as raw application/sdp merely because optional session is absent. The checked-in API schema reserves the raw SDP alternative for an existing ephemeral session token; ordinary project-key backend calls must remain multipart even when session configuration is omitted. Default to typed multipart and expose raw SDP only for an explicitly selected ephemeral-auth flow. Existing inline discussion already captures this blocker.

@apcha-oai
apcha-oai added this pull request to the merge queue Aug 25, 2026
Merged via the queue into main with commit 0d12ca8 Aug 25, 2026
54 checks passed
@apcha-oai
apcha-oai deleted the castiron/promotions/pr-79 branch August 25, 2026 20:36
@openai-sdks openai-sdks Bot mentioned this pull request Aug 25, 2026
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.

2 participants