KimiModelProvider
public final class KimiModelProvider implements ModelProvider
io/agentscope/extensions/model/openai/compat/kimi/KimiModelProvider.java:57–113Kimi 模型提供者,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.openai.compat.kimi 包,实现 ModelProvider。核心成员包括 providerId、supports、create。
Kimi (Moonshot AI) provider registered through java.util.ServiceLoader.
Kimi exposes an OpenAI-compatible Chat Completions endpoint, so this provider creates
OpenAIChatModel instances preconfigured for Kimi:
-
Base URL defaults to
https://api.moonshot.cn/v1 -
Formatter defaults to
KimiFormatter(a customFormattercomponent in theModelCreationContexttakes precedence, e.g.KimiMultiAgentFormatter) -
Native structured output defaults to disabled; the agent falls back to the
generate_responsetool instead -
Native structured output alongside tools defaults to disabled, because Kimi prioritises
response_formatover tool invocations when both are present
The API key is taken from ModelCreationContext#getApiKey(), then from the
MOONSHOT_API_KEY environment variable, then from KIMI_API_KEY.
Usage:
`ReActAgent agent = ReActAgent.builder()
.name("assistant")
.model("kimi:kimi-k3") // resolved by ModelRegistry through this provider
.build();
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String providerId() | 返回提供者标识。 Returns the provider id. |
public boolean supports(String modelId) | 设置支持。 Performs the supports operation. |
public Model create(String modelId) | 创建并返回实例。 Creates and returns an instance. |
public Model create(String modelId, ModelCreationContext context) | 创建并返回实例。 Creates and returns an instance. |
方法详情Method Detail
providerId
public String providerId()
返回提供者标识。
Returns the provider id.
Stringio/agentscope/extensions/model/openai/compat/kimi/KimiModelProvider.java:63–66supports
public boolean supports(String modelId)
设置支持。
Performs the supports operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
booleanio/agentscope/extensions/model/openai/compat/kimi/KimiModelProvider.java:68–71create
public Model create(String modelId)
创建并返回实例。
Creates and returns an instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
Modelio/agentscope/extensions/model/openai/compat/kimi/KimiModelProvider.java:73–76create
public Model create(String modelId, ModelCreationContext context)
创建并返回实例。
Creates and returns an instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
context | ModelCreationContext | 上下文(类型 `ModelCreationContext`)。The context. |
Modelio/agentscope/extensions/model/openai/compat/kimi/KimiModelProvider.java:78–112