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 customFormattercomponent in theModelCreationContexttakes precedence, e.g.GLMMultiAgentFormatter) - Native structured output defaults to disabled, because the GLM
response_formatonly supportsjson_object(notjson_schema); the agent falls back to thegenerate_responsetool 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
- Specified by:
providerIdin interfaceio.agentscope.core.model.spi.ModelProvider
-
supports
- Specified by:
supportsin interfaceio.agentscope.core.model.spi.ModelProvider
-
create
- Specified by:
createin interfaceio.agentscope.core.model.spi.ModelProvider
-
create
public io.agentscope.core.model.Model create(String modelId, io.agentscope.core.model.ModelCreationContext context) - Specified by:
createin interfaceio.agentscope.core.model.spi.ModelProvider
-