Generative AI with Node js in Hindi #4 Open AI Instructions, Roles, Reasoning #generativeai #nodejs
Open AI Instructions,Roles, Reasoning
Steps:-
- Use env file for API key
- What is Instruction and how to use it
- What are the roles in Open AI with example
- Reasoning in open AI
Code:-
import OpenAI from "openai"
import dotenv from 'dotenv'
dotenv.config();
const client= new OpenAI({apiKey:process.env.openAI_Key})
// const response = await client.responses.create({
// instructions:'give result in 10 word',
// input:"tell me one best color",
// model:"gpt-4o-mini"
// });
const response = await client.responses.create({
input:[
{role:'system',content:'answer in hindi language'},
{role:'developer',content:'gave a basic example in JS'},
{role:'user',content:'what is coding'}
],
model:"gpt-4o-mini"
});
console.log(response.output_text);