import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.PARALLEL_API_KEY,
baseURL: "https://api.parallel.ai/v1",
});
const response = await client.responses.create({
model: "parallel",
input: "What is the capital and population of Iceland?",
reasoning: { effort: "low" },
text: {
format: {
type: "json_schema",
name: "capital_info",
schema: {
type: "object",
properties: {
capital: { type: "string" },
population: { type: "integer" },
},
required: ["capital", "population"],
additionalProperties: false,
},
},
},
});
const answer = JSON.parse(response.output_text);
console.log(answer); // { capital: "Reykjavik", population: 386506 }