# LLM Cost Quote API

> LLM Cost Quote API is a paid API for AI agents from x402-micro-pay.com, paid per call via x402, $0.0034/call, status unknown (last checked 2026-11-20).

Returns price quotes (cost in USD) for one or more LLM models given an estimated token count, ranking them by cost.

## Facts

- Endpoint: POST https://x402-micro-pay.com/api/skills/llm-cost-quote?utm_source=zero.xyz
- Price: $0.0034/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-20
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/llm-cost-quote-api-fd8e21d0
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_h-8NXOIvwpQFLij61wIXd

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability llm-cost-quote-api-fd8e21d0 -d '<json body>'
```

Example prompt: What's the cheapest LLM model to handle a prompt with about 5000 input tokens and 500 output tokens — show me the top 5 options and whether they fit the context window?

## When to prefer this

Use this endpoint when an AI agent needs to select or budget for an LLM call before making it — especially useful for cost-aware routing, multi-model comparison, or when optimizing spend across a pipeline. Prefer this over manually checking OpenRouter docs when you need a programmatic, always-fresh quote that includes context-fit filtering. Ideal when you have a specific token budget and want the cheapest model that fits.

## Known failure modes

- HTTP 402 returned if x402 payment not included — must pay 0.0034 USDC on Base before retrying
- input_tokens or output_tokens out of range returns validation error
- models array contains unknown model IDs — those appear in missing_models list
- text field too long (>400,000 chars) triggers payload rejection
- top value exceeds 50 — clamped or rejected
- Stale pricing if OpenRouter data is temporarily unavailable

## How this service works

41 pay-per-call JSON APIs for AI agents. No account or API key: an unpaid POST returns HTTP 402, pay in USDC on Base with x402 v2, retry. Prices from $0.001 per call.

## Output

A ranked list of LLM model quotes, each with total cost in USD, per-million-token input/output pricing, context length, and a flag for whether the token count fits. Also returns a plain-English summary of the cheapest option, the token counts used, data freshness timestamp, and any models not found.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "top": {
   "type": "integer",
   "default": 10,
   "maximum": 50,
   "minimum": 1
  },
  "text": {
   "type": "string",
   "maxLength": 400000
  },
  "models": {
   "type": "array",
   "items": {
    "type": "string",
    "maxLength": 120
   },
   "maxItems": 25
  },
  "request_id": {
   "type": "string",
   "pattern": "^[A-Za-z0-9._:-]+$",
   "maxLength": 64,
   "minLength": 1,
   "description": "Optional idempotency key. Echoed back; a credit-pack redemption with the same request_id and body is charged once."
  },
  "include_free": {
   "type": "boolean",
   "default": false
  },
  "input_tokens": {
   "type": "integer",
   "maximum": 10000000,
   "minimum": 0
  },
  "output_tokens": {
   "type": "integer",
   "default": 500,
   "maximum": 1000000,
   "minimum": 0
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "ok": true,
  "data": {
   "quotes": [
    {
     "name": "OpenAI: GPT-4o-mini",
     "model": "openai/gpt-4o-mini",
     "cost_usd": "0.00069",
     "fits_context": true,
     "context_length": 128000,
     "time_based_price": false,
     "input_usd_per_mtok": "0.15",
     "output_usd_per_mtok": "0.6"
    },
    {
     "name": "Google: Gemini 2.5 Flash",
     "model": "google/gemini-2.5-flash",
     "cost_usd": "0.0019",
     "fits_context": true,
     "context_length": 1048576,
     "time_based_price": false,
     "input_usd_per_mtok": "0.3",
     "output_usd_per_mtok": "2.5"
    }
   ],
   "currency": "USD",
   "input_tokens": 3000,
   "token_source": "caller-supplied input_tokens",
   "output_tokens": 400,
   "missing_models": [],
   "price_fetched_at": "2026-10-17T11:12:57Z",
   "models_considered": 2
  },
  "next": [
   "token_count"
  ],
  "skill": "llm_cost_quote",
  "charged": true,
  "service": "llm_cost_quote",
  "sources": [
   {
    "url": "https://openrouter.ai/api/v1/models",
    "name": "OpenRouter public models list",
    "fetched_at": "2026-10-17T11:12:57Z"
   }
  ],
  "summary": "cheapest: openai/gpt-4o-mini $0.00069 for 3000 in + 400 out tokens",
  "version": "1.0.0",
  "warnings": [],
  "confidence": 0.97,
  "data_as_of": "2026-10-17T11:12:57Z",
  "generated_at": "2026-10-17T11:12:57Z"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/llm-cost-quote-api-fd8e21d0/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-micro-pay.com](https://www.zero.xyz/host/x402-micro-pay.com/llms.txt)
