diff --git a/app/_how-tos/ai-gateway/use-claude-code-with-ai-gateway-vertex.md b/app/_how-tos/ai-gateway/use-claude-code-with-ai-gateway-vertex.md new file mode 100644 index 00000000000..a10ff91d0ef --- /dev/null +++ b/app/_how-tos/ai-gateway/use-claude-code-with-ai-gateway-vertex.md @@ -0,0 +1,185 @@ +--- +title: Route Claude CLI traffic through {{site.ai_gateway}} and Vertex AI +permalink: /ai-gateway/use-claude-code-with-ai-gateway-vertex/ +content_type: how_to + +related_resources: + - text: "{{site.ai_gateway}}" + url: /ai-gateway/ + +description: Configure {{site.ai_gateway}} to proxy Claude CLI traffic using Google Vertex AI models + +products: + - ai-gateway + +works_on: + - konnect + +tools: + - kongctl + +min_version: + ai-gateway: '2.0' + +tags: + - ai + - vertex-ai + +tldr: + q: How do I run Claude CLI through {{site.ai_gateway}} against a Vertex AI model? + a: Create an AI Provider entity to store your GCP service account credentials, create an AI Model entity with an Anthropic-compatible format that routes to a Gemini model on Vertex AI through that provider, then point Claude CLI's `ANTHROPIC_BASE_URL` at your local {{site.ai_gateway}} endpoint so all LLM requests pass through the gateway for monitoring and control. + +prereqs: + inline: + - title: Vertex + content: | + Before you begin, you must get the following credentials from Google Cloud: + + - **Service Account Key**: A JSON key file for a service account with Vertex AI permissions + - **Project ID**: Your Google Cloud project identifier + - **Location ID**: The region where your Vertex AI endpoint is deployed (for example, `us-central1`) + - **API Endpoint**: The Vertex AI API endpoint URL (typically `https://{location}-aiplatform.googleapis.com`) + + Export these values as environment variables: + ```sh + export GEMINI_API_KEY="" + export GCP_PROJECT_ID="" + export GEMINI_LOCATION_ID="" + export GEMINI_API_ENDPOINT="" + ``` + icon_url: /assets/icons/vertex.svg + - title: Claude Code CLI + icon_url: /assets/icons/third-party/claude.svg + include_content: prereqs/claude-code + +--- + +## Create an AI Provider entity + +Create an [AI Model Provider](/ai-gateway/entities/ai-model-provider/) entity to define your connection to Vertex AI and store your GCP service account credentials: + +```sh +kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" <