Skip to content

Standard Requests

import Tokenrouter from 'tokenrouter';
const client = new Tokenrouter({
apiKey: process.env.TOKENROUTER_API_KEY
});
const response = await client.responses.create({
model: 'auto:balance',
input: 'What is the capital of France?'
});
console.log(response.output[0].content[0].text);
  • model - Routing mode or specific model (default: auto:balance)
  • input - Text input (required)
  • instructions - System instructions
  • max_output_tokens - Maximum response length
  • temperature - Randomness (0-2)
  • stream - Enable streaming
{
"id": "resp_...",
"model": "gpt-4o-2024-11-20",
"output": [
{
"role": "assistant",
"content": [{"type": "text", "text": "Paris."}]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 3,
"total_tokens": 15
}
}