#!/usr/bin/env node
/**
* Thorough test of the reasoning/Cortex model
*/
import { config } from 'dotenv';
config();
const SAPTIVA_API_KEY = process.env.SAPTIVA_API_KEY;
const SAPTIVA_BASE_URL = process.env.SAPTIVA_BASE_URL || "https://api.saptiva.com";
async function testDirect(testName, payload) {
console.log(`\n${'='.repeat(60)}`);
console.log(`Test: ${testName}`);
console.log('='.repeat(60));
console.log('Payload:', JSON.stringify(payload, null, 2));
try {
const response = await fetch(`${SAPTIVA_BASE_URL}/v1/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${SAPTIVA_API_KEY}`,
},
body: JSON.stringify(payload),
});
console.log(`\nStatus: ${response.status} ${response.statusText}`);
const text = await response.text();
try {
const json = JSON.parse(text);
console.log('\nResponse:', JSON.stringify(json, null, 2).substring(0, 2000));
if (json.choices?.[0]?.message) {
const msg = json.choices[0].message;
if (msg.reasoning_content) {
console.log('\n--- REASONING CONTENT ---');
console.log(msg.reasoning_content.substring(0, 500) + '...');
}
if (msg.content) {
console.log('\n--- FINAL ANSWER ---');
console.log(msg.content);
}
}
return { success: true, data: json };
} catch {
console.log('\nRaw response:', text.substring(0, 1000));
return { success: false, error: text };
}
} catch (err) {
console.log('\nError:', err.message);
return { success: false, error: err.message };
}
}
async function runTests() {
console.log('Testing Saptiva Reasoning Models');
console.log('API Key:', SAPTIVA_API_KEY ? `${SAPTIVA_API_KEY.substring(0, 10)}...` : 'NOT SET');
// Test 1: Saptiva Cortex with simple question
await testDirect('Saptiva Cortex - Simple Math', {
model: 'Saptiva Cortex',
messages: [
{ role: 'user', content: 'What is 15 + 27?' }
],
max_tokens: 500
});
// Test 2: Saptiva Cortex with reasoning question
await testDirect('Saptiva Cortex - Reasoning', {
model: 'Saptiva Cortex',
messages: [
{ role: 'user', content: 'If I have 3 apples and give away 1, then buy 5 more, how many do I have?' }
],
max_tokens: 500
});
// Test 3: Saptiva Ops model
await testDirect('Saptiva Ops - Simple', {
model: 'Saptiva Ops',
messages: [
{ role: 'user', content: 'What is the capital of France?' }
],
max_tokens: 200
});
// Test 4: Saptiva Turbo for comparison
await testDirect('Saptiva Turbo - Control', {
model: 'Saptiva Turbo',
messages: [
{ role: 'user', content: 'What is 15 + 27?' }
],
max_tokens: 200
});
// Test 5: Saptiva Cortex with system message
await testDirect('Saptiva Cortex - With System', {
model: 'Saptiva Cortex',
messages: [
{ role: 'system', content: 'You are a helpful math tutor.' },
{ role: 'user', content: 'Solve: 2x + 5 = 15' }
],
max_tokens: 500
});
// Test 6: Different temperature
await testDirect('Saptiva Cortex - Low Temp', {
model: 'Saptiva Cortex',
messages: [
{ role: 'user', content: 'What is 100 divided by 4?' }
],
max_tokens: 300,
temperature: 0.1
});
console.log('\n' + '='.repeat(60));
console.log('All tests completed');
console.log('='.repeat(60));
}
runTests();