Skip to main content
Glama

get_pricing

Check pricing for Fal.ai models before generating content. Returns cost per unit (image/video/second) in USD to help users estimate expenses.

Instructions

Get pricing information for Fal.ai models. Returns cost per unit (image/video/second) in USD. Use this to check costs before generating content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelsYesModel IDs or aliases to get pricing for (e.g., ['flux_schnell', 'fal-ai/kling-video'])

Implementation Reference

  • The core handler function for the 'get_pricing' tool. It validates input models, resolves them to endpoint IDs using the ModelRegistry, fetches pricing data from the API, handles errors, and formats the pricing information as text content.
    async def handle_get_pricing(
        arguments: Dict[str, Any],
        registry: ModelRegistry,
    ) -> List[TextContent]:
        """Handle the get_pricing tool."""
        model_inputs = arguments.get("models", [])
        if not model_inputs:
            return [
                TextContent(
                    type="text",
                    text="❌ No models specified. Provide a list of model IDs or aliases.",
                )
            ]
    
        # Resolve all model inputs to endpoint IDs
        endpoint_ids = []
        failed_models = []
        for model_input in model_inputs:
            try:
                endpoint_id = await registry.resolve_model_id(model_input)
                endpoint_ids.append(endpoint_id)
            except ValueError:
                failed_models.append(model_input)
    
        if failed_models:
            return [
                TextContent(
                    type="text",
                    text=f"❌ Unknown model(s): {', '.join(failed_models)}. Use list_models to see available options.",
                )
            ]
    
        # Fetch pricing from API
        try:
            pricing_data = await registry.get_pricing(endpoint_ids)
        except httpx.HTTPStatusError as e:
            logger.error(
                "Pricing API returned HTTP %d for %s: %s",
                e.response.status_code,
                endpoint_ids,
                e,
            )
            return [
                TextContent(
                    type="text",
                    text=f"❌ Pricing API error (HTTP {e.response.status_code})",
                )
            ]
        except httpx.TimeoutException:
            logger.error("Pricing API timeout for %s", endpoint_ids)
            return [
                TextContent(
                    type="text",
                    text="❌ Pricing request timed out. Please try again.",
                )
            ]
        except httpx.ConnectError as e:
            logger.error("Cannot connect to pricing API: %s", e)
            return [
                TextContent(
                    type="text",
                    text="❌ Cannot connect to Fal.ai API. Check your network connection.",
                )
            ]
    
        prices = pricing_data.get("prices", [])
        if not prices:
            return [
                TextContent(
                    type="text",
                    text="No pricing information available for the specified models.",
                )
            ]
    
        # Format output
        lines = ["💰 **Pricing Information**\n"]
        for price_info in prices:
            endpoint_id = price_info.get("endpoint_id", "Unknown")
            unit_price = price_info.get("unit_price", 0)
            unit = price_info.get("unit", "request")
            currency = price_info.get("currency", "USD")
    
            # Format price with currency symbol
            if currency == "USD":
                price_str = f"${unit_price:.4f}".rstrip("0").rstrip(".")
            else:
                price_str = f"{unit_price:.4f} {currency}".rstrip("0").rstrip(".")
    
            lines.append(f"- **{endpoint_id}**: {price_str} per {unit}")
    
        return [TextContent(type="text", text="\n".join(lines))]
  • The Tool schema definition for 'get_pricing', including name, description, and input schema requiring a list of model IDs or aliases.
    Tool(
        name="get_pricing",
        description="Get pricing information for Fal.ai models. Returns cost per unit (image/video/second) in USD. Use this to check costs before generating content.",
        inputSchema={
            "type": "object",
            "properties": {
                "models": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "Model IDs or aliases to get pricing for (e.g., ['flux_schnell', 'fal-ai/kling-video'])",
                    "minItems": 1,
                    "maxItems": 50,
                },
            },
            "required": ["models"],
        },
    ),
  • Registration of the 'get_pricing' handler in the TOOL_HANDLERS dictionary used by the stdio server to map tool names to their handler functions.
    TOOL_HANDLERS = {
        # Utility tools (no queue needed)
        "list_models": handle_list_models,
        "recommend_model": handle_recommend_model,
        "get_pricing": handle_get_pricing,
        "get_usage": handle_get_usage,
        "upload_file": handle_upload_file,
        # Image generation tools
        "generate_image": handle_generate_image,
        "generate_image_structured": handle_generate_image_structured,
        "generate_image_from_image": handle_generate_image_from_image,
        # Image editing tools
        "remove_background": handle_remove_background,
        "upscale_image": handle_upscale_image,
        "edit_image": handle_edit_image,
        "inpaint_image": handle_inpaint_image,
        "resize_image": handle_resize_image,
        "compose_images": handle_compose_images,
        # Video tools
        "generate_video": handle_generate_video,
        "generate_video_from_image": handle_generate_video_from_image,
        "generate_video_from_video": handle_generate_video_from_video,
        # Audio tools
        "generate_music": handle_generate_music,
    }
  • Registration of the 'get_pricing' handler in the TOOL_HANDLERS dictionary used by the HTTP/SSE server.
    TOOL_HANDLERS = {
        # Utility tools (no queue needed)
        "list_models": handle_list_models,
        "recommend_model": handle_recommend_model,
        "get_pricing": handle_get_pricing,
        "get_usage": handle_get_usage,
        "upload_file": handle_upload_file,
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it returns cost data in USD per unit (image/video/second), which is valuable context. However, it doesn't mention rate limits, authentication requirements, or error conditions, leaving gaps for a tool that likely queries external pricing data.

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 front-loaded and efficient: two sentences with zero waste. The first sentence states the purpose and return format, and the second provides usage guidance, making it easy to parse quickly.

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 moderate complexity (external pricing query), no annotations, and no output schema, the description is adequate but incomplete. It explains the return value (cost per unit in USD) but lacks details on response structure, error handling, or data freshness, which could hinder agent usage.

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 the schema already fully documents the 'models' parameter. The description adds no additional parameter semantics beyond what the schema provides, such as examples of valid model IDs or pricing granularity. Baseline 3 is appropriate when the schema does the heavy lifting.

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's purpose: 'Get pricing information for Fal.ai models' with specific resources (models) and verb (get). It distinguishes from siblings like 'get_usage' (usage statistics) and 'list_models' (model listing) by focusing on cost data.

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

Usage Guidelines4/5

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

The description provides clear context: 'Use this to check costs before generating content,' which implicitly suggests using it for cost estimation prior to using generation tools. However, it doesn't explicitly state when not to use it or name specific alternatives among siblings.

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/raveenb/fal-mcp-server'

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