AS AgentScopeAPI 手册 / API Reference
类class agentscope.model

XAIChatModel

class XAIChatModel(ChatModelBase)
源码Source agentscope/model/_xai/_model.py:30–454

xAI 聊天模型使用官方xai_sdkgRPC 客户端。位于 agentscope.model 包,继承自 ChatModelBase。

This model provides native access to xAI-specific features such as server-side agentic tools (web search, X search, code execution) and reasoning effort control, which are not available through the OpenAI-compatible REST endpoint.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Parameters类class
参数用于 xAI 聊天模型。
The parameters for the xAI chat model.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(credential: XAICredential, model: str, parameters: 'XAIChatModel.Parameters | None' = None, stream: bool =…
初始化 `XAIChatModel` 实例。
Initialize the xAI chat model.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
typeLiteral['xai_chat']
类型字段。
'xai_chat'

构造器详情Constructor Detail

XAIChatModel

def __init__(credential: XAICredential, model: str, parameters: 'XAIChatModel.Parameters | None' = None, stream: bool = True, max_retries: int = 3, retry_delay: float = 1.0, context_size: int = 131072, formatter: XAIChatFormatter | None = None, client_kwargs: dict[str, Any] | None = None) -> None

初始化 XAIChatModel 实例。

Initialize the xAI chat model.

参数Parameters
名称Name类型Type说明Description
credentialXAICredential凭证对象(类型 `XAICredential`)。The xAI credential used to authenticate API calls.
modelstr模型实例(类型 `str`)。The xAI model name, e.g. `grok-3` or `grok-3-mini`.
parameters默认default None'XAIChatModel.Parameters | None'参数(类型 `'XAIChatModel.Parameters | None'`)。The xAI API parameters. When `None`, the default parameters will be used.
stream默认default Truebool判断是否到启用流式输出。Whether to enable streaming output.
max_retries默认default 3int最大重试次数(类型 `int`)。The maximum number of retries for the xAI API.
retry_delay默认default 1.0float重试延迟(类型 `float`)。Seconds to sleep between retry attempts.
context_size默认default 131072int上下文大小(类型 `int`)。The model context size used for context compression.
formatter默认default NoneXAIChatFormatter | None格式化器(类型 `XAIChatFormatter | None`)。The formatter that converts `Msg` objects to xai_sdk proto messages. When `None`, an `XAIChatFormatter` instance will be used.
client_kwargs默认default Nonedict[str, Any] | None客户端关键字参数(类型 `dict[str, Any] | None`)。Extra keyword arguments forwarded to `xai_sdk.AsyncClient` (e.g. `timeout`, `metadata`, `channel_options`). Keys that overlap with credential-derived arguments (such as `api_key` or `api_host`) take precedence over the credential values.
源码Source agentscope/model/_xai/_model.py:93–145

属性详情Attribute Detail

type

Literal['xai_chat'] = 'xai_chat'

类型字段。声明为 Literal['xai_chat']。

The type field.

源码Source agentscope/model/_xai/_model.py:90

嵌套类详情Nested Class Detail

Parameters

class Parameters

参数用于 xAI 聊天模型。位于 agentscope.model 包。

The parameters for the xAI chat model. Declared in agentscope.model.

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.