Skip to main content
Glama

get_model_pricing

Compare AI model pricing across major providers like Anthropic, OpenAI, Google, Meta, Mistral, and Cohere. Get prices per million tokens to make informed cost decisions.

Instructions

Get AI model pricing comparison across all major providers (Anthropic, OpenAI, Google, Meta, Mistral, Cohere). Prices per 1M tokens.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'get_model_pricing' tool via server.tool() on the MCP server. No input schema. Fetches pricing data from /models endpoint and formats it as text.
    server.tool(
      'get_model_pricing',
      'Get AI model pricing comparison across all major providers (Anthropic, OpenAI, Google, Meta, Mistral, Cohere). Prices per 1M tokens.',
      {},
      async () => {
        const data = await fetchJSON('/models') as {
          providers: {
            name: string;
            models: { name: string; inputPrice: number; outputPrice: number; contextWindow: number; released: string; capabilities: string[] }[];
          }[];
        };
    
        const text = data.providers
          .map(p => {
            const models = p.models
              .map(m => {
                const input = m.inputPrice === 0 ? 'Free' : `$${m.inputPrice.toFixed(2)}`;
                const output = m.outputPrice === 0 ? 'Free' : `$${m.outputPrice.toFixed(2)}`;
                const ctx = m.contextWindow >= 1000000
                  ? `${(m.contextWindow / 1000000).toFixed(0)}M`
                  : `${(m.contextWindow / 1000).toFixed(0)}K`;
                return `    ${m.name}: Input ${input}, Output ${output}, Context ${ctx}, Released ${m.released}`;
              })
              .join('\n');
            return `  ${p.name}:\n${models}`;
          })
          .join('\n\n');
    
        return { content: [{ type: 'text' as const, text: `AI Model Pricing (per 1M tokens):\n\n${text}` }] };
      }
    );
  • Handler function for get_model_pricing. Calls fetchJSON('/models') to retrieve pricing data from tensorfeed.ai, then formats it into a human-readable text response listing providers and their models with input/output prices per 1M tokens, context window size, and release date.
    async () => {
      const data = await fetchJSON('/models') as {
        providers: {
          name: string;
          models: { name: string; inputPrice: number; outputPrice: number; contextWindow: number; released: string; capabilities: string[] }[];
        }[];
      };
    
      const text = data.providers
        .map(p => {
          const models = p.models
            .map(m => {
              const input = m.inputPrice === 0 ? 'Free' : `$${m.inputPrice.toFixed(2)}`;
              const output = m.outputPrice === 0 ? 'Free' : `$${m.outputPrice.toFixed(2)}`;
              const ctx = m.contextWindow >= 1000000
                ? `${(m.contextWindow / 1000000).toFixed(0)}M`
                : `${(m.contextWindow / 1000).toFixed(0)}K`;
              return `    ${m.name}: Input ${input}, Output ${output}, Context ${ctx}, Released ${m.released}`;
            })
            .join('\n');
          return `  ${p.name}:\n${models}`;
        })
        .join('\n\n');
    
      return { content: [{ type: 'text' as const, text: `AI Model Pricing (per 1M tokens):\n\n${text}` }] };
    }
  • Helper function fetchJSON that handles API calls to tensorfeed.ai. Used by the get_model_pricing handler to fetch data from the /models endpoint. Handles authentication via TENSORFEED_TOKEN env var and error states including 402 (payment required) and 401 (token rejected).
    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();
    }
Behavior3/5

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

With no annotations, the description must disclose behavioral traits. It states the providers covered and unit, but lacks details on data freshness, caching, real-time behavior, or whether it returns all models. The description is minimal for a tool with no annotations.

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, clear sentence with no wasted words. It is front-loaded and immediately conveys the tool's purpose. Perfectly concise.

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

Completeness4/5

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

Despite no output schema, the description covers the main return value (pricing comparison) and unit. It could include more detail (e.g., input vs. output pricing, model list), but it is sufficient for a simple tool with no parameters.

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

Parameters4/5

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

The input schema has zero parameters (100% coverage). The description adds meaning by explaining the output context (pricing comparison per 1M tokens), which is helpful. Baseline for 0 params is 4.

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

Purpose5/5

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

The description clearly states the tool retrieves AI model pricing comparisons across major providers (Anthropic, OpenAI, Google, Meta, Mistral, Cohere) and specifies the unit (per 1M tokens). It distinguishes itself from sibling tools like 'pricing_series' by explicitly covering multiple providers.

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

Usage Guidelines3/5

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

The description implies usage for comparing provider pricing but provides no explicit guidance on when to use this tool versus siblings like 'cost_projection' or 'pricing_series'. No exclusions or alternatives 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