ModelsPricingEnterprise
500+ AI Model API, All In One API.Just In CometAPI
Models API
Developer
Quick StartDocumentationAPI Dashboard
Company
About usEnterprise
Resources
AI ModelsBlogChangelogSupport
Terms of ServicePrivacy Policy
© 2026 CometAPI · All rights reserved
Home/Models/xAI/Grok 4
X

Grok 4

Input:$2.4/M
Output:$12/M
Context:256K
Max Output:256K
Grok 4 is an artificial intelligence model provided by XAI. Currently supports text modality, with vision, image generation, and other features coming soon. Possesses extremely powerful technical parameters and ecosystem capabilities: Context Window: Supports context processing of up to 256,000 tokens, leading mainstream models.
New
Commercial Use
Playground
Overview
Features
Pricing
API
Versions

Features

  • Generative Chatbot: Grok 4 continues xAI’s lineage of chat-based LLMs (Grok‑1 through Grok‑3), now integrated deep across Musk’s X platform, standalone web app, and mobile application.
  • Multimodality: In addition to text, Grok 4 introduces early support for vision inputs—paving the way for image understanding and generation. Primarily text, with upcoming support for vision and image generation
  • Expressive Voice Assistant: The “Eve” persona, introduced earlier, now benefits from its refined speech synthesis, offering singing and expressive dialogue.

Technical Architecture and Model Versions

  • Architecture: Grok 4 builds on a transformer-based backbone with significant architectural refinements geared toward logical consistency and context retention over extended dialogues.
  • Training Regimen: Trained on a bespoke corpus scraped from publicly available X posts, open web sources, and licensed datasets. xAI emphasizes data refinement to filter “garbage data” and mitigate bias.

Benchmark Performance

xAI highlights that Grok 4 outperforms most AI systems on key academic and coding benchmarks:

  • AIME: 98.8 (Advanced Intelligence Math Exam)
  • GPQA: 88 (Graduate-level Prompted QA)
  • SWE‑Bench: 75 (Software Engineering tasks)
  • Humanity Last Exam (HLE): 45% overall with advanced reasoning.
    In live demos, Elon Musk claimed Grok 4 is “smarter than almost all graduate students,” underscoring its leadership in multi-disciplinary performance .

How to access Grok 4 API

Step 1: Sign Up for API Key

Log in to cometapi.com. If you are not our user yet, please register first. Sign into your CometAPI console. Get the access credential API key of the interface. Click “Add Token” at the API token in the personal center, get the token key: sk-xxxxx and submit.

Step 2: Send Requests to Grok 4 API

Select the “\grok-4\” endpoint to send the API request and set the request body. The request method and request body are obtained from our website API doc. Our website also provides Apifox test for your convenience. Replace <YOUR_API_KEY> with your actual CometAPI key from your account. base url is Chat format(https://api.cometapi.com/v1/chat/completions).

Insert your question or request into the content field—this is what the model will respond to . Process the API response to get the generated answer.

Step 3: Retrieve and Verify Results

Process the API response to get the generated answer. After processing, the API responds with the task status and output data.

Features for Grok 4

Explore the key features of Grok 4, designed to enhance performance and usability. Discover how these capabilities can benefit your projects and improve user experience.

Pricing for Grok 4

Explore competitive pricing for Grok 4, designed to fit various budgets and usage needs. Our flexible plans ensure you only pay for what you use, making it easy to scale as your requirements grow. Discover how Grok 4 can enhance your projects while keeping costs manageable.
Comet Price (USD / M Tokens)Official Price (USD / M Tokens)Discount
Input:$2.4/M
Output:$12/M
Input:$3/M
Output:$15/M
-20%

Sample code and API for Grok 4

The Grok 4 API is a developer-friendly, OpenAI-compatible interface that enables access to xAI's latest large language model for advanced text generation, reasoning, and coding tasks via secure RESTful endpoints.
POST
/v1/chat/completions
Python
JavaScript
Curl
from openai import OpenAI
import os

# Get your CometAPI key from https://api.cometapi.com/console/token, and paste it here
COMETAPI_KEY = os.environ.get("COMETAPI_KEY") or "<YOUR_COMETAPI_KEY>"
BASE_URL = "https://api.cometapi.com/v1"

client = OpenAI(base_url=BASE_URL, api_key=COMETAPI_KEY)

completion = client.chat.completions.create(
    model="grok-4-0709",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"},
    ],
)

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

Python Code Example

from openai import OpenAI
import os

# Get your CometAPI key from https://api.cometapi.com/console/token, and paste it here
COMETAPI_KEY = os.environ.get("COMETAPI_KEY") or "<YOUR_COMETAPI_KEY>"
BASE_URL = "https://api.cometapi.com/v1"

client = OpenAI(base_url=BASE_URL, api_key=COMETAPI_KEY)

completion = client.chat.completions.create(
    model="grok-4-0709",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"},
    ],
)

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

JavaScript Code Example

import OpenAI from "openai";

// Get your CometAPI key from https://api.cometapi.com/console/token, and paste it here
const COMETAPI_KEY = process.env.COMETAPI_KEY || "<YOUR_COMETAPI_KEY>";
const BASE_URL = "https://api.cometapi.com/v1";

const client = new OpenAI({
  apiKey: COMETAPI_KEY,
  baseURL: BASE_URL,
});

async function main() {
  const completion = await client.chat.completions.create({
    model: "grok-4-0709",
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "Hello!" },
    ],
  });

  console.log(completion.choices[0].message.content);
}

main();

Curl Code Example

#!/bin/bash
# Get your CometAPI key from https://api.cometapi.com/console/token, and paste it here

curl "https://api.cometapi.com/v1/chat/completions" \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4-0709",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ]
  }'

Versions of Grok 4

The reason Grok 4 has multiple snapshots may include potential factors such as variations in output after updates requiring older snapshots for consistency, providing developers a transition period for adaptation and migration, and different snapshots corresponding to global or regional endpoints to optimize user experience. For detailed differences between versions, please refer to the official documentation.
version
grok-4.20-multi-agent-0309
grok-4.20-multi-agent-beta-0309
grok-4-1-fast-non-reasoning
grok-4-1-fast-reasoning
grok-4-fast-reasoning
grok-4
grok-4.20-0309-reasoning
grok-4-fast-non-reasoning
grok-4-0709
grok-4.20-0309-non-reasoning
grok-4.20-beta-0309-non-reasoning
grok-4.20-beta-0309-reasoning

More Models

C

Claude Opus 4.7

Input:$3/M
Output:$15/M
Claude Opus 4.7 is a hybrid reasoning model designed specifically for frontier-level coding, AI agents, and complex multi-step professional work. Unlike lighter models (e.g., Sonnet or Haiku variants), Opus 4.7 prioritizes depth, consistency, and autonomy on the hardest tasks.
A

Claude Sonnet 4.6

Input:$2.4/M
Output:$12/M
Claude Sonnet 4.6 is our most capable Sonnet model yet. It’s a full upgrade of the model’s skills across coding, computer use, long-context reasoning, agent planning, knowledge work, and design. Sonnet 4.6 also features a 1M token context window in beta.
O

GPT 5.5 Pro

Input:$24/M
Output:$144/M
An advanced model engineered for extremely complex logic and professional demands, representing the highest standard of deep reasoning and precise analytical capabilities.
O

GPT 5.5

Input:$4/M
Output:$24/M
A next-generation multimodal flagship model balancing exceptional performance with efficient response, dedicated to providing comprehensive and stable general-purpose AI services.
O

GPT Image 2 ALL

Per Request:$0.04
GPT Image 2 is openai state-of-the-art image generation model for fast, high-quality image generation and editing. It supports flexible image sizes and high-fidelity image inputs.
O

GPT 5.5 ALL

Input:$4/M
Output:$24/M
GPT-5.5 excels in code writing, online research, data analysis, and cross-tool operations. The model not only improves its autonomy in handling complex multi-step tasks but also significantly improves reasoning capabilities and execution efficiency while maintaining the same latency as its predecessor, marking an important step towards automated office automation in AI.

Related Blog

Cursor Composer vs Windsurf vs GitHub Copilot: Pricing & What You Actually Get
Apr 20, 2026
copilot
composer-2
windsurf

Cursor Composer vs Windsurf vs GitHub Copilot: Pricing & What You Actually Get

If you want the best autonomous output, Cursor usually wins. If you want the smoothest guided editing experience, Windsurf is often the most comfortable. If you want the best GitHub-native workflow per dollar, Copilot is the most practical. That ranking is an inference from the current product designs, pricing, and agent models published by each vendor.
What is Grok 4.2: Features, Architecture and Comparisons
Mar 12, 2026
grok-4-2

What is Grok 4.2: Features, Architecture and Comparisons

Grok 4.2 is xAI’s public-beta flagship in the Grok 4 family: a multi-agent, tool-enabled generation model with industry-leading throughput, a giant 2,000,000-token agent mode context window, and specialized API variants such as grok-4.20-multi-agent-beta-0309, grok-4.20-beta-0309-reasoning, and grok-4.20-beta-0309-non-reasoning. It’s optimized for fast, agentic workflows (real-time X data / tool calling), is available in Web, iOS/Android and early API channels eg CometAPI, and is aimed at users needing fast, live-data aware assistants rather than the deepest long-form reasoning.
How to Use Grok 4.2 API in 2026
Mar 12, 2026
grok-4-2

How to Use Grok 4.2 API in 2026

Grok 4.2 is xAI’s latest multi-agent reasoning model that combines four cooperating agents and new agentic tool-calling features to deliver much faster, lower-hallucination inference for enterprise workloads. To call it today most developers either (a) use the official xAI REST/gRPC endpoints or (b) call it through an aggregator like CometAPI (single REST endpoint,post https://api.cometapi.com/v1/responsess) which simplifies keys, billing, and multi-model switching.
Does Grok allow NSFW Now(As of early 2026)?
Feb 9, 2026
grok-4
x-ai

Does Grok allow NSFW Now(As of early 2026)?

While many AI platforms implement stringent filters to prevent the generation of Not Safe For Work (NSFW) content, Grok, developed by Elon Musk's xAI, has adopted a notably different approach. This article delves into Grok's stance on NSFW content, examining its features, implications, and the broader ethical considerations.
Grok 4.2: what will it bring and Why It Matters in AI in 2026
Jan 18, 2026
grok-4-2

Grok 4.2: what will it bring and Why It Matters in AI in 2026

Grok 4.2, a sophisticated iteration of Elon Musk’s flagship model. Unlike its predecessors, Grok 4.2 has arrived through a series of "stealth checkpoints"—mysterious model variants appearing on leaderboards under codenames like *Obsidian, Vortex Shade, and Quantum Crow.