Grok API pricing
xAI bills the Grok API per 1M tokens of input, cached input and output [1]. Grok 4.7 lists at $2.00 per 1M input tokens and $6.00 per 1M output tokens on xAI for prompts under 200K tokens ($4.00 / $12.00 above that). [1] One Straitly key calls all 5 current Grok models in the table at https://api.straitly.ai/v1 [8].
Updated
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.straitly.ai/v1",
api_key=os.environ["STRAITLY_API_KEY"],
)
reply = client.chat.completions.create(
model="grok-4.7",
messages=[{"role": "user",
"content": "Hello"}],
)How do I get a Grok API key?
From xAI, or as a Straitly key that calls Grok and every other Straitly model. Either way the OpenAI SDK works with a base URL and key change [3][10].
| Step | xAI API | Straitly |
|---|---|---|
| Get a key | Sign up at console.x.ai, load credits, then create a key on the API Keys page [3] | Sign up, add prepaid credits [11], then create a key on the API keys page [9] |
| Environment variable | XAI_API_KEY | STRAITLY_API_KEY |
| Base URL | https://api.x.ai/v1 | https://api.straitly.ai/v1 |
| Request format | Responses API [3]; Chat Completions is a legacy endpoint [4] | OpenAI Chat Completions and Anthropic Messages [10] |
| Models on one key | xAI's own models [2] | All 117 on /models [8] |
Questions people ask about Grok API pricing
Ask a question- Grok 4.7 lists at $2.00 per 1M input tokens and $6.00 per 1M output tokens on xAI for prompts under 200K tokens ($4.00 / $12.00 above that). Each Grok model has its own rate per 1M input and output tokens, and the table on this page lists xAI's price for 5 current Grok models. List prices are from xAI's pricing page, matched on 24 November 2026 and checked again on 23 November 2026. [1][7]
- Yes, on xAI's own API. Once a prompt reaches 200K tokens, xAI bills every token in that request at the model's long-context rate. Grok 4.7, Grok 4.6 and Grok 4.5 then cost $4.00 / $12.00 per 1M input / output tokens. Grok 4.3 and Grok 4.20 then cost $2.50 / $5.00 per 1M input / output tokens. This is xAI's rule, from its pricing page checked 23 November 2026. [1]
- On xAI, sign up at console.x.ai, load credits, create a key on the API Keys page and export it as XAI_API_KEY; the base URL is https://api.x.ai/v1. On Straitly, create a Straitly key, set the base URL to https://api.straitly.ai/v1 and use the model id grok-4.7. The same Straitly key calls all 117 Straitly models. [3][9]
- Yes. xAI's quickstart calls Grok 4.7 with the OpenAI SDK by setting base_url to https://api.x.ai/v1, and uses the Responses API; xAI's Chat Completions page says it "is offered as a legacy endpoint". Straitly accepts OpenAI Chat Completions and Anthropic Messages requests at https://api.straitly.ai/v1, so the OpenAI SDK works with a base URL and key change. [3][4][10]
- No. Zero data retention (ZDR) is the default on every Straitly account, on every key. Prompts and completions are never written to disk or logs, and never used to train models. Straitly keeps only the metadata needed for billing and the Activity page: timestamp, model, provider, and the key that made the request; token counts per bucket; latency, status code, and the amount charged. None of these fields contain prompt or completion text. [12] See data retention.
Sources
Last updated 23 November 2026. Prices change. If something here is out of date, tell us at straitly.ai/contact.
- [1]API pricing
- [2]Models
- [3]Quickstart
- [4]Chat Completions (legacy endpoint)
- [5]Release notes
- [6]Grok 4.3 is now live on the xAI API
- [7]Straitly model catalog
- [8]Straitly models
- [9]Quickstart
- [10]Endpoints
- [11]Pricing
- [12]Data retention
How this page was checked
The 5 Grok models in the table are from Straitly's catalog on 25 November 2026. List prices are the ones matched on xAI's pricing page on 24 November 2026; that page, the models page, the quickstart and the release notes were read again on 23 November 2026. xAI's docs now carry the SpaceXSI name; the docs.x.ai address, console.x.ai and the XAI_API_KEY variable are unchanged. Release months come from xAI's models page and release notes, and for Grok 4.3 from xAI's launch post on X.
Call Grok 4.7 on Straitly.
One OpenAI-compatible key for the 5 Grok models above and the rest of the 117.