File size: 945 Bytes
8cbeed3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | // GPT-5.2 API Example via NexaAPI
// Get your free API key at: https://nexa-api.com
// Install: npm install nexaapi
import NexaAPI from 'nexaapi';
const client = new NexaAPI({ apiKey: 'YOUR_API_KEY' });
async function main() {
// Basic text generation
const response = await client.chat.completions.create({
model: 'gpt-5.2',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Explain quantum computing in simple terms' }
]
});
console.log('GPT-5.2 Response:');
console.log(response.choices[0].message.content);
// Code generation
const codeResponse = await client.chat.completions.create({
model: 'gpt-5.2',
messages: [{
role: 'user',
content: 'Write a JavaScript function to sort an array of objects by a property'
}]
});
console.log('\nCode Generation:');
console.log(codeResponse.choices[0].message.content);
}
main();
|