Grok 4 API
surplus/grok-4
Call Grok 4 through UberLLM’s OpenAI-compatible API — from $2.00/M input and $6.00/M output, routed automatically to the cheapest healthy provider. xAI · 2,000,000 token context. No inference markup.
Grok 4 pricing & providers
| Provider | Input / 1M | Output / 1M |
|---|---|---|
| Surplus Intelligencebest | $2.00 | $6.00 |
How to use Grok 4 with the OpenAI SDK
Already using OpenAI or OpenRouter? Change one line — the base URL — and call Grok 4 with your existing code. Anthropic SDKs work against https://api.uberllm.dev/v1/messages.
from openai import OpenAI
client = OpenAI(
base_url="https://api.uberllm.dev/v1",
api_key="ull_your_key_here",
)
resp = client.chat.completions.create(
model="surplus/grok-4",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)Grok 4 API — FAQ
How much does the Grok 4 API cost?
Grok 4 costs from $2.00 per million input tokens and $6.00 per million output tokens through UberLLM, which routes to the cheapest healthy provider. There is no inference markup.
How do I call Grok 4 via API?
Use any OpenAI-compatible SDK: set the base URL to https://api.uberllm.dev/v1, your UberLLM API key, and model "surplus/grok-4". Anthropic SDKs work via https://api.uberllm.dev/v1/messages.
Is Grok 4 OpenAI-compatible on UberLLM?
Yes. Every model on UberLLM — including Grok 4 — is served through one OpenAI-compatible endpoint, so you change only the base URL and key.