gRPC API

概览

查看 Markdown

xAI gRPC API 通过 gRPC 提供与 REST API 相同的模型和服务。所有服务的基础 URL 为 api.x.ai,每次调用都必须携带请求头 Authorization: Bearer <your xAI API key> 进行身份验证。

protobuf 定义发布在 xai-org/xai-protoxAI Python SDKxai-sdk)原生使用 gRPC;安装命令为 pip install xai-sdk 进行身份验证。

使用 buf curl

克隆 Protocol Buffers 定义,然后使用 buf curl 调用 API:

Bash

git clone https://github.com/xai-org/xai-proto.git
cd xai-proto

以下所有 buf curl 示例均假定你在克隆的 xai-proto 目录中运行。

服务


最后更新:2026 年 9 月 2 日