|
| 1 | +/** |
| 2 | + * Agent Card Endpoint — /.well-known/agent.json |
| 3 | + * |
| 4 | + * Serves the OmniRoute A2A Agent Card for discovery by other agents. |
| 5 | + * Conforms to A2A Protocol v0.3. |
| 6 | + * |
| 7 | + * The Agent Card is dynamically generated to include the current version |
| 8 | + * from package.json and skills based on available combos. |
| 9 | + */ |
| 10 | + |
| 11 | +import { NextResponse } from "next/server"; |
| 12 | + |
| 13 | +const PACKAGE_VERSION = process.env.npm_package_version || "1.8.1"; |
| 14 | +const BASE_URL = process.env.OMNIROUTE_BASE_URL || "http://localhost:20128"; |
| 15 | + |
| 16 | +/** |
| 17 | + * GET /.well-known/agent.json |
| 18 | + * |
| 19 | + * Returns the OmniRoute Agent Card that describes this gateway's |
| 20 | + * capabilities as an A2A agent. |
| 21 | + */ |
| 22 | +export async function GET() { |
| 23 | + const agentCard = { |
| 24 | + name: "OmniRoute AI Gateway", |
| 25 | + description: |
| 26 | + "Intelligent AI routing gateway with 36+ providers, smart fallback, " + |
| 27 | + "quota tracking, format translation, and auto-managed combos. " + |
| 28 | + "Routes AI requests to the optimal provider based on cost, latency, " + |
| 29 | + "quota availability, and task requirements.", |
| 30 | + url: `${BASE_URL}/a2a`, |
| 31 | + version: PACKAGE_VERSION, |
| 32 | + capabilities: { |
| 33 | + streaming: true, |
| 34 | + pushNotifications: false, |
| 35 | + }, |
| 36 | + skills: [ |
| 37 | + { |
| 38 | + id: "smart-routing", |
| 39 | + name: "Smart Request Routing", |
| 40 | + description: |
| 41 | + "Routes AI requests to the optimal provider based on quota, cost, " + |
| 42 | + "latency, and reliability. Supports combo-based routing with " + |
| 43 | + "multiple strategies: priority, weighted, round-robin, cost-optimized.", |
| 44 | + tags: ["routing", "llm", "optimization", "fallback"], |
| 45 | + examples: [ |
| 46 | + "Route this coding task to the fastest available model", |
| 47 | + "Send this review to an analytical model under $0.50 budget", |
| 48 | + "Find the cheapest provider with available quota", |
| 49 | + ], |
| 50 | + }, |
| 51 | + { |
| 52 | + id: "quota-management", |
| 53 | + name: "Quota & Cost Management", |
| 54 | + description: |
| 55 | + "Tracks and manages API quotas across 36+ providers with " + |
| 56 | + "auto-fallback when quotas are exhausted. Provides real-time " + |
| 57 | + "cost tracking and budget enforcement.", |
| 58 | + tags: ["quota", "cost", "monitoring", "budget"], |
| 59 | + examples: [ |
| 60 | + "Check remaining quota for all providers", |
| 61 | + "Which provider has the most available quota?", |
| 62 | + "Generate a cost report for today", |
| 63 | + ], |
| 64 | + }, |
| 65 | + { |
| 66 | + id: "auto-combo", |
| 67 | + name: "Auto-Managed Model Combos", |
| 68 | + description: |
| 69 | + "Self-healing model chains that dynamically adapt to provider " + |
| 70 | + "health and quota availability. Uses a scoring function based on " + |
| 71 | + "quota, health, cost, latency, task fitness, and stability.", |
| 72 | + tags: ["combo", "auto", "self-healing", "adaptive"], |
| 73 | + examples: [ |
| 74 | + "Create an auto-managed combo for coding tasks", |
| 75 | + "Switch to cost-saver mode", |
| 76 | + "Show the Auto-Combo scoring breakdown", |
| 77 | + ], |
| 78 | + }, |
| 79 | + { |
| 80 | + id: "format-translation", |
| 81 | + name: "Format Translation", |
| 82 | + description: |
| 83 | + "Transparently translates between OpenAI, Claude (Anthropic), " + |
| 84 | + "Gemini (Google), and Responses API formats. Supports streaming " + |
| 85 | + "translation for all format pairs.", |
| 86 | + tags: ["translation", "openai", "claude", "gemini", "responses"], |
| 87 | + examples: [ |
| 88 | + "Send an OpenAI-format request to Claude", |
| 89 | + "Translate this Gemini response to OpenAI format", |
| 90 | + ], |
| 91 | + }, |
| 92 | + ], |
| 93 | + authentication: { |
| 94 | + schemes: ["api-key"], |
| 95 | + apiKeyHeader: "Authorization", |
| 96 | + }, |
| 97 | + }; |
| 98 | + |
| 99 | + return NextResponse.json(agentCard, { |
| 100 | + headers: { |
| 101 | + "Cache-Control": "public, max-age=3600", |
| 102 | + "Content-Type": "application/json", |
| 103 | + }, |
| 104 | + }); |
| 105 | +} |
0 commit comments