Standard Requests
Basic Request
Section titled “Basic Request”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);from tokenrouter import Tokenrouter
client = Tokenrouter( api_key=os.getenv("TOKENROUTER_API_KEY"))
response = client.responses.create( model="auto:balance", input="What is the capital of France?")
print(response.output[0].content[0].text)curl https://api.tokenrouter.io/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer tr_..." \ -d '{ "model": "auto:balance", "input": "What is the capital of France?" }'Request Parameters
Section titled “Request Parameters”model- Routing mode or specific model (default:auto:balance)input- Text input (required)instructions- System instructionsmax_output_tokens- Maximum response lengthtemperature- Randomness (0-2)stream- Enable streaming
Response Format
Section titled “Response Format”{ "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 }}