help needed in linking vercel ai #8361
-
hello everyone, vansh here from cargocorp logistics. we are creating our personalized invoicing desktop app, and want to use vercel ai in our software. can anyone guide me how can i do that? our tech stack is: thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I suggest you go through the docs to get a better understanding, but the process is quite simple. Here is the link to the documentation: Vercel AI Docs. Here’s a basic outline of the steps:
npm install @ai-sdk/openai
import { openai } from '@ai-sdk/openai'; If you want to customize it (optional), you can create your own instance: import { createOpenAI } from '@ai-sdk/openai';
const openai = createOpenAI({
// Custom settings, e.g.
headers: {
'header-name': 'header-value',
},
});
Import the import { generateText } from 'ai'; Use it like this: const { text } = await generateText({
model: openai('gpt-5'), // Select the model
prompt: 'Write your prompt here', // Your prompt
});
Here’s a simple example of an API endpoint to get responses from the AI: // pages/api/generate.js
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
export default async function handler(req, res) {
const { prompt } = req.body;
const { text } = await generateText({
model: openai('gpt-5'),
prompt,
});
res.status(200).json({ text });
} You can pass additional parameters to I hope this helps!
|
Beta Was this translation helpful? Give feedback.
I suggest you go through the docs to get a better understanding, but the process is quite simple. Here is the link to the documentation: Vercel AI Docs.
Here’s a basic outline of the steps:
If you want to customize it (optional), you can create your own instance:
Import the
generateText
function:Use it like this:
const