Seedance 2.0 | Special Offer ✦ 10% OFF NOW
xai

x-ai/grok-4

x-ai/grok-4

256,000 context · $3.00/M input tokens · $15.00/M output tokens

Grok 4 is xAI's latest reasoning model with a 256k context window. It supports parallel tool calling, structured outputs, and both image and text inputs. Note that reasoning is not...

定价

按量付费

无需预付费用,仅按实际使用量付费

输入
128K $3.00 / M Tokens
> 128K $6.00 / M Tokens
输出
128K $15.00 / M Tokens
> 128K $30.00 / M Tokens

API 使用

使用以下代码示例接入我们的 API:

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://llm.wavespeed.ai/v1"
)

response = client.chat.completions.create(
    model="x-ai/grok-4",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

模型介绍

X-Ai grok-4

x-ai grok-4


Why It Looks Great

  • Large Language Model architecture for efficient processing
  • 256000 context window for long document handling
  • Competitive pricing at $3.3/$16.5 per million tokens

Key Features

  • Context Window: 256000 tokens
  • Max Output: 4096 tokens
  • Vision: Supported
  • Function Calling: Supported

Specifications

SpecificationValue
ProviderX-Ai
Model TypeLarge Language Model (LLM)
ArchitectureN/A
Context Window256000 tokens
Max Output4096 tokens
InputText
OutputText
VisionSupported
Function CallingSupported

Pricing

Token TypeCost per Million Tokens
Input$3.3
Output$16.5

How to Use

  1. Write your prompt — describe the task, provide context, and specify desired output format.
  2. Submit — the model processes your request and returns the response.

API Integration

Base URL: https://llm.wavespeed.ai/v1 API Endpoint: chat/completions Model ID: x-ai/grok-4


API Usage

Python SDK

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://llm.wavespeed.ai/v1"
)

response = client.chat.completions.create(
    model="x-ai/grok-4",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

cURL

curl https://llm.wavespeed.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "x-ai/grok-4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Notes

  • Model: x-ai/grok-4
  • Provider: X-Ai

Info

Providerxai
Typellm

支持功能

输入
TextImage
输出
Text
上下文256,000
最大输出4,096
Vision✓ Supported
Function Calling✓ Supported

API 访问指南

Base URLhttps://llm.wavespeed.ai/v1
API Endpointchat/completions
Model IDx-ai/grok-4

x-ai/grok-4

Grok 4 is xAI's latest reasoning model with a 256k context window. It supports parallel tool calling, structured outputs, and both image and text inputs. Note that reasoning is not...

Input

$3 /M

Output

$15 /M

Context

256K

Max Output

4K

Vision

Supported

Tool Use

Supported

Try x-ai/grok-4 on WaveSpeedAI

Access x-ai/grok-4 through our unified API — OpenAI-compatible, no cold starts, transparent pricing.

Open Playground