From 425478cee167c9feb591e96d87cfc6a522f1e8a9 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Fri, 20 Mar 2026 16:44:06 -0700 Subject: [PATCH] Feat: Add :online web search support for OpenAI --- providers.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/providers.js b/providers.js index 733fecb..83c7d4e 100644 --- a/providers.js +++ b/providers.js @@ -105,8 +105,11 @@ export async function streamOpenRouter({ apiKey, body, signal, onDelta, isRunnin export async function streamOpenAI({ apiKey, body, signal, onDelta, isRunning }) { const client = new OpenAI({ apiKey }) + const online = (body.model ?? '').endsWith(':online') + const model = online ? body.model.slice(0, -7) : body.model + const params = { - model: body.model, + model, input: buildInputForResponses(body.messages || []), temperature: body.temperature, stream: true, @@ -116,6 +119,13 @@ export async function streamOpenAI({ apiKey, body, signal, onDelta, isRunning }) if (body.reasoning?.effort) params.reasoning = { effort: body.reasoning.effort } if (body.verbosity) params.text = { verbosity: body.verbosity } + if (online) { + params.tools = [ + ...(params.tools || []), + { type: 'web_search', external_web_access: true }, + ] + } + const stream = await client.responses.stream(params) try { for await (const event of stream) { @@ -243,4 +253,3 @@ export async function streamGoogle({ apiKey, body, signal, onDelta, isRunning }) buf = buf.slice(buf.lastIndexOf('\n') + 1) } } -