nickyni's picture
Upload examples/gpt52_example.js with huggingface_hub
8cbeed3 verified
Raw
History Blame Contribute Delete
945 Bytes
// 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();