xAI

Grok 4 API

US xAI
在 Playground 試用 → 取得 API 金鑰

Grok 4 是 xAI 的通用模型。可透過 MeshTok 統一 API 使用。

圖片推理工具JSON旗艦

定價 (官方列表,每 1M 個 Token)

輸入
$3.00/M
輸出
$15.00/M

規格

上下文視窗256K 代幣 輸入模態圖片 串流 API相容 OpenAI

如何使用 Grok 4

可直接取代 OpenAI。只需變更 base_url 和 model。

# Python - pip install openai
from openai import OpenAI

client = OpenAI(
    base_url="https://meshtok.com/v1",
    api_key="sk-your-MeshTok-key",
)

resp = client.chat.completions.create(
    model="x-ai/grok-4",
    messages=[{"role":"user","content":"Hello!"}],
)
print(resp.choices[0].message.content)
# cURL
curl https://meshtok.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your-MeshTok-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"x-ai/grok-4","messages":[{"role":"user","content":"Hello!"}]}'

相關模型

其他您可能考慮的模型。