Skip to content

Commit 7debb98

Browse files
Pablo Vitassoclaude
andcommitted
fix(api): add undici fetch wrapper for localhost connections
Fixes connection issues with localhost API providers on Node.js 20+ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 275e992 commit 7debb98

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/api/providers/base-openai-compatible-provider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import OpenAI from "openai"
33

44
import type { ModelInfo } from "@klaus-code/types"
55

6+
// Install undici-based fetch wrapper when using OpenAI-compatible providers
7+
// This fixes connection issues with localhost on Node.js 20+
8+
import { installUndisciFetchWrapper } from "../utils/undici-fetch-wrapper"
9+
installUndisciFetchWrapper()
10+
611
import { type ApiHandlerOptions, getModelMaxOutputTokens } from "../../shared/api"
712
import { TagMatcher } from "../../utils/tag-matcher"
813
import { ApiStream, ApiStreamUsageChunk } from "../transform/stream"

src/api/providers/router-provider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import OpenAI from "openai"
22

33
import { type ModelInfo, type ModelRecord } from "@klaus-code/types"
44

5+
// Install undici-based fetch wrapper when using router-based providers
6+
// This fixes connection issues with localhost on Node.js 20+
7+
import { installUndisciFetchWrapper } from "../utils/undici-fetch-wrapper"
8+
installUndisciFetchWrapper()
9+
510
import { ApiHandlerOptions, RouterName } from "../../shared/api"
611

712
import { BaseProvider } from "./base-provider"

0 commit comments

Comments
 (0)