xAI · Large Language Model

Grok AI Chat API

Access xAI's Grok family of models through an OpenAI-compatible format. Use Grok 4.7 for reasoning, coding, and visual analysis, or choose Grok 4.5, Grok 4, or Grok 3 based on the task.

🧠 Grok 4.7 Reasoning 📷 Text and Image Understanding 🔌 OpenAI Compatible
4
Chat Models
4 levels
Grok 4.7 Reasoning Effort
Token
Usage-Based Pricing
SSE
Streaming Responses

Core Features

Grok 4.7 supports text and image inputs and tool calling, making it suitable for reasoning, analysis, and in-app conversations. For video generation, see the Grok Imagine Video API.

🧠

Flagship Reasoning Capabilities

Grok 4.7 is suited for math, programming, and complex analysis. Use reasoning_effort to select minimal, low, medium, or high.

📜

Text and Image Understanding

Use an image_url content block to add images to Grok 4.7 messages and analyze screenshots, charts, and visual materials.

🔌

OpenAI-Compatible Format

Call /grok/chat/completions through the OpenAI SDK and reuse the Chat Completions request format.

OpenAI-compatible, ready to use

Use the OpenAI SDK you already know and seamlessly switch to Grok models by changing base_url.

Python
from openai import OpenAI
client = OpenAI(
  base_url="https://api.acedata.cloud/grok",
  api_key="YOUR_API_KEY",
)
response = client.chat.completions.create(
  model="grok-4.7",
  messages=[{"role": "user", "content": "用一句话解释量子计算"}],
  reasoning_effort="medium",
  max_tokens=1024,
)
print(response.choices[0].message.content)

JSON response

The following response excerpt from the existing API guide shows the fields used to read the result. The example model, task ID, and media content come from that historical example; refer to the actual response for this request.

{
  "id": "foaicmpl-13936918-cb99-49e1-b94c-bde98b482ed4",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Yo! What's up? 😎 Ready to dive into whatever you're pondering about today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 8,
    "completion_tokens": 20,
    "total_tokens": 28
  }
}

Get started in 3 steps

From signing up to your first Grok conversation, it only takes a few minutes.

1

Get an API Key

Log in to the application list, open General Application, and click the copy button to the right of API KEY. Store the key on your server and use it to replace YOUR_API_KEY in the example.

Get an Ace Data Cloud API Key
2

Choose a Grok model

Select grok-4.7 or another released model from the model list.

3

Start a conversation

Send a request through the OpenAI-compatible /grok/chat/completions endpoint.

What is Grok good for?

Covering a range of use cases from everyday conversations to professional research.

💻

Code generation

Grok 4.7 can be used for code generation, code review, and debugging.

📊

Data analysis

Handle complex data analysis tasks and generate insight reports and visualization suggestions.

🤖

AI customer service

Build customer service systems with Grok 3 to respond quickly to customer inquiries.

📝

Content creation

Writing articles, translation, summarization, advertising copy, and other writing tasks.

🔬

Academic research

Complex reasoning, literature analysis, mathematical proofs, and exploration of scientific questions.

Grok model family

From ultra-fast reasoning to flagship reasoning, choose the model that suits you best

🧠 Grok 4.7

A next-generation flagship reasoning model supporting long context, visual understanding, and tool calling.

grok-4.7

🔥 Grok 4.5 / 4 / 3

Mature, high-performance models suited to general reasoning, programming, and content tasks.

grok-4.5 grok-4 grok-3

Grok API Pricing

Pay by Token usage, with no subscription fees or hidden charges.

Get bigger discounts with bulk packages

Pay as you go
Token-based billing
Low cost Billed per Token

Billed based on actual Token usage, with separate pricing for input and output

  • ✓ Grok 4.7: Next-generation flagship reasoning model
  • ✓ Grok 3: A cost-effective choice for ultra-long context
  • ✓ Supports streaming responses, billed based on actual Token usage
View pricing details
Enterprise
Custom

Tailored solutions for high-usage teams

  • ✓ Usage-based tiered discounts
  • ✓ Priority support and an account manager
  • ✓ Custom rate limits
  • ✓ SLA guarantee
  • ✓ Private deployment options
Contact sales

Frequently Asked Questions

Common questions about using the Grok API

How do I choose a Grok model and reasoning effort?›

For complex analysis, code review, or image and text tasks, start with Grok 4.7's default medium. For everyday conversations, compare the response quality, latency, and usage of other models before deciding on a production configuration.

How is this different from using the xAI API directly?›

Ace Data Cloud provides a unified OpenAI-compatible interface, with no need to register an xAI account or configure a separate API key. Use the same API Key to access models from multiple providers, including Grok, Claude, GPT, and Gemini.

Can I use the OpenAI SDK to call Grok?›

Yes. Set base_url to https://api.acedata.cloud/grok, then select an available model and its corresponding parameters.

Is streaming supported?›

Yes. Set stream: true to receive token-by-token SSE streaming output, suitable for real-time conversations and frontend display.

Explore More AI Conversation Services

Ace Data Cloud offers a range of large language model APIs

Get Started with the Grok API

Choose a Grok model and get started with text conversations, visual understanding, or tool calls.