-
Notifications
You must be signed in to change notification settings - Fork 4.5k
POST: /api/chat doesn't reply. #907
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
Comments
I ran into the same thing. The app/(chat)/api/chat/route.ts is eating the meaningful error, if you add:
you'll see what the problem is. For me, it was I didn't have |
I got a xAI api key and set it in local.env. how to validate that api key? |
Set a breakpoint on that exception or add debug message shown above to validate / rule out an invalid key. |
Running into the same issue. |
You need credits on xAI API key. |
How to get credits on xAI API key? I have already got a xAI_API_KEY in https://console.x.ai/. |
You mean that I should use google or deepseek api key, not a xAi key? |
Most of the other providers are fairly generous with their free tiers so you don't have to get into paying. Here's a diff of changes I made to providers.ts and the package.json to switch this code template back to OpenAI. (If you aren't familiar with this diff format then just give this to your LLM and it will help you understand it, validate it, and apply it.) diff --git a/lib/ai/providers.ts b/lib/ai/providers.ts
index 810c329..c10b211 100644
--- a/lib/ai/providers.ts
+++ b/lib/ai/providers.ts
@@ -3,7 +3,7 @@ import {
extractReasoningMiddleware,
wrapLanguageModel,
} from 'ai';
-import { xai } from '@ai-sdk/xai';
+import { openai } from '@ai-sdk/openai';
import { isTestEnvironment } from '../constants';
import {
artifactModel,
@@ -23,15 +23,16 @@ export const myProvider = isTestEnvironment
})
: customProvider({
languageModels: {
- 'chat-model': xai('grok-2-1212'),
+ 'chat-model': openai('gpt-4o-mini'),
'chat-model-reasoning': wrapLanguageModel({
- model: xai('grok-3-mini-beta'),
+ model: openai('o3-mini'),
middleware: extractReasoningMiddleware({ tagName: 'think' }),
}),
- 'title-model': xai('grok-2-1212'),
- 'artifact-model': xai('grok-2-1212'),
+ 'title-model': openai('o3-mini'),
+ 'artifact-model': openai('o3-mini'),
},
imageModels: {
- 'small-model': xai.image('grok-2-image'),
+ 'small-model': openai.image('dall-e-2'),
+ 'large-model': openai.image('dall-e-3'),
},
});
diff --git a/package.json b/package.json
index a48d3e3..6236ef9 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,7 @@
},
"dependencies": {
"@ai-sdk/react": "^1.2.8",
- "@ai-sdk/xai": "^1.2.10",
+ "@ai-sdk/openai": "^1.3.10",
"@codemirror/lang-javascript": "^6.2.2",
"@codemirror/lang-python": "^6.1.6",
"@codemirror/state": "^6.5.0",
@@ -104,4 +104,4 @@
"typescript": "^5.6.3"
},
"packageManager": "pnpm@9.12.3"
-}
+} |
Also... they need to update their documentation... |
you can add console.error at https://github.com/vercel/ai-chatbot/blob/main/app/(chat)/api/chat/route.ts#L223 ![]() ![]() |
I forked project in local and set all environment variables. but it occurs error while sending message. What's wrong?
The text was updated successfully, but these errors were encountered: