WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Discussion options

You must be logged in to vote

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:

  1. Install the Vercel AI SDK
npm install @ai-sdk/openai
  1. Import the predefined provider instance
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',
  },
});
  1. Create an endpoint to generate responses

Import the generateText function:

import { generateText } from 'ai';

Use it like this:

const 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by gr2m
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants