Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

connectOpenAi fails with `server_error code 42` on 0.4.2

未關閉
#321 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
node.js, typescript

研究方向

從 TypeScript 的 connectOpenAi 呼叫開始,使用列出的 SDK 版本追蹤其請求到 Stream 的 /video/connect_agent 端點。使用提供的 webhook 流程重現,並將傳遞出的 code 42 錯誤與直接的 OpenAI Realtime 連線進行比較。完成標準是:同一個有效金鑰可以在沒有不透明伺服器錯誤的情況下,將 agent 連線到 Stream Video 通話。

由索引模型根據 Issue 內容生成。

描述

Summary

stream.video.connectOpenAi(...) consistently fails with server_error code 42 when connecting an OpenAI Realtime agent to a call. I have isolated the cause: the same OpenAI API key connects directly to OpenAI's GA Realtime API without error, so the key/account/access are fine. I guess the failure is still inside Stream's /video/connect_agent → OpenAI path.

Bumping to 0.4.2 (as advised on my previous, now-closed ticket) did not change the result.

What I'm trying to do

Connect an OpenAI Realtime (speech-to-speech) agent to a Stream Video call so it joins as a participant and talks. It's triggered server-side from the call.session_started webhook: look up the meeting/agent, then call connectOpenAi.

const call = stream.video.call("default", meetingId);
const client = await stream.video.connectOpenAi({
  call,
  openAiApiKey: process.env.OPENAI_API_KEY, // sk-proj-36XU_...
  agentUserId: agent.id,
});
client.updateSession({ instructions });

No model is passed, so it defaults to gpt-realtime (GA).

Environment

  • @stream-io/node-sdk: 0.7.62
  • @stream-io/openai-realtime-api: 0.4.2
  • @stream-io/video-react-sdk: 1.39.1 (client)
  • Next.js: 16.2.10

What's failing

connectOpenAi rejects. The client only surfaces the opaque code 42:

Error: Stream connect_agent failed (code 42): Error:  code
{
  type: 'error',
  error: { type: 'server_error', code: '42', message: 'Error:  code ', param: null, event_id: '' }
}

The webhook itself is fine, signature verification passes (HTTP 200 via verifyAndParseWebhook on the raw gzipped body); the 500 comes solely from connectOpenAi.

Timeline

  1. On @stream-io/[email protected] → code 42.
  2. Support (previous ticket) said bump to 0.4.2; the ticket was closed.
  3. Bumped to 0.4.2 → still code 42, model set or unset.

Checks performed (ruling out my side)

  • API key is loaded in the route: confirmed sk-proj-36XU_..., not undefined.
  • Account: paid tier with credit.
  • Model: default gpt-realtime (GA).
  • Agent user: upserted via stream.upsertUsers([...]) at meeting creation, so the agentUserId exists as a Stream user on the call.

Decisive test: same key connects to OpenAI directly

I connected to OpenAI's GA Realtime API directly with the exact same OPENAI_API_KEY:

new WebSocket("wss://api.openai.com/v1/realtime?model=gpt-realtime", {
  headers: { Authorization: `Bearer ${OPENAI_API_KEY}` }
});

Result: WebSocket opens cleanly, no error. So the key, its Realtime access, org verification, and tier are all confirmed working outside Stream.

Conclusion

This concluded that my OpenAI credentials/access were not the problem. Should probably be coming from Stream's connect_agent backend.

Error

⨯ Error: Stream connect_agent failed (code 42): Error:  code
    at ignore-listed frames {
  type: 'error',
  error: {
    type: 'server_error',
    code: '42',
    message: 'Error:  code ',
    param: null,
    event_id: ''
  }
}
 POST /api/webhook/stream 500 in 2.0s (next.js: 121ms, proxy.ts: 11ms, application-code: 1886ms)
 POST /api/webhook/stream 200 in 514ms (next.js: 4ms, proxy.ts: 9ms, application-code: 501ms)
 ......
⨯ Error: Stream connect_agent failed (code 42): Error:  code
    at ignore-listed frames {
  type: 'error',
  error: {
    type: 'server_error',
    code: '42',
    message: 'Error:  code ',
    param: null,
    event_id: ''
  }
}
主要語言
TypeScript
星號
19
分支
4
平均合併
22 小時 29 分鐘
30 天內合併 PR
15

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

GetStream/stream-node 的其他 Issue

查看 GetStream/stream-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。