推理 API

模型

查看 Markdown

列出模型

/v1/models

列出通过身份验证的 API 密钥可用的所有模型,包括模型名称(ID)、创建时间和价格。

响应体

dataarray<object>

(对象数组,必填)— 包含简要信息的模型列表。

objectstring

(string,必填)— `data` 字段的对象类型,始终为 `"list"`。

Exampletext

text

No parameters.
Exampletext

text

{
  "data": [
    {
      "id": "latest",
      "aliases": [],
      "context_length": 131072,
      "created": 1776556800,
      "object": "model",
      "owned_by": "xai",
      "prompt_text_token_price": 12500,
      "cached_prompt_text_token_price": 2000,
      "prompt_image_token_price": 12500,
      "completion_text_token_price": 25000
    },
    {
      "id": "grok-420-reasoning",
      "aliases": [],
      "context_length": 256000,
      "created": 1768003200,
      "object": "model",
      "owned_by": "xai",
      "prompt_text_token_price": 20000,
      "cached_prompt_text_token_price": 2000,
      "prompt_image_token_price": 0,
      "completion_text_token_price": 80000,
      "prompt_text_token_price_long_context": 40000,
      "completion_text_token_price_long_context": 160000,
      "long_context_threshold": 128000,
      "capabilities": {
        "reasoning_effort": [
          "low",
          "medium",
          "high",
          "xhigh"
        ],
        "default_reasoning_effort": "high"
      }
    },
    {
      "id": "grok-imagine-image",
      "aliases": [],
      "context_length": 1024,
      "created": 1769472000,
      "object": "model",
      "owned_by": "xai",
      "image_price": 200000000
    }
  ],
  "object": "list"
}

获取模型

/v1/models/{model_id}

根据 model_id 获取模型信息,包括价格。

路径参数

model_idstring

(字符串,必填)— 要获取的模型 ID。

响应体

aliasesarray<string>

(字符串数组,必填)— 用户可在请求的 `model` 字段中使用的模型别名 ID。

createdinteger

(整数,必填)— 模型创建时间的 Unix 时间戳。

idstring

(字符串,必填)— 模型 ID,可从 <https://console.x.ai/team/default/models> 或 <https://docs.x.ai/docs/models>

objectstring

(字符串,必填)— 对象类型,始终为 `"model"`。

owned_bystring

(字符串,必填)— 模型的所有者。

pricingarray<object>

(array<object>)— 按(quality, resolution)tier 列出的每张图像价格(图像生成 模型)。当模型对所有质量采用相同价格时省略 (见 `image_price`)。

Exampletext

text

No parameters.
Exampletext

text

{
  "id": "latest",
  "created": 1776556800,
  "object": "model",
  "owned_by": "xai",
  "prompt_text_token_price": 12500,
  "cached_prompt_text_token_price": 2000,
  "prompt_image_token_price": 12500,
  "completion_text_token_price": 25000
}

列出语言模型

/v1/language-models

列出通过身份验证的 API 密钥可用的所有聊天和图像理解模型的完整信息。与 /v1/models 相比,额外信息包括模态、fingerprint 和别名。

响应体

modelsarray<object>

(对象数组,必填)— 可用语言模型数组。

Exampletext

text

No parameters.
Exampletext

text

{
  "models": [
    {
      "id": "latest",
      "fingerprint": "fp_777a9f8466",
      "created": 1776556800,
      "object": "model",
      "owned_by": "xai",
      "version": "1.0",
      "input_modalities": [
        "text",
        "image"
      ],
      "output_modalities": [
        "text"
      ],
      "prompt_text_token_price": 12500,
      "cached_prompt_text_token_price": 2000,
      "prompt_image_token_price": 12500,
      "completion_text_token_price": 25000,
      "search_price": 0,
      "prompt_text_token_price_long_context": 0,
      "cached_prompt_text_token_price_long_context": 0,
      "completion_text_token_price_long_context": 0,
      "long_context_threshold": 0,
      "aliases": [
        "grok-4.3-latest"
      ]
    },
    {
      "id": "grok-420-reasoning",
      "fingerprint": "fp_5319828d69",
      "created": 1768003200,
      "object": "model",
      "owned_by": "xai",
      "version": "1.0",
      "input_modalities": [
        "text"
      ],
      "output_modalities": [
        "text"
      ],
      "prompt_text_token_price": 20000,
      "cached_prompt_text_token_price": 2000,
      "prompt_image_token_price": 0,
      "completion_text_token_price": 80000,
      "search_price": 0,
      "prompt_text_token_price_long_context": 40000,
      "cached_prompt_text_token_price_long_context": 0,
      "completion_text_token_price_long_context": 160000,
      "long_context_threshold": 128000,
      "aliases": [],
      "capabilities": {
        "reasoning_effort": [
          "low",
          "medium",
          "high",
          "xhigh"
        ],
        "default_reasoning_effort": "high"
      }
    }
  ]
}

获取语言模型

/v1/language-models/{model_id}

根据 model_id 获取聊天或图像理解模型的完整信息。

路径参数

model_idstring

(字符串,必填)— 要获取的模型 ID。

响应体

aliasesarray<string>

(字符串数组,必填)— 用户可在请求的 `model` 字段中使用的模型别名 ID。

cached_prompt_text_token_priceinteger

(integer,必填)— 之前已缓存的 prompt 文本 token 价格(单位:每 1 亿 token 的 USD 美分)。

cached_prompt_text_token_price_long_contextinteger

(integer,必填)— 长上下文请求中已缓存 prompt 文本 token 的价格(单位:每 1 亿 token 的 USD 美分)。 为 0 时回退到 cached_prompt_text_token_price。

completion_text_token_priceinteger

(integer,必填)— completion 文本 token 的价格(单位:每 1 亿 token 的 USD 美分)。

completion_text_token_price_long_contextinteger

(integer,必填)— 长上下文请求中 completion 文本 token 的价格(单位:每 1 亿 token 的 USD 美分)。 为 0 时使用标准的 completion_text_token_price。

createdinteger

(integer,必填)— 模型创建时间的 Unix 时间戳。

fingerprintstring

(字符串,必填)— 托管该模型的 xAI 系统配置指纹。

idstring

(字符串,必填)— 模型 ID,可从 <https://console.x.ai/team/default/models> 或 <https://docs.x.ai/docs/models>

input_modalitiesarray<string>

(字符串数组,必填)— 模型支持的输入模态,例如 `"text"`、`"image"`。

long_context_thresholdinteger

(整数,必填)— 适用长上下文价格的 token 数量下限。 为 0 时,该模型没有长上下文定价层级。

objectstring

(字符串,必填)— 对象类型,始终为 `"model"`。

output_modalitiesarray<string>

(字符串数组,必填)— 模型支持的输出模态,例如 `"text"`、`"image"`。

owned_bystring

(字符串,必填)— 模型的所有者。

prompt_image_token_priceinteger

(integer,必填)— prompt 图像 token 的价格(单位:每 1 亿 token 的 USD 美分)。

prompt_text_token_priceinteger

(integer,必填)— prompt 文本 token 的价格(单位:每 1 亿 token 的 USD 美分)。

prompt_text_token_price_long_contextinteger

(integer,必填)— 长上下文请求中 prompt 文本 token 的价格(单位:每 1 亿 token 的 USD 美分)。 为 0 时,所有上下文长度都使用标准 prompt_text_token_price。

search_priceinteger

(integer,必填)— 搜索价格(单位:每 1 亿次搜索的 USD 美分)。

versionstring

(字符串,必填)— 模型版本。

Exampletext

text

No parameters.
Exampletext

text

{
  "id": "latest",
  "fingerprint": "fp_156d35dcaa",
  "created": 1743724800,
  "object": "model",
  "owned_by": "xai",
  "version": "1.0.0",
  "input_modalities": [
    "text"
  ],
  "output_modalities": [
    "text"
  ],
  "prompt_text_token_price": 20000,
  "cached_prompt_text_token_price": 0,
  "prompt_image_token_price": 0,
  "completion_text_token_price": 100000,
  "aliases": [
    "grok-4",
    "grok-4-latest"
  ]
}

列出图像生成模型

/v1/image-generation-models

列出通过身份验证的 API 密钥可用的所有图像生成模型的完整信息。与 /v1/models 相比,额外信息包括模态、fingerprint 和别名。

响应体

modelsarray<object>

(对象数组,必填)— 可用图像生成模型数组。

Exampletext

text

No parameters.
Exampletext

text

{
  "models": [
    {
      "id": "grok-imagine-image",
      "fingerprint": "fp_ca78641a52",
      "max_prompt_length": 1024,
      "created": 1738961600,
      "object": "model",
      "owned_by": "xai",
      "version": "1.0.0",
      "prompt_text_token_price": 100000,
      "prompt_image_token_price": 100000,
      "generated_image_token_price": 100000,
      "aliases": []
    }
  ]
}

获取图像生成模型

/v1/image-generation-models/{model_id}

根据 model_id 获取图像生成模型的完整信息。

路径参数

model_idstring

(字符串,必填)— 要获取的模型 ID。

响应体

aliasesarray<string>

(字符串数组,必填)— 用户可在请求的 `model` 字段中使用的模型别名 ID。

createdinteger

(整数,必填)— 模型创建时间的 Unix 时间戳。

fingerprintstring

(字符串,必填)— 托管该模型的 xAI 系统配置指纹。

idstring

(字符串,必填)— 模型 ID。

image_priceinteger

(integer,必需)— 单张图像价格,单位为 USD cents。 默认 tier:默认(1k)分辨率下的 medium quality。完整质量/分辨率矩阵请参阅 `pricing`。

input_modalitiesarray<string>

(字符串数组,必填)— 模型支持的输入模态。

max_prompt_lengthinteger

(整数,必填)

objectstring

(字符串,必填)— 对象类型,始终为 `"model"`。

output_modalitiesarray<string>

(字符串数组,必填)— 模型支持的输出模态。

owned_bystring

(字符串,必填)— 模型的所有者。

pricingarray<object>

(array<object>)— 按(quality, resolution)tier 列出的每张图像价格。模型支持的每个组合对应一个条目;当模型对所有质量采用相同价格时省略(见 `image_price`)。

versionstring

(字符串,必填)— 模型版本。

Exampletext

text

No parameters.
Exampletext

text

{
  "id": "grok-imagine-image",
  "fingerprint": "fp_ca78641a52",
  "max_prompt_length": 1024,
  "created": 1737961600,
  "object": "model",
  "owned_by": "xai",
  "version": "1.0.0",
  "prompt_text_token_price": 100000,
  "prompt_image_token_price": 100000,
  "generated_image_token_price": 100000,
  "aliases": []
}

列出视频生成模型

/v1/video-generation-models

列出通过身份验证的 API 密钥可用的所有视频生成模型的完整信息。

响应体

modelsarray<object>

(对象数组,必填)— 可用视频生成模型数组。

Exampletext

text

No parameters.
Exampletext

text

{
  "models": [
    {
      "id": "grok-imagine-video",
      "fingerprint": "fp_898ae9f31c",
      "created": 1743724800,
      "object": "model",
      "owned_by": "xai",
      "version": "1.0.0",
      "input_modalities": [
        "text",
        "image"
      ],
      "output_modalities": [
        "video"
      ],
      "aliases": []
    }
  ]
}

获取视频生成模型

/v1/video-generation-models/{model_id}

根据 model_id 获取视频生成模型的完整信息。

路径参数

model_idstring

(字符串,必填)— 要获取的模型 ID。

响应体

aliasesarray<string>

(字符串数组,必填)— 用户可在请求的 `model` 字段中使用的模型别名 ID。

createdinteger

(整数,必填)— 模型创建时间的 Unix 时间戳。

fingerprintstring

(字符串,必填)— 托管该模型的 xAI 系统配置指纹。

idstring

(字符串,必填)— 模型 ID。

input_modalitiesarray<string>

(字符串数组,必填)— 模型支持的输入模态(例如 "text"、"image"; 接受参考音频的模型还支持 "audio")。

objectstring

(字符串,必填)— 对象类型,始终为 `"model"`。

output_modalitiesarray<string>

(字符串数组,必填)— 模型支持的输出模态(例如 "video")。

owned_bystring

(字符串,必填)— 模型的所有者。

versionstring

(字符串,必填)— 模型版本。

Exampletext

text

No parameters.
Exampletext

text

{
  "id": "grok-imagine-video",
  "fingerprint": "fp_898ae9f31c",
  "created": 1743724800,
  "object": "model",
  "owned_by": "xai",
  "version": "1.0",
  "input_modalities": [
    "text",
    "image"
  ],
  "output_modalities": [
    "video"
  ],
  "aliases": []
}

最后更新:2026 年 4 月 13 日