{"id":23104,"date":"2026-08-07T08:21:15","date_gmt":"2026-08-07T08:21:15","guid":{"rendered":"https:\/\/scannn.com\/a-unified-api-for-ai-model-routing\/"},"modified":"2026-08-07T08:21:15","modified_gmt":"2026-08-07T08:21:15","slug":"a-unified-api-for-ai-model-routing","status":"publish","type":"post","link":"https:\/\/scannn.com\/lv\/a-unified-api-for-ai-model-routing\/","title":{"rendered":"A unified API for AI model routing"},"content":{"rendered":"\n<div>\n<p data-block-key=\"r2cz9\">When building AI applications, developers need the freedom to route traffic to the best model for the job without hardcoding endpoints or managing open-source proxies. <a href=\"https:\/\/docs.cloud.google.com\/api-gateway\/docs\">Google Cloud API Gateway<\/a> now offers model routing in Public Preview to solve this. It provides a lightweight, serverless ingress layer that accepts OpenAI-compatible requests and dynamically routes them to Gemini, Claude, or OpenAI OSS-GPT.<\/p>\n<p data-block-key=\"a0dae\">API Gateway can be used standalone for simple rate limiting and token tracking, or paired seamlessly with the Gemini Enterprise Agent Platform. For example, you can route your agent&#8217;s egress through Agent Gateway for strict security governance, and then pass the request to API Gateway to handle dynamic routing to Google-hosted LLMs. Here is a step-by-step guide on how to configure your routing logic.<\/p>\n<h3 data-block-key=\"zm7zh\" id=\"routing-your-traffic\"><b>Routing your traffic<\/b><\/h3>\n<p data-block-key=\"9m16r\">Setting up your model routing logic takes just a few steps:<\/p>\n<ol>\n<li data-block-key=\"u9la\"><b>Configure your routing rules:<\/b> You can map virtual model names to specific backend targets directly in your OpenAPI 3.x specification using the new <code>x-google-api-management<\/code> extension block.<\/li>\n<\/ol>\n<\/div>\n<div>\n<pre><code class=\"language-yaml\">openapi: 3.0.4&#13;\n&#13;\ninfo:&#13;\n  title: OpenAPI 3.x spec using Model Routing&#13;\n  description: Using Model Routing in an OAS 3.x spec&#13;\n  version: 1.0.0&#13;\n&#13;\nx-google-api-management:&#13;\n  backends:&#13;\n    gemini-35-flashlite:&#13;\n      address: &gt;-&#13;\n        https:\/\/aiplatform.googleapis.com\/v1\/projects\/YOUR_PROJECT_ID\/locations\/global\/publishers\/google\/models\/gemini-3.5-flash-lite:generateContent&#13;\n      deadline: 60.0&#13;\n      pathTranslation: CONSTANT_ADDRESS&#13;\n&#13;\n    anthropic-claude-opus-47:&#13;\n      address: &gt;-&#13;\n        https:\/\/aiplatform.googleapis.com\/v1\/projects\/YOUR_PROJECT_ID\/locations\/global\/publishers\/anthropic\/models\/claude-opus-4-7:rawPredict&#13;\n      deadline: 60.0&#13;\n      pathTranslation: CONSTANT_ADDRESS&#13;\n&#13;\n    openai-gpt-oss-120b:&#13;\n      address: &gt;-&#13;\n        https:\/\/aiplatform.googleapis.com\/v1\/projects\/YOUR_PROJECT_ID\/locations\/global\/endpoints\/openapi\/chat\/completions&#13;\n      deadline: 60.0&#13;\n      pathTranslation: CONSTANT_ADDRESS&#13;\n&#13;\n  ai:&#13;\n    models:&#13;\n      routing:&#13;\n        routers:&#13;\n          # Router 1: route between Gemini (default) and Claude.&#13;\n          gemini-claude-router:&#13;\n            defaultModel:&#13;\n              backend: gemini-35-flashlite&#13;\n              targetModel: google\/gemini-3.5-flash-lite&#13;\n            rules:&#13;\n              - model: \"claude-opus-4-7\"&#13;\n                backend: anthropic-claude-opus-47&#13;\n                targetModel: anthropic\/claude-opus-4-7&#13;\n&#13;\n          # Router 2: route between OpenAI GPT (default) and Gemini.&#13;\n          openai-gemini-router:&#13;\n            defaultModel:&#13;\n              backend: openai-gpt-oss-120b&#13;\n              targetModel: openai\/gpt-oss-120b-maas&#13;\n            rules:&#13;\n              - model: \"gemini-3.5-flash-lite\"&#13;\n                backend: gemini-35-flashlite&#13;\n                targetModel: google\/gemini-3.5-flash-lite&#13;\n&#13;\nservers:&#13;\n  - url: \"https:\/\/my-gateway-url.com\"&#13;\n&#13;\npaths:&#13;\n  \/v1\/chat\/gemini-claude:&#13;\n    post:&#13;\n      summary: \"Endpoint:defaults to Gemini &amp; Claude as an option.\"&#13;\n      operationId: \"chatGeminiClaude\"&#13;\n      x-google-model-router: gemini-claude-router&#13;\n      responses:&#13;\n        '200':&#13;\n          description: \"OK\"&#13;\n&#13;\n  \/v1\/chat\/openai-gemini:&#13;\n    post:&#13;\n      summary: \"Endpoint:defaults to OpenAI &amp; Gemini as an option.\"&#13;\n      operationId: \"chatOpenAIGemini\"&#13;\n      x-google-model-router: openai-gemini-router&#13;\n      responses:&#13;\n        '200':&#13;\n          description: \"OK\"<\/code><\/pre>\n<p>\n        YAML\n    <\/p>\n<\/div>\n<div>\n<p data-block-key=\"r2cz9\"><b>Note:<\/b> All backends referenced by a single router must share the same host (for example, aiplatform.googleapis.com). Routing selects a different model and path on that shared Vertex host \u2014 it does not route across different hosts.<\/p>\n<p data-block-key=\"cjbe6\">2.<b> Deploy the Gateway:<\/b> Deploy your updated API config so the Gateway is active and ready to process traffic.<\/p>\n<p data-block-key=\"820q5\">3. <b>Send standard requests:<\/b> Your application simply sends a standard OpenAI <code>POST \/v1\/chat\/gemini-claude<\/code> or <code>POST \/v1\/chat\/openai-gemini<\/code> request. The Gateway intercepts it, transcodes the payload to the native schema of the backend, and routes it on the fly. As an example (use appropriate values for <code>$API_KEY<\/code> and <code>my-gateway-url.com<\/code>) :<\/p>\n<\/div>\n<div>\n<pre><code class=\"language-shell\">curl -X POST \"https:\/\/my-gateway-url.com\/v1\/chat\/gemini-claude\" \\&#13;\n  -H \"content-type: application\/json\" \\&#13;\n  -H \"x-api-key: $API_KEY\" \\&#13;\n  -d '{&#13;\n        \"model\": \"claude-opus-4-7\",&#13;\n        \"messages\": [&#13;\n          {\"role\": \"user\", \"content\": \"Introduce yourself in 5 words\"}&#13;\n        ]&#13;\n      }'<\/code><\/pre>\n<p>\n        Shell\n    <\/p>\n<\/div>\n<div>\n<h3 data-block-key=\"2f490\" id=\"get-started\"><b>Get started<\/b><\/h3>\n<p data-block-key=\"2254c\">Model routing is now available in Public Preview for API Gateway. To stop managing proxies and start unifying your AI traffic, <a href=\"https:\/\/docs.cloud.google.com\/api-gateway\/docs\/model-routing-overview\">check out our documentation<\/a> to deploy your first model router today.<\/p>\n<\/div>\n<p><a href=\"https:\/\/developers.googleblog.com\/a-unified-api-for-ai-model-routing\/?utm_source=tldrai\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When building AI applications, developers need the freedom to route traffic to the best model for the job without hardcoding endpoints or managing open-source proxies. Google Cloud API Gateway now offers model routing in Public Preview to solve this. It provides a lightweight, serverless ingress layer that accepts OpenAI-compatible requests and dynamically routes them to [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":23105,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[143],"tags":[],"class_list":["post-23104","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/posts\/23104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/comments?post=23104"}],"version-history":[{"count":0,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/posts\/23104\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/media\/23105"}],"wp:attachment":[{"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/media?parent=23104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/categories?post=23104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/tags?post=23104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}