Skip to content

feat: add openai responses api capability #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/(chat)/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { getWeather } from '@/lib/ai/tools/get-weather';
import { isProductionEnvironment } from '@/lib/constants';
import { NextResponse } from 'next/server';
import { myProvider } from '@/lib/ai/providers';
import { openai } from '@ai-sdk/openai';

export const maxDuration = 60;

Expand Down Expand Up @@ -85,6 +86,7 @@ export async function POST(request: Request) {
'createDocument',
'updateDocument',
'requestSuggestions',
'webSearchPreview'
],
experimental_transform: smoothStream({ chunking: 'word' }),
experimental_generateMessageId: generateUUID,
Expand All @@ -96,6 +98,14 @@ export async function POST(request: Request) {
session,
dataStream,
}),
webSearchPreview: openai.tools.webSearchPreview({
searchContextSize: 'medium'
})
},
providerOptions: {
openai: {
store: false,
}
},
onFinish: async ({ response, reasoning }) => {
if (session.user?.id) {
Expand Down Expand Up @@ -134,7 +144,7 @@ export async function POST(request: Request) {
});
},
onError: () => {
return 'Oops, an error occured!';
return 'Oops, an error occurred!';
},
});
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions lib/ai/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const myProvider = isTestEnvironment
})
: customProvider({
languageModels: {
'chat-model-small': openai('gpt-4o-mini'),
'chat-model-large': openai('gpt-4o'),
'chat-model-small': openai.responses('gpt-4o-mini'),
'chat-model-large': openai.responses('gpt-4o'),
'chat-model-reasoning': wrapLanguageModel({
model: fireworks('accounts/fireworks/models/deepseek-r1'),
middleware: extractReasoningMiddleware({ tagName: 'think' }),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@ai-sdk/fireworks": "0.1.12",
"@ai-sdk/openai": "1.2.0",
"@ai-sdk/openai": "1.2.2",
"@ai-sdk/react": "^1.1.20",
"@codemirror/lang-javascript": "^6.2.2",
"@codemirror/lang-python": "^6.1.6",
Expand All @@ -40,7 +40,7 @@
"@vercel/analytics": "^1.3.1",
"@vercel/blob": "^0.24.1",
"@vercel/postgres": "^0.10.0",
"ai": "4.1.50",
"ai": "4.1.54",
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Package update to [email protected]

This update from 4.1.50 to 4.1.54 is required to support the OpenAI Responses API implementation. The PR comments indicate this adds 14 new transitive dependencies, which is expected for this feature addition.


🏁 Script executed:

#!/bin/bash
# Verify the compatibility of these packages by checking their latest versions
echo "Checking latest versions of @ai-sdk/openai and ai packages..."
npm view @ai-sdk/openai version
npm view ai version

Length of output: 202


Update ai dependency to the latest published version (4.3.10)
npm registry shows that ai@4.1.54 is two minor releases behind—the current latest is 4.3.10. To pick up bug fixes and improvements beyond the OpenAI Responses API support, please bump the version.

  • File: package.json (line 43)
  • Diff suggestion:
-   "ai": "4.1.54",
+   "ai": "^4.3.10",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"ai": "4.1.54",
"ai": "^4.3.10",

"bcrypt-ts": "^5.0.2",
"class-variance-authority": "^0.7.0",
"classnames": "^2.5.1",
Expand Down
97 changes: 81 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.