KI-Anwendungen verwenden KI-Modelle, um eine bestimmte Aufgabe auszuführen.
Eine KI-Anwendung kann beispielsweise ein KI-Modell verwenden, um Dokumente zusammenzufassen, oder eine Chatoberfläche sein, die eine Vektordatenbank nutzt, um mehr Kontext abzurufen.
KI-Agents kombinieren die Intelligenz fortschrittlicher KI-Modelle mit dem Zugriff auf Tools, um Aktionen im Namen des Nutzers und unter seiner Kontrolle auszuführen.
Sie können KI-Agents als Cloud Run-Dienste implementieren, um eine Reihe asynchroner Aufgaben zu orchestrieren und Nutzern Informationen bereitzustellen. Dazu sind mehrere Anfrage-Antwort-Interaktionen erforderlich.
Architektur für KI-Agenten in Cloud Run
Eine typische KI-Agent-Architektur, die in Cloud Run bereitgestellt wird, kann mehrere Komponenten aus Google Cloud und außerhalb von Google Cloudumfassen:
Bereitstellung und Orchestrierung:Ein Cloud Run-Dienst fungiert als skalierbarer API-Endpunkt und kann mehrere gleichzeitige Nutzer durch automatische, bedarfsgesteuerte und schnelle Skalierung von Instanzen verarbeiten. In diesem Dienst wird die Kernlogik des Agents ausgeführt, häufig mit einem KI-Orchestrierungs-Framework wie LangGraph oder dem Agent Development Kit (ADK). Diese Ebene koordiniert Aufrufe an andere Komponenten. Cloud Run unterstützt das Streamen von HTTP-Antworten zurück an den Nutzer über WebSockets. Die integrierte Dienstidentität von Cloud Run bietet sichere und automatische Anmeldedaten für den Aufruf von Google Cloud APIs, ohne dass API-Schlüssel verwaltet werden müssen.
KI-Modelle:Die Orchestrierungsebene ruft Modelle für die Reasoning-Funktionen auf. Beispiele:
Langzeitspeicher zum Speichern des Unterhaltungsverlaufs oder zum Speichern der Einstellungen des Nutzers kann implementiert werden, indem Cloud Run mit Firestore verbunden wird, einer skalierbaren, serverlosen NoSQL-Datenbank.
Datenbanken und Abruf:Für Retrieval-Augmented Generation (RAG) oder zum Abrufen strukturierter Daten:
Mit der pgvector-Erweiterung können Sie Cloud Run mit Vektordatenbanken wie Cloud SQL for PostgreSQL oder AlloyDB for PostgreSQL verbinden, um bestimmte Informationen zu Entitäten abzufragen oder Ähnlichkeitssuchen für Einbettungen durchzuführen.
Tools:Der Orchestrator verwendet Tools, um bestimmte Aufgaben auszuführen, für die Modelle nicht geeignet sind, oder um mit externen Diensten, APIs oder Websites zu interagieren. Beispiel:
Einfache Dienstprogramme: Genaue mathematische Berechnungen, Zeitumrechnungen oder ähnliche Dienstprogramme können im orchestrating Cloud Run-Dienst ausgeführt werden.
API-Aufrufe: Aufrufe anderer interner oder Drittanbieter-APIs (Lese- oder Schreibzugriff).
Bilder oder Diagramme erstellen: Mit Modellen zur Bilderstellung oder Diagrammbibliotheken lassen sich schnell und effektiv visuelle Inhalte erstellen.
Browser- und Betriebssystemautomatisierung: Führen Sie ein Headless- oder ein vollständiges grafisches Betriebssystem in Containerinstanzen aus, damit der Agent im Web surfen, Informationen von Websites extrahieren oder Aktionen durch Klicks und Tastatureingaben ausführen kann. Der Cloud Run-Dienst gibt Pixel von Bildschirmen zurück. Verwenden Sie Bibliotheken wie Puppeteer, um den Browser zu steuern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-02 (UTC)."],[],[],null,["# Host AI apps and agents on Cloud Run\n\nThis page highlights some use cases for using Cloud Run as a\nhosting platform for the following AI use cases:\n\n- [AI applications](#ai-apps)\n- [AI agents](#ai-agents)\n\nHost AI applications on Cloud Run\n---------------------------------\n\nAI applications use AI models to operate or perform a specific task.\nFor example, an AI application can use an AI model to summarize documents, or be a chat interface that uses a vector database to retrieve more context.\n\nCloud Run is one of the [application hosting infrastructures](/docs/generative-ai/choose-models-infra-for-ai) that provides a fully managed environment for your AI application workloads.\nCloud Run integrates with AI models such as [Gemini API](/vertex-ai/generative-ai/docs/model-reference/inference), [Vertex AI endpoints](/vertex-ai/docs/general/deployment), or models hosted on [a GPU-enabled Cloud Run service](/run/docs/configuring/services/gpu).\nCloud Run also integrates with [Cloud SQL for PostgreSQL](/sql/docs/postgres/connect-run) and [AlloyDB for PostgreSQL](/alloydb/docs/quickstart/integrate-cloud-run), which are two databases offering the `pgvector` extension for Retrieval-Augmented Generation (RAG).\n\nHost AI Agents on Cloud Run\n---------------------------\n\nAI agents combine the intelligence of advanced AI models, with access to tools,\nto take actions on behalf of the user and under the user's control.\n\nYou can implement AI agents as Cloud Run services to orchestrate a set\nof asynchronous tasks and provide information to users, through involving multiple\nrequest-response interactions.\n\n### AI agent on Cloud Run architecture\n\nA typical AI agent architecture deployed on Cloud Run can involve\nseveral components from Google Cloud and outside of Google Cloud:\n\n1. **Serving and Orchestration:** A Cloud Run service acts as a scalable API endpoint, and can handle multiple concurrent users through automatic, on-demand, rapid scaling of instances. This service runs the core agent logic, often using an AI orchestration framework like [LangGraph](https://www.langchain.com/langgraph) or [Agent Development Kit (ADK)](https://google.github.io/adk-docs/). This layer coordinates calls to other components. Cloud Run supports [streaming HTTP responses](/run/docs/triggering/https-request#streaming) back to the user using [WebSockets](/run/docs/triggering/websockets). Cloud Run's built-in [service identity](/run/docs/securing/service-identity) provides secure and automatic credentials for calling Google Cloud APIs without managing API keys.\n\n2. **AI Models:** The orchestration layer calls models for reasoning capabilities. These can be:\n\n - The [Gemini API](/vertex-ai/generative-ai/docs/model-reference/inference)\n - Custom models or other foundation models deployed on [Vertex AI endpoints](/vertex-ai/docs/general/deployment)\n - Your own fine-tuned models served from a separate [GPU-enabled-Cloud Run service](/run/docs/configuring/services/gpu)\n3. **Memory:** Agents often need memory to retain context and learn from past interactions.\n\n - **Short-term memory** can be implemented by [connecting Cloud Run to Memorystore for Redis](/memorystore/docs/redis/connect-redis-instance-cloud-run).\n - **Long-term memory** for storing the conversational history or remembering the user's preferences can be implemented by connecting Cloud Run to [Firestore](/firestore/docs), a scalable, serverless NoSQL database.\n4. **Databases and Retrieval:** For Retrieval-Augmented Generation (RAG) or fetching structured data:\n\n - Query specific entity information or perform similarity searches over embeddings by connecting Cloud Run to vector databases like [Cloud SQL for PostgreSQL](/sql/docs/postgres/connect-run) or [AlloyDB for PostgreSQL](/alloydb/docs/quickstart/integrate-cloud-run) with the `pgvector` extension.\n5. **Tools:** The orchestrator uses tools to perform specific tasks that models are not suited for or to interact with external services, APIs, or websites. This can include:\n\n - Basic utilities: Precise math calculations, time conversions, or other similar utilities can run in the orchestrating Cloud Run service.\n - API calling: Make calls to other internal or third-party APIs (read or write access).\n - Image or chart generation: Use image generation models or run chart libraries to quickly and effectively create visual content.\n - Browser and OS automation: Run a headless or a full graphical Operating System within container instances to allow the agent to browse the web, extract information from websites, or perform actions using clicks and keyboard input. The Cloud Run service returns pixels of screens. Use libraries like [Puppeteer](https://pptr.dev/) to control the browser.\n - Code execution: Cloud Run provides a [secure environment with multi-layered sandboxing](/run/docs/securing/security#compute-security) and can be configured to the code execution service with minimal or no [IAM permissions](/run/docs/securing/service-identity). A [Cloud Run job](/run/docs/create-jobs) can be used to execute code asynchronously and a [Cloud Run service](/run/docs/deploying) with a [concurrency of 1](/run/docs/configuring/concurrency) can be used for synchronous execution.\n\nWhat's next\n-----------\n\n- Watch [Build AI agents on Cloud Run](https://www.youtube.com/watch?v=GwL8e5Z1tl4).\n- Try the [codelab](https://codelabs.developers.google.com/codelabs/build-and-deploy-a-langchain-app-on-cloud-run) for learning how to build and deploy a LangChain app to Cloud Run.\n- Learn how to [deploy Agent Development Kit (ADK) to Cloud Run](https://google.github.io/adk-docs/deploy/cloud-run/).\n- Find ready-to-use agent samples in [Agent Development Kit (ADK) samples](https://github.com/google/adk-samples).\n- [Host Model Context Protocol (MCP) servers on Cloud Run](/run/docs/host-mcp-servers)."]]