-
Clone the repository:
git clone <repository_url> cd examples/qa-mode/openai-node-sdk
-
Install the dependencies:
npm install
- Node.js v22.3.0 or higher
- npm (Node Package Manager)
This is an example project demonstrating the use of the OpenAI Node SDK with TypeScript.
-
Set your OpenAI API key in
index.ts
:const client = new OpenAI({ baseURL: "https://api.inkeep.com/v1/", apiKey: "YOUR_API_KEY", // dangerouslyAllowBrowser: true, // use this setting if you are using this in browser });
-
Run the project:
npm start
This is an example project demonstrating the use of the Vercel AI SDK with TypeScript.
-
Set your OpenAI API key in
index.ts
:const openai = createOpenAI({ baseURL: "https://api.inkeep.com/v1/", apiKey: "YOUR_API_KEY", });
-
Run the project:
npm start
The qa
models are specifically tailored for customer-facing support bot scenarios. More information in our docs.
index.ts
: Main entry point of the application. It demonstrates how to use the OpenAI Node SDK to create a chat completion and handle tools.LinksToolSchema.ts
: Contains Zod schemas used for validating data structures.
Open localhost:3000 to see a basic AI application that uses Vercel AI SDK. These examples show how to set up the provideLinks
tool call, and how to stream the response to the client.
app/api/chat/route.ts
: Route handler implementation for the chat endpoint.app/useChat/page.tsx
: Page implementation that usesuseChat
to stream a response from the server. Go to localhost:3000/useChat to see the page.
components/chat.tsx
: Chat client component that renders the response messages that are streamed from the server. This also has a form that callssubmitUserMessage
with the form's input value.lib/chat/actions.tsx
:submitUserMessage
callsstreamUI
with relevant configuration to stream the response to the client and handle tool calling.inkeep-qa-schema.ts
: Contains Zod schemas used for validating data structures.
These examples show how to set up the API calls that use Inkeep's contextual mode, and how to stream a structured JSON response to the client. More information regarding Inkeep's contextual mode can be found in our docs.
index.ts
: Main entry point of the application.LinksToolSchema.ts
: Contains Zod schemas used for validating data structures.
-
openai
: OpenAI's official Node.js client. -
@ai-sdk/openai
: SDK for interacting with OpenAI's API. -
ai
: Library for AI tools. -
openai
: OpenAI's official Node.js client. -
zod
: TypeScript-first schema declaration and validation library.
-
tsx
: TypeScript execution environment. -
typescript
: TypeScript language.