Developer Dashboard

Back to Model Explorer

xAIAvailable on AvalAI

grok-4 API on AvalAI

xai/grok-4

grok-4 is an AI model from xAI that is available through AvalAI's OpenAI-compatible API.

Price display scale
Input price$3.00 / 1M tokens
Output price$15.00 / 1M tokens
Context window256,000 tokens
Maximum output256,000 tokens

Use grok-4 with the AvalAI API

Keep the API key in an environment variable and send requests from server-side code.

bash
curl https://api.avalai.ir/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AVALAI_API_KEY" \
  -d '{"model": "xai/grok-4", "messages": [{"role": "user", "content": "Give a concise, practical solution."}]}'
python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AVALAI_API_KEY"],
    base_url="https://api.avalai.ir/v1",
)

response = client.chat.completions.create(
    model="xai/grok-4",
    messages=[{"role": "user", "content": "Give a concise, practical solution."}],
)

print(response.choices[0].message.content)
javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.AVALAI_API_KEY,
  baseURL: "https://api.avalai.ir/v1",
});

const response = await client.chat.completions.create({
  model: "xai/grok-4",
  messages: [{ role: "user", content: "Give a concise, practical solution." }],
});

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

Create an API keyRead the quickstart

Capabilities and endpoints

  • Function calling
  • Prompt caching
  • Tool choice
  • Web search

grok-4 rate limits

TierRPMTPM
Tier 11080,000
Tier 250120,000
Tier 380200,000
Tier 4120200,000
Tier 5200200,000

Frequently asked questions

What is the grok-4 API on AvalAI?

Create an AvalAI API key and send the model ID xai/grok-4 to one of the supported endpoints shown on this page.

How much does the grok-4 API cost on AvalAI?

The grok-4 API on AvalAI costs $3.00 per 1M input tokens and $15.00 per 1M output tokens.

What is the token cost for grok-4?

Current AvalAI pricing for grok-4 is $3.00 / 1M tokens for input and $15.00 / 1M tokens for output.

What is the grok-4 context window?

The recorded maximum input context for grok-4 is 256,000 tokens.

What are the rate limits for grok-4 on AvalAI?

On tier 5, grok-4 on AvalAI supports up to 200 requests per minute and 200,000 tokens per minute.

What features does grok-4 support on AvalAI?

grok-4 on AvalAI supports Function calling, Prompt caching, Tool choice, Web search.

What account tier is required to use grok-4 on AvalAI?

Calling grok-4 on AvalAI requires tier 1 or higher.

Third-party data and freshness

  • Pricing, availability, endpoints, and rate limits: AvalAI structured data (authoritative)