| name | grok |
| description | Call Grok 4.5 through RunAPI with the official OpenAI SDK or compatible clients. Use when the user asks for Grok chat, streaming completions, reasoning effort, function tools, structured JSON output, or wants to point an OpenAI-compatible client at RunAPI. |
| metadata | {"openclaw":{"homepage":"https://runapi.ai/models/grok","primaryEnv":"OPENAI_API_KEY","requires":{"env":["OPENAI_API_KEY","OPENAI_BASE_URL"]},"envVars":[{"name":"OPENAI_API_KEY","required":true,"description":"RunAPI API key used by OpenAI-compatible Grok clients."},{"name":"OPENAI_BASE_URL","required":true,"description":"Set to https://runapi.ai/v1 for Grok on RunAPI."}]}} |
Grok 4.5 on RunAPI
Use the official OpenAI SDK or any OpenAI-compatible HTTP client. Set the base
URL to https://runapi.ai/v1 and call Chat Completions with grok-4.5.
Setup
OPENAI_API_KEY=YOUR_RUNAPI_TOKEN
OPENAI_BASE_URL=https://runapi.ai/v1
Get a RunAPI API Key at https://runapi.ai/api_keys.
Chat Completions
from openai import OpenAI
client = OpenAI(
api_key="YOUR_RUNAPI_TOKEN",
base_url="https://runapi.ai/v1",
)
response = client.chat.completions.create(
model="grok-4.5",
messages=[{"role": "user", "content": "Review this implementation plan."}],
reasoning_effort="high",
)
print(response.choices[0].message.content)
print(response.usage)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_RUNAPI_TOKEN",
baseURL: "https://runapi.ai/v1",
});
const response = await client.chat.completions.create({
model: "grok-4.5",
messages: [{ role: "user", content: "Review this implementation plan." }],
reasoning_effort: "high",
});
console.log(response.choices[0].message.content);
Streaming
Request terminal usage with stream_options.include_usage so the final event
contains the authoritative token counts before [DONE].
stream = client.chat.completions.create(
model="grok-4.5",
messages=[{"role": "user", "content": "Draft a concise rollout checklist."}],
reasoning_effort="medium",
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if chunk.usage:
print(f"\n{chunk.usage}")
Function Tools
response = client.chat.completions.create(
model="grok-4.5",
messages=[{"role": "user", "content": "What is the weather in Shanghai?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
},
},
"required": ["city"],
"additionalProperties": False,
},
},
}],
)
for tool_call in response.choices[0].message.tool_calls or []:
print(tool_call.function.name, tool_call.function.arguments)
Structured Output
response = client.chat.completions.create(
model="grok-4.5",
messages=[{"role": "user", "content": "Return a risk assessment."}],
response_format={
"type": "json_schema",
"json_schema": {
"name": "risk_assessment",
"strict": True,
"schema": {
"type": "object",
"properties": {
"risk": {"type": "string"},
"severity": {"type": "string", "enum": ["low", "medium", "high"]},
},
"required": ["risk", "severity"],
"additionalProperties": False,
},
},
},
)
print(response.choices[0].message.content)
Protocol compatibility
Grok text models are available through RunAPI's OpenAI-compatible Chat
Completions and Responses interfaces, Anthropic-compatible Messages interface,
and Gemini contents interface. RunAPI preserves the exact public model id
grok-4.5 across all four request protocols; use the protocol already expected
by your application or agent runtime.
Request Rules
- Use the exact model id
grok-4.5; do not send historical Grok aliases.
reasoning_effort accepts low, medium, or high; omit it to use the model default.
- Do not send
presence_penalty, frequency_penalty, or stop with this reasoning model.
- Preserve terminal
usage when storing or displaying billing evidence.
Supported models
| Model ID | Use when |
|---|
grok-4.5 | Chat, coding, reasoning, tools, and structured output |
References
Agent rules
- Keep API keys in
OPENAI_API_KEY, RUNAPI_TOKEN, or a secret manager.
- Default new integrations to
POST /v1/chat/completions at https://runapi.ai/v1.
- Prefer streaming for longer responses and request terminal usage.
- Link to the catalog page for pricing instead of copying price values.