Skip to content

Conversation

@kwhinnery-openai
Copy link
Contributor

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

  • Need to export WebSocket client for JSR / Deno!

Additional context & links

https://jsr.io/docs/package-configuration#exports

@kwhinnery-openai kwhinnery-openai requested a review from a team as a code owner January 17, 2025 21:12
@kwhinnery-openai
Copy link
Contributor Author

This should work but currently does not - this PR should fix.

// import { OpenAIRealtimeWebSocket } from "openai/beta/realtime/websocket";
import { OpenAIRealtimeWebSocket } from "jsr:@openai/openai/beta/realtime/websocket";

const rt = new OpenAIRealtimeWebSocket({
  model: "gpt-4o-realtime-preview-2024-12-17",
});

rt.socket.addEventListener("open", () => {
  rt.send({ type: "session.update", session: { modalities: ["text"] } });

  rt.send({
    type: "conversation.item.create",
    item: {
      type: "message",
      role: "user",
      content: [{
        type: "input_text",
        text: "Tell me a three sentence bedtime story about a unicorn.",
      }],
    },
  });

  rt.send({ type: "response.create" });
});

rt.on("response.text.delta", (event) => process.stdout.write(event.delta));
rt.on("response.done", () => rt.close());

Copy link

@Lupie Lupie left a comment

Choose a reason for hiding this comment

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

sure

@kwhinnery-openai kwhinnery-openai merged commit 9e669fa into master Jan 21, 2025
3 checks passed
SkinnnyJay pushed a commit to SkinnnyJay/openai-node that referenced this pull request Sep 13, 2025
Create export for WebSocket on Deno/JSR
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.

4 participants