init
This commit is contained in:
31
3-tc-websearch.mjs
Normal file
31
3-tc-websearch.mjs
Normal file
@@ -0,0 +1,31 @@
|
||||
import OpenAI from 'openai'
|
||||
const openai = new OpenAI({
|
||||
apiKey:
|
||||
'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'
|
||||
}) // or set environment: export OPENAI_API_KEY=...
|
||||
|
||||
const my = {
|
||||
model: 'gpt-5-nano'
|
||||
}
|
||||
|
||||
const tools = [
|
||||
{
|
||||
type: 'web_search'
|
||||
}
|
||||
]
|
||||
|
||||
let input = [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Tell me the most up-to-date news about the war in Iran'
|
||||
}
|
||||
]
|
||||
|
||||
let response = await openai.responses.create({
|
||||
model: my.model,
|
||||
tools,
|
||||
input
|
||||
})
|
||||
|
||||
console.log('==========Response')
|
||||
console.log(JSON.stringify(response, null, 2)) // response.output_text/output_parsed
|
||||
Reference in New Issue
Block a user