Skip to main content
Glama

premium_routing

Rank AI models for code, reasoning, creative, or general tasks. Set budget and minimum quality to receive a scored list with breakdowns for quality, availability, cost, latency.

Instructions

Get a ranked list of recommended AI models for a task with full score breakdown (quality, availability, cost, latency). Costs 1 credit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskNoTask type the model needs to be good at (default: general)
budgetNoMax blended USD per 1M tokens
min_qualityNoMinimum quality score in [0, 1]
top_nNoHow many models to return (default 5)

Implementation Reference

  • The async handler function that executes the premium_routing tool logic. It builds URL params from the input schema, calls the API endpoint /premium/routing, and formats the response into a human-readable text block.
      async ({ task, budget, min_quality, top_n }) => {
        const params = new URLSearchParams();
        if (task) params.set('task', task);
        if (typeof budget === 'number') params.set('budget', String(budget));
        if (typeof min_quality === 'number') params.set('min_quality', String(min_quality));
        if (typeof top_n === 'number') params.set('top_n', String(top_n));
        const data = (await fetchJSON(`/premium/routing?${params}`, { auth: true })) as {
          task: string;
          recommendations: {
            rank: number;
            model: { name: string; provider: string };
            pricing: { input: number; output: number };
            composite_score: number;
            components: { quality: number; availability: number; cost: number; latency: number };
          }[];
          billing?: { credits_charged: number; credits_remaining?: number };
        };
        const list = data.recommendations
          .map(r => {
            const c = r.components;
            return `  #${r.rank} ${r.model.name} (${r.model.provider}) score=${r.composite_score.toFixed(3)}\n     in $${r.pricing.input}/1M, out $${r.pricing.output}/1M\n     quality=${c.quality.toFixed(2)} avail=${c.availability.toFixed(2)} cost=${c.cost.toFixed(2)} latency=${c.latency.toFixed(2)}`;
          })
          .join('\n\n');
        const billing = data.billing
          ? `\n\nCharged ${data.billing.credits_charged} credit. Remaining: ${data.billing.credits_remaining}.`
          : '';
        return { content: [{ type: 'text' as const, text: `Routing for "${data.task}":\n\n${list}${billing}` }] };
      },
    );
  • Input schema for the premium_routing tool using Zod: optional task (enum: code/reasoning/creative/general), budget (number), min_quality (0-1), and top_n (1-10).
    {
      task: z.enum(['code', 'reasoning', 'creative', 'general']).optional().describe('Task type the model needs to be good at (default: general)'),
      budget: z.number().optional().describe('Max blended USD per 1M tokens'),
      min_quality: z.number().min(0).max(1).optional().describe('Minimum quality score in [0, 1]'),
      top_n: z.number().min(1).max(10).optional().describe('How many models to return (default 5)'),
    },
  • Registration of the tool using server.tool() with name 'premium_routing', description about ranked recommended AI models, Zod input schema, and the async handler.
    server.tool(
      'premium_routing',
      'Get a ranked list of recommended AI models for a task with full score breakdown (quality, availability, cost, latency). Costs 1 credit.',
      {
        task: z.enum(['code', 'reasoning', 'creative', 'general']).optional().describe('Task type the model needs to be good at (default: general)'),
        budget: z.number().optional().describe('Max blended USD per 1M tokens'),
        min_quality: z.number().min(0).max(1).optional().describe('Minimum quality score in [0, 1]'),
        top_n: z.number().min(1).max(10).optional().describe('How many models to return (default 5)'),
      },
      async ({ task, budget, min_quality, top_n }) => {
        const params = new URLSearchParams();
        if (task) params.set('task', task);
        if (typeof budget === 'number') params.set('budget', String(budget));
        if (typeof min_quality === 'number') params.set('min_quality', String(min_quality));
        if (typeof top_n === 'number') params.set('top_n', String(top_n));
        const data = (await fetchJSON(`/premium/routing?${params}`, { auth: true })) as {
          task: string;
          recommendations: {
            rank: number;
            model: { name: string; provider: string };
            pricing: { input: number; output: number };
            composite_score: number;
            components: { quality: number; availability: number; cost: number; latency: number };
          }[];
          billing?: { credits_charged: number; credits_remaining?: number };
        };
        const list = data.recommendations
          .map(r => {
            const c = r.components;
            return `  #${r.rank} ${r.model.name} (${r.model.provider}) score=${r.composite_score.toFixed(3)}\n     in $${r.pricing.input}/1M, out $${r.pricing.output}/1M\n     quality=${c.quality.toFixed(2)} avail=${c.availability.toFixed(2)} cost=${c.cost.toFixed(2)} latency=${c.latency.toFixed(2)}`;
          })
          .join('\n\n');
        const billing = data.billing
          ? `\n\nCharged ${data.billing.credits_charged} credit. Remaining: ${data.billing.credits_remaining}.`
          : '';
        return { content: [{ type: 'text' as const, text: `Routing for "${data.task}":\n\n${list}${billing}` }] };
      },
    );
  • The fetchJSON helper function used by the handler to make authenticated HTTP requests to the TensorFeed API.
    async function fetchJSON(path: string, opts: FetchOptions = {}): Promise<unknown> {
      const headers: Record<string, string> = {
        'User-Agent': `TensorFeed-MCP/${SDK_VERSION}`,
      };
      if (opts.body !== undefined) headers['Content-Type'] = 'application/json';
      if (opts.auth) {
        const token = process.env.TENSORFEED_TOKEN;
        if (!token) {
          throw new Error(
            'TENSORFEED_TOKEN env var is not set. Premium MCP tools require a bearer token. ' +
              'Buy credits at https://tensorfeed.ai/developers/agent-payments and pass the returned tf_live_... token via the TENSORFEED_TOKEN env var in your MCP client config.',
          );
        }
        headers['Authorization'] = `Bearer ${token}`;
      }
      const res = await fetch(`${API_BASE}${path}`, {
        method: opts.method ?? 'GET',
        headers,
        ...(opts.body !== undefined ? { body: JSON.stringify(opts.body) } : {}),
      });
      if (!res.ok) {
        let errPayload: unknown;
        try {
          errPayload = await res.json();
        } catch {
          errPayload = await res.text().catch(() => '');
        }
        if (res.status === 402) {
          throw new Error(
            `Payment required (402). Your token may be out of credits. Top up at https://tensorfeed.ai/developers/agent-payments. Detail: ${JSON.stringify(errPayload)}`,
          );
        }
        if (res.status === 401) {
          throw new Error(
            `Token rejected (401). Check that TENSORFEED_TOKEN is set to a valid tf_live_... token. Detail: ${JSON.stringify(errPayload)}`,
          );
        }
        throw new Error(`API error ${res.status}: ${JSON.stringify(errPayload)}`);
      }
      return res.json();
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool costs 1 credit, which is a behavioral trait. However, it fails to mention other important aspects such as whether it is read-only, destructive, or has rate limits. The description does not contradict annotations as none exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that conveys the core functionality and a key constraint (cost). It is concise with no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters, no output schema, no annotations), the description provides the essential purpose and cost but lacks details such as return format, default parameter values, and usage scenarios. It is minimally adequate but has gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description does not add extra meaning beyond the schema for any of the four parameters. It does not explain default values or provide additional context beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get a ranked list of recommended AI models for a task with full score breakdown (quality, availability, cost, latency).' It uses a specific verb and resource, and mentions the scoring dimensions. However, it does not explicitly differentiate from siblings like 'compare_models' or 'get_model_pricing', though the distinction is implied.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It only notes that it costs 1 credit. No when-to-use, when-not-to-use, or alternative tools are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/RipperMercs/tensorfeed'

If you have feedback or need assistance with the MCP directory API, please join our Discord server