TokenRouter is a token-efficient AI agent built for AMD Developer Hackathon Track 1. It solves a real enterprise problem: how do you get accurate AI answers while keeping API costs low? The Problem Every token sent to a large language model has a cost. Sending every task to the largest model wastes budget on tasks that smaller models handle equally well. Our Solution TokenRouter adds a lightweight classification layer before every Fireworks API call. It reads the prompt, detects the task type — code, logic, math, summarization, NER, sentiment, or factual — and selects the best model for that category. Routing Strategy Heavy tasks (code generation, debugging, logical reasoning) are routed to the highest-capability model in ALLOWED_MODELS. Everything else goes to the smallest, cheapest model. No model names are hardcoded — the router ranks ALLOWED_MODELS dynamically at runtime using parameter-size patterns in the model ID, so it works with any model list the harness injects. Architecture tasks.json → main.py → agent.py → router.py → model.py → Fireworks API → results.json Each file has a single job. The pipeline reads from /input/tasks.json and writes to /output/results.json, exits 0 on success, and reads all credentials from environment variables. Technical Stack Python 3.12, Docker linux/amd64, Fireworks AI via the OpenAI-compatible SDK, python:3.12-slim base image. No secrets, no hardcoded values, no unnecessary dependencies. Result Significant reduction in Fireworks token usage compared to a single-model approach, while staying above the 80% accuracy gate.
Category tags: