Class GLMModelProvider

java.lang.Object
io.agentscope.extensions.model.openai.compat.glm.GLMModelProvider
All Implemented Interfaces:
io.agentscope.core.model.spi.ModelProvider

public final class GLMModelProvider extends Object implements io.agentscope.core.model.spi.ModelProvider
Zhipu AI (Z.ai) GLM provider registered through ServiceLoader.

GLM exposes an OpenAI-compatible Chat Completions endpoint, so this provider creates OpenAIChatModel instances preconfigured for GLM:

  • Base URL defaults to https://open.bigmodel.cn/api/paas/v4
  • Formatter defaults to GLMFormatter (a custom Formatter component in the ModelCreationContext takes precedence, e.g. GLMMultiAgentFormatter)
  • Native structured output defaults to disabled, because the GLM response_format only supports json_object (not json_schema); the agent falls back to the generate_response tool instead

The API key is taken from ModelCreationContext.getApiKey(), then from the GLM_API_KEY environment variable, then from ZHIPUAI_API_KEY.

Usage:


 ReActAgent agent = ReActAgent.builder()
     .name("assistant")
     .model("glm:glm-5.2") // resolved by ModelRegistry through this provider
     .build();
 
  • Constructor Details

    • GLMModelProvider

      public GLMModelProvider()
  • Method Details

    • providerId

      public String providerId()
      Specified by:
      providerId in interface io.agentscope.core.model.spi.ModelProvider
    • supports

      public boolean supports(String modelId)
      Specified by:
      supports in interface io.agentscope.core.model.spi.ModelProvider
    • create

      public io.agentscope.core.model.Model create(String modelId)
      Specified by:
      create in interface io.agentscope.core.model.spi.ModelProvider
    • create

      public io.agentscope.core.model.Model create(String modelId, io.agentscope.core.model.ModelCreationContext context)
      Specified by:
      create in interface io.agentscope.core.model.spi.ModelProvider