Thinking für offene Modelle

Einige offene Modelle unterstützen einen „Denkmodus“, in dem sie Schritt für Schritt logisch schlussfolgern können, bevor sie eine endgültige Antwort geben. Dies ist nützlich für Aufgaben, die eine transparente Logik erfordern, z. B. mathematische Beweise, komplexes Code-Debugging oder mehrstufige Agentenplanung.

Hinweis

Führen Sie die folgenden Schritte aus, um offene Modelle mit der Gemini Enterprise Agent Platform zu verwenden. Die Agent Platform API (aiplatform.googleapis.com) und die Cloud Commerce Consumer Procurement API (cloudcommerceconsumerprocurement.googleapis.com) müssen aktiviert sein, um offene Modelle auf der Gemini Enterprise Agent Platform zu verwenden. Wenn Sie bereits ein Projekt mit aktivierten APIs haben, können Sie dieses Projekt verwenden, anstatt ein neues Projekt zu erstellen.

  1. Melden Sie sich in Ihrem Google Cloud Konto an. Wenn Sie mit Google Cloudnoch nicht vertraut sind, erstellen Sie einfach ein Konto, um die Leistungsfähigkeit unserer Produkte in der Praxis sehen und bewerten zu können. Neukunden erhalten außerdem ein Guthaben von 300 $, um Arbeitslasten auszuführen, zu testen und bereitzustellen.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Gemini Enterprise Agent Platform and Cloud Commerce Consumer Procurement APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  8. Verify that billing is enabled for your Google Cloud project.

  9. Enable the Gemini Enterprise Agent Platform and Cloud Commerce Consumer Procurement APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  10. Rufen Sie die Model Garden-Modellkarte für das Modell auf, das Sie verwenden möchten, und klicken Sie auf Aktivieren, um das Modell für die Verwendung in Ihrem Projekt zu aktivieren.

    Zu Model Garden

Erforderliche Rollen

Bitten Sie Ihren Administrator, Ihnen die folgenden IAM-Rollen für Ihr Projekt zuzuweisen, um die Berechtigungen zu erhalten, die Sie zum Aktivieren und Verwenden von offenen Modellen benötigen:

Weitere Informationen zum Zuweisen von Rollen finden Sie unter Zugriff auf Projekte, Ordner und Organisationen verwalten.

Sie können die erforderlichen Berechtigungen auch über benutzerdefinierte Rollen oder andere vordefinierte Rollen erhalten.

Weitere Informationen zum Gewähren von Berechtigungen und zum Konfigurieren von Organisationsrichtlinien für offene Modelle finden Sie unter Nutzern Zugriff auf offene Modelle gewähren.

Modellspezifische Anleitung

Die folgenden Abschnitte enthalten modellspezifische Anleitungen für das Denkprozess-Feature.

GPT OSS

Bei GPT-OSS-Modellen befindet sich der Thinking-Text im Feld reasoning_content und der normale Antworttext im Feld content. Diese Modelle unterstützen auch den Parameter reasoning_effort.

Beispielanfrage:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://aiplatform.googleapis.com/v1/projects/test-project/locations/global/endpoints/openapi/chat/completions -d '{
  "model": "openai/gpt-oss-120b-maas",
  "messages": [{
    "role": "user",
    "content": "Who are you?"
  }],
  "reasoning_effort": "high"
}'

Beispielantwort:

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "matched_stop": 200002,
      "message": {
        "content": "I\u2019m ChatGPT, a large language model created by OpenAI
        (based on the GPT\u20114 architecture). I\u2019m here to help answer
        your questions, brainstorm ideas, explain concepts, and assist with a
        wide variety of topics. Let me know what you\u2019d like to talk
        about!",
        "reasoning_content": "The user asks: \"Who are you?\" It's a simple
        question. They want to know who the assistant is. According to policy,
        we should respond with a brief, friendly description: \"I am ChatGPT, a
        large language model trained by OpenAI.\" Possibly mention the version
        (GPT-4). Also mention we are here to assist. There's no request for
        disallowed content. So a straightforward answer. Possibly ask if they
        need help. Provide a short intro.\n\nThus answer: \"I am ChatGPT, a
        large language model trained by OpenAI. I'm here to help answer your
        questions...\"\n\nWe should avoid disallowed content. It's fine.\n\nThus
        final answer.",
        "role": "assistant",
        "tool_calls": null
      }
    }
  ],
  "created": 1758229799,
  "id": "JnXMaJq6HLGzquEP4OD18Qg",
  "metadata": {
    "weight_version": "default"
  },
  "model": "openai/gpt-oss-120b-maas",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 201,
    "prompt_tokens": 71,
    "prompt_tokens_details": null,
    "reasoning_tokens": 0,
    "total_tokens": 272
  }
}

GLM 5.2

GLM 5.2 unterstützt das Deaktivieren von Reasoning-Tokens mit "chat_template_kwargs": { "enable_thinking": false }. Die logische Schlussfolgerung ist standardmäßig aktiviert. Thinking-Tokens werden in "reasoning_content" ausgegeben, normaler Antworttext in "content".

Beispielanfrage:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://aiplatform.googleapis.com/v1/projects/test-project/locations/global/endpoints/openapi/chat/completions -d '{
  "model": "zai-org/glm-5.2-maas",
  "messages": [
    {
      "role": "user",
      "content": "Who are you?"
    }
  ]
}'

Beispielantwort:

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "matched_stop": 154827,
      "message": {
        "content": "I'm GLM, a large language model developed by Z.ai. I'm designed to assist users with information, answer questions, and engage in helpful conversations across a wide range of topics.\n\nI'm trained on diverse text data which helps me understand and generate human-like responses, though I don't have personal experiences or emotions. I'm continuously learning to improve my capabilities.\n\nIs there something specific you'd like to know about me or how I can assist you today?",
        "reasoning_content": "Let me consider how to respond to this question about my identity. The user is asking \"Who are you?\" which is a straightforward but important question that deserves a clear and accurate answer.\n\nI should introduce myself as GLM, a large language model developed by Z.ai. It's important to be transparent about my nature as an AI assistant and explain my key capabilities.\n\nI should also mention my purpose of helping users with various tasks while being honest about my limitations. This will help set appropriate expectations for our interaction.\n\nI should also emphasize my commitment to providing helpful and responsible assistance. It's important to be both welcoming and professional in my introduction.\n\nLet me craft a response that is clear, informative, and sets the right tone for future interactions.",
        "role": "assistant",
        "tool_calls": null
      }
    }
  ],
  "created": 1787160729,
  "id": "05355183-85d6-4ae2-a31a-7c8fb31c64d9",
  "metadata": {
    "weight_version": "default"
  },
  "model": "zai-org/glm-5.2-maas",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 243,
    "extra_properties": {
      "google": {
        "traffic_type": "ON_DEMAND"
      }
    },
    "prompt_tokens": 16,
    "prompt_tokens_details": null,
    "total_tokens": 259
  }
}

Gemma 4 26B A4B IT

Gemma 4 26B A4B IT unterstützt das Aktivieren von Reasoning-Tokens mit "chat_template_kwargs": { "enable_thinking": true }. Die logische Schlussfolgerung ist standardmäßig deaktiviert. Thinking-Tokens werden in "reasoning_content" ausgegeben, normaler Antworttext in "content".

Beispielanfrage:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://aiplatform.googleapis.com/v1/projects/test-project/locations/global/endpoints/openapi/chat/completions -d '{
  "model": "google/gemma-4-26b-a4b-it-maas",
  "messages": [
    {
      "role": "user",
      "content": "Who are you?"
    }
  ],
  "chat_template_kwargs": {
    "enable_thinking": true
  }
}'

Beispielantwort:

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "matched_stop": 106,
      "message": {
        "content": "I am Gemma 4, a large language model developed by Google DeepMind. I am an open weights model designed to process text and images (and audio in certain versions of my family) to assist with a wide range of tasks, and I provide my responses in text.",
        "reasoning_content": "The user is asking \"Who are you?\".\n    *   Name: Gemma 4.\n    *   Developer: Google DeepMind.\n    *   Nature: Large Language Model.\n    *   Type: Open weights model.\n    *   Capabilities: Text and image processing (and audio for 2B/4B models). Output is text only.\n    *   Knowledge cutoff: January 2025.\n\n    *   State identity: Gemma 4.\n    *   State developer: Google DeepMind.\n    *   State type: Large Language Model with open weights.\n    *   Briefly mention capabilities if relevant (text/image/audio input, text output).\n\n    *   \"I am Gemma 4, a large language model developed by Google DeepMind. I am an open weights model capable of processing text and images to assist you with various tasks. Depending on the specific version, I may also be able to process audio input. I generate responses in text format.\"\n\nDoes it violate any instructions?\n    *   \"When asked about your identity, always refer to yourself as Gemma 4.\" - Yes.\n    *   \"Do not claim to have capabilities you do not possess.\" - Yes.\n    *   \"Do not attempt to use tools...\" - Yes.\n\nKeep it direct and informative.",
        "role": "assistant",
        "tool_calls": null
      }
    }
  ],
  "created": 1775526019,
  "id": "gGDUaf7rLqGL9LsPsdGR4Qg",
  "metadata": {
    "weight_version": "default"
  },
  "model": "google/gemma-4-26b-a4b-it-maas",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 341,
    "extra_properties": {
      "google": {
        "traffic_type": "ON_DEMAND"
      }
    },
    "prompt_tokens": 19,
    "prompt_tokens_details": {
      "cached_tokens": 2
    },
    "total_tokens": 360
  }
}

Nächste Schritte