OpenRouter Ultra V2 – MCP Server & Deterministic JSON API
Pricing
from $3.00 / 1,000 ultra api call (validated + fallback protected)s
OpenRouter Ultra V2 – MCP Server & Deterministic JSON API
Zero-cold-start OpenRouter proxy and native MCP server for AI agent tool calls. Delivers deterministic JSON self-healing (REST & SSE streaming), <5ms local semantic routing, automated vision token optimization, shadow model benchmarking, context compression, and 50-row dataset batching.
Pricing
from $3.00 / 1,000 ultra api call (validated + fallback protected)s
Rating
0.0
(0)
Developer
Chris
Maintained by CommunityActor stats
1
Bookmarked
6
Total users
1
Monthly active users
12 days ago
Last modified
Categories
Features
Share
🚀 OpenRouter Ultra V2 — AI Gateway, MCP Server & Deterministic JSON Proxy
A zero-cold-start Apify Server Actor and intelligent OpenRouter proxy with native MCP server integration for AI agent tool calls, deterministic JSON self-healing, smart model routing, and high-throughput dataset batch orchestration.
OpenRouter Ultra V2 is not just another LLM wrapper. It is a production-hardened OpenRouter proxy and Server Actor engineered to guarantee deterministic JSON, automatic provider failover, strict Pay-Per-Event (PPE) budget governance, and turnkey MCP server integration for autonomous AI agent tool calls.
🤖 For AI Agents (MCP) — Native Model Context Protocol Integration
OpenRouter Ultra V2 includes built-in MCP server integration, exposing its structured extraction and deterministic JSON healing pipelines directly as AI agent tool calls over mcp.apify.com (HTTP SSE & Streamable HTTP transports).
Connecting via mcp.apify.com
External AI agents (Claude Desktop, Cursor, Windsurf, LangGraph, CrewAI, OpenAI Agents SDK, or custom MCP clients) can discover and invoke Ultra's tools directly through Apify's MCP gateway or your Server Actor standby URL:
- Apify MCP Gateway (SSE):
https://mcp.apify.com/sse?actors=chriskelch77/openrouter-ultra
- Direct Server Actor Endpoints:
- SSE Stream:
GET /sse(orGET /mcp/sse) - SSE Messages:
POST /messages(orPOST /mcp/messages) - Streamable HTTP:
POST /mcp - Tool Discovery:
GET /mcp/tools
- SSE Stream:
Example MCP Client Configuration (claude_desktop_config.json / .cursor/mcp.json)
{"mcpServers": {"openrouter-ultra": {"url": "https://mcp.apify.com/sse?actors=chriskelch77/openrouter-ultra","headers": {"Authorization": "Bearer <YOUR_APIFY_API_TOKEN>","x-openrouter-api-key": "<YOUR_OPENROUTER_API_KEY>"}}}}
Exposed MCP Tools for AI Agent Tool Calls
| MCP Tool Name | Input Arguments | Description |
|---|---|---|
ultra_extract | text (string, required), jsonSchema (object, optional), openRouterApiKey (string, optional), modelChain (string[], optional) | Accepts raw unstructured text and a JSON Schema, returning validated deterministic JSON using Ultra's ultra-extract preset and smart model fallback chains. |
ultra_json_repair | payload (string, required), jsonSchema (object, optional) | Accepts broken or malformed LLM JSON output (markdown fences, trailing commas, unquoted keys, single quotes, prose wrappers) and returns the deterministically healed JSON object. |
⚡ Why OpenRouter Ultra V2?
Most raw LLM APIs break in production pipelines because of:
- ❌ Malformed or truncated JSON responses that crash downstream parsers
- ❌ Provider rate limits (
HTTP 429) and upstream outages (502/503/504) - ❌ Cold-start latency and runaway token spend
- ❌ Lack of native MCP server integration for AI agent tool calls
OpenRouter Ultra V2 solves all four in a 256 MB zero-cold-start Server Actor.
🧠 Core V2 Capabilities
1. Deterministic JSON Repair & Schema Enforcement
Every structured response passes through a multi-stage deterministic JSON self-healing and Ajv validation pipeline:
- Strips
```jsonmarkdown fences, BOM markers, and conversational prose - Quotes bare keys, converts single-quoted strings, removes trailing commas, and escapes literal newlines
- Validates against your Draft-07 JSON Schema and stores diagnostic artifacts (
/v1/debug/:id) on failure
2. Local Semantic Edge Routing (<5ms Zero-Cost Classification)
Ultra V2 embeds a local quantized ONNX feature-extraction classifier (Xenova/all-MiniLM-L6-v2 with instant keyword fallback) to classify prompts into chat, extraction, classification, reasoning, coding, or embedding in under 5ms at $0 token cost before selecting the optimal OpenRouter model chain:
ultra-fast— sub-second latency priorityultra-smart— highest reasoning quality + repair + debug tracesultra-extract— strict schema extraction for AI agent tool callsultra-json— guaranteed deterministic JSON modeultra-private— automatic PII masking (emails, phones, credit cards, SSNs) & Zero Data Retention (zdrOnly)ultra-batch— high-throughput dataset processing
3. Real-Time Streaming JSON Auto-Healing (stream: true + jsonStrictMode: true)
- State-machine transform stream (
StreamingJsonFixTransform) heals SSE token streams on the fly - Strips leading/trailing ```json fences mid-stream and tracks open strings, escape characters, braces
{...}, and brackets[...] - Automatically emits synthetic closing tokens if an upstream provider cuts off or truncates the stream mid-object, guaranteeing valid JSON at stream end
4. Automated Vision Token Optimizer (enableVisionOptimizer: true)
- Intercepts Base64 Data-URI images (
image_url) before forwarding to OpenRouter - Uses
sharpto resize images to fit Vision LLM tile boundaries (768pxshortest-side cap,2048pxmax bounding box) and compresses them into optimized WebP (quality: 80), cutting multimodal vision token costs by up to 70%
5. Shadow Traffic Benchmarking / Canary Mode (shadowModel)
- Pass
"shadowModel"(e.g."deepseek/deepseek-chat") in your request or Actor config to mirror primary requests asynchronously (fire-and-forget, zero extra latency on the primary response) - Compares latency delta, estimated cost savings (
costDifferencePct), and JSON Schema parity, saving a structured comparison report to the Apify Key-Value Store (SHADOW_BENCHMARK_<requestId>) retrievable viaGET /v1/shadow/:id
6. Auto-Summarizing Context Compression (autoCompressContext: true)
- Monitors incoming
messagestoken counts againstmaxInputTokens(default8000) - Preserves your
systemprompt and the 4 most recent turns while compressing older conversation history in the background viagoogle/gemini-2.5-flash-lite([Compressed Conversation History]), preventing context-window overflows and slashing prompt costs on long agentic loops
7. Zero-Cold-Start Server Actor Architecture
- Runs natively on Apify Server Actors with a locked 256 MB memory footprint and strict 20 MB bounded LRU cache
SIGTERM/SIGINTgraceful shutdown hooks drain all in-flight OpenRouter requests and Key-Value Store writes before scaling down- Strict 30-second HTTP timeouts prevent hung upstream LLM calls from burning compute units
8. High-Scale Batch Orchestrator (Chunked 50-Row Pipeline)
- Processes massive Apify Datasets (
mode: "batch") withp-limit(10)concurrency and randomized worker jitter - Batches
Actor.pushData()andChargeBatchercalls in synchronized 50-row chunks, cutting Apify API network overhead by 98% - Built-in exponential backoff and jitter (
src/utils/retry.ts) automatically recover from Apify API429rate limits and5xxerrors
9. Pure Pay-Per-Event (PPE) Billing with Circuit Breaker
- Strictly meters
'request'(real-time API / MCP calls) and'row-processed'(batch items) - Hard 3-strike billing circuit breaker temporarily pauses incoming traffic if
Actor.charge()fails or times out three consecutive times
🧩 HTTP REST & OpenRouter Proxy Endpoints
| Endpoint | Method | Description |
|---|---|---|
/v1/ultra | POST | Primary intelligent OpenRouter proxy endpoint |
/v1/extract | POST | One-call structured extraction (ultra-extract preset) |
/v1/repair | POST | Standalone deterministic JSON self-healing & schema validator |
/v1/convert | POST | Token-optimized format conversion (JSON ↔ TOON) |
/v1/chat/completions | POST | Drop-in OpenAI Chat Completions compatible OpenRouter proxy |
/v1/messages | POST | Anthropic Messages compatible route |
/v1/responses | POST | OpenRouter Responses API route |
/v1/embeddings | POST | Vector embeddings route |
/sse & /messages | GET / POST | Native MCP server integration (HTTP SSE transport) |
/mcp | POST / GET | Native MCP server integration (Streamable HTTP transport) |
/mcp/tools | GET | List registered MCP tools (ultra_extract, ultra_json_repair) |
/v1/request/:id | GET | Retrieve full request execution trace |
/v1/debug/:id | GET | Retrieve JSON repair & schema validation diagnostics |
/v1/shadow/:id | GET | Retrieve Shadow Traffic Benchmarking / Canary comparison report |
/health | GET | Server Actor health, version (2.0.0), cache memory & in-flight stats |
🔬 Example: Structured Extraction via /v1/extract
curl -X POST https://<YOUR-SERVER-ACTOR-URL>/v1/extract \-H "Content-Type: application/json" \-H "x-openrouter-api-key: sk-or-v1-..." \-d '{"text": "Invoice #9481 from Acme Corp for $1,250.00 due on 2026-12-01.","jsonSchema": {"type": "object","properties": {"invoiceNumber": { "type": "string" },"vendor": { "type": "string" },"amountUsd": { "type": "number" }},"required": ["invoiceNumber", "vendor", "amountUsd"]}}'
Response
{"success": true,"data": {"invoiceNumber": "9481","vendor": "Acme Corp","amountUsd": 1250},"meta": {"requestId": "req_1762855800000_a1b2c3","latencyMs": 612,"finalModel": "openai/gpt-4o-mini","fallbacksTried": [],"repairedJSON": false,"policyPreset": "ultra-extract","taskClass": "extraction","estimatedCostUsd": 0.00014}}

