const response = await fetch('https://openrouter.ai/api/v1/responses', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_OPENROUTER_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'openai/o4-mini',
input: [
{
type: 'message',
role: 'user',
content: [
{
type: 'input_text',
text: 'What is your favorite color?',
},
],
},
{
type: 'message',
role: 'assistant',
id: 'msg_abc123',
status: 'completed',
content: [
{
type: 'output_text',
text: "I don't have a favorite color.",
annotations: []
}
]
},
{
type: 'message',
role: 'user',
content: [
{
type: 'input_text',
text: 'How many Earths can fit on Mars?',
},
],
},
],
reasoning: {
effort: 'high'
},
max_output_tokens: 9000,
}),
});
const result = await response.json();
console.log(result);