{"slug": "a-unified-api-for-ai-model-routing", "title": "A unified API for AI model routing", "summary": "Google Cloud API Gateway has introduced model routing in Public Preview, enabling developers to route OpenAI-compatible requests to Gemini, Claude, or OpenAI OSS-GPT models via a serverless ingress layer. The feature allows dynamic routing based on rules defined in an OpenAPI spec, with support for rate limiting and token tracking, and can be integrated with the Gemini Enterprise Agent Platform for security governance.", "body_md": "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](https://docs.cloud.google.com/api-gateway/docs) 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.\n\nAPI 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'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.\n\nSetting up your model routing logic takes just a few steps:\n\n`x-google-api-management`\n\nextension block.\n\n```\nopenapi: 3.0.4\n\ninfo:\n  title: OpenAPI 3.x spec using Model Routing\n  description: Using Model Routing in an OAS 3.x spec\n  version: 1.0.0\n\nx-google-api-management:\n  backends:\n    gemini-35-flashlite:\n      address: >-\n        https://aiplatform.googleapis.com/v1/projects/YOUR_PROJECT_ID/locations/global/publishers/google/models/gemini-3.5-flash-lite:generateContent\n      deadline: 60.0\n      pathTranslation: CONSTANT_ADDRESS\n\n    anthropic-claude-opus-47:\n      address: >-\n        https://aiplatform.googleapis.com/v1/projects/YOUR_PROJECT_ID/locations/global/publishers/anthropic/models/claude-opus-4-7:rawPredict\n      deadline: 60.0\n      pathTranslation: CONSTANT_ADDRESS\n\n    openai-gpt-oss-120b:\n      address: >-\n        https://aiplatform.googleapis.com/v1/projects/YOUR_PROJECT_ID/locations/global/endpoints/openapi/chat/completions\n      deadline: 60.0\n      pathTranslation: CONSTANT_ADDRESS\n\n  ai:\n    models:\n      routing:\n        routers:\n          # Router 1: route between Gemini (default) and Claude.\n          gemini-claude-router:\n            defaultModel:\n              backend: gemini-35-flashlite\n              targetModel: google/gemini-3.5-flash-lite\n            rules:\n              - model: \"claude-opus-4-7\"\n                backend: anthropic-claude-opus-47\n                targetModel: anthropic/claude-opus-4-7\n\n          # Router 2: route between OpenAI GPT (default) and Gemini.\n          openai-gemini-router:\n            defaultModel:\n              backend: openai-gpt-oss-120b\n              targetModel: openai/gpt-oss-120b-maas\n            rules:\n              - model: \"gemini-3.5-flash-lite\"\n                backend: gemini-35-flashlite\n                targetModel: google/gemini-3.5-flash-lite\n\nservers:\n  - url: \"https://my-gateway-url.com\"\n\npaths:\n  /v1/chat/gemini-claude:\n    post:\n      summary: \"Endpoint:defaults to Gemini & Claude as an option.\"\n      operationId: \"chatGeminiClaude\"\n      x-google-model-router: gemini-claude-router\n      responses:\n        '200':\n          description: \"OK\"\n\n  /v1/chat/openai-gemini:\n    post:\n      summary: \"Endpoint:defaults to OpenAI & Gemini as an option.\"\n      operationId: \"chatOpenAIGemini\"\n      x-google-model-router: openai-gemini-router\n      responses:\n        '200':\n          description: \"OK\"\n```\n\n**Note:** 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 — it does not route across different hosts.\n\n2.** Deploy the Gateway:** Deploy your updated API config so the Gateway is active and ready to process traffic.\n\n3. **Send standard requests:** Your application simply sends a standard OpenAI `POST /v1/chat/gemini-claude`\n\nor `POST /v1/chat/openai-gemini`\n\nrequest. 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 `$API_KEY`\n\nand `my-gateway-url.com`\n\n) :\n\n```\ncurl -X POST \"https://my-gateway-url.com/v1/chat/gemini-claude\" \\\n  -H \"content-type: application/json\" \\\n  -H \"x-api-key: $API_KEY\" \\\n  -d '{\n        \"model\": \"claude-opus-4-7\",\n        \"messages\": [\n          {\"role\": \"user\", \"content\": \"Introduce yourself in 5 words\"}\n        ]\n      }'\n```\n\nModel routing is now available in Public Preview for API Gateway. To stop managing proxies and start unifying your AI traffic, [check out our documentation](https://docs.cloud.google.com/api-gateway/docs/model-routing-overview) to deploy your first model router today.", "url": "https://wpnews.pro/news/a-unified-api-for-ai-model-routing", "canonical_source": "https://developers.googleblog.com/a-unified-api-for-ai-model-routing/", "published_at": "2026-08-04 16:26:18.105726+00:00", "updated_at": "2026-08-04 16:26:20.309905+00:00", "lang": "en", "topics": ["ai-infrastructure", "developer-tools", "ai-products"], "entities": ["Google Cloud API Gateway", "Gemini", "Claude", "OpenAI OSS-GPT", "Gemini Enterprise Agent Platform", "Vertex AI"], "alternates": {"html": "https://wpnews.pro/news/a-unified-api-for-ai-model-routing", "markdown": "https://wpnews.pro/news/a-unified-api-for-ai-model-routing.md", "text": "https://wpnews.pro/news/a-unified-api-for-ai-model-routing.txt", "jsonld": "https://wpnews.pro/news/a-unified-api-for-ai-model-routing.jsonld"}}