MCPcopy Index your code
hub / github.com/TanStack/ai / extractRequestOptions

Function extractRequestOptions

packages/openai-base/src/utils/request-options.ts:11–24  ·  view source on GitHub ↗
(
  request: Request | RequestInit | undefined,
)

Source from the content-addressed store, hash-verified

9 * `expect.objectContaining()` keep working when no request override was set.
10 */
11export function extractRequestOptions(
12 request: Request | RequestInit | undefined,
13): { headers?: HeadersInit; signal?: AbortSignal | null } {
14 if (!request) return {}
15 // Conditional spread: under exactOptionalPropertyTypes the target's
16 // `headers?: HeadersInit` and `signal?: AbortSignal | null` forbid an
17 // explicit `undefined`. Omit the keys entirely when the source values
18 // are absent so the OpenAI SDK sees `headers: undefined` as "not set"
19 // rather than a present-but-undefined value.
20 return {
21 ...(request.headers !== undefined && { headers: request.headers }),
22 ...(request.signal != null && { signal: request.signal }),
23 }
24}

Callers 6

chatStreamFunction · 0.90
structuredOutputFunction · 0.90
structuredOutputStreamFunction · 0.90
chatStreamFunction · 0.90
structuredOutputFunction · 0.90
structuredOutputStreamFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected