New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ai-sdk-openai-websocket-fetch

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai-sdk-openai-websocket-fetch

WebSocket transport for the AI SDK OpenAI provider — drop-in fetch replacement that routes streaming requests through a persistent WebSocket connection.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
28K
28.24%
Maintainers
1
Weekly downloads
 
Created
Source

ai-sdk-openai-websocket-fetch

Drop-in fetch replacement that routes OpenAI Responses API streaming requests through a persistent WebSocket connection instead of HTTP.

Installation

npm install ai-sdk-openai-websocket-fetch

Usage

import { streamText } from 'ai';
import { createOpenAI } from '@ai-sdk/openai';
import { createWebSocketFetch } from 'ai-sdk-openai-websocket-fetch';

const wsFetch = createWebSocketFetch();
const openai = createOpenAI({ fetch: wsFetch });

const result = streamText({
  model: openai('gpt-4.1-mini'),
  prompt: 'Hello!',
  onFinish: () => wsFetch.close(),
});

Why?

OpenAI's WebSocket API keeps a persistent connection open. After the initial handshake, subsequent requests skip TCP/TLS/HTTP negotiation entirely — reducing TTFB in multi-step agentic workflows where the model makes many tool calls.

License

MIT

Keywords

ai-sdk

FAQs

Package last updated on 23 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts