SpaceXAI Chat Completions
Call Grok models through HaoAI’s SpaceXAI API family. The SpaceXAI route selects only Grok-family models and upstreams; its text request and response payloads use xAI’s OpenAI-compatible Chat Completions JSON and SSE shape.
This is a SpaceXAI protocol boundary, not an OpenAI-upstream alias. Use your HaoAI API key—not an xAI OAuth credential—and the Grok endpoint below.
Legacy /grok/... API paths remain directly supported with the same behavior as
/x-ai/..., without redirects. Existing model IDs such as grok/grok-4.5
also remain supported; use x-ai/grok-4.5 for new integrations. Grok names the
model family; SpaceXAI is the provider and API display name.
Base URL and endpoint
The protocol root is:
https://api.hao.ai/x-aiFor the official OpenAI SDK, configure this SDK base URL:
https://api.hao.ai/x-ai/v1The Chat Completions endpoint is:
POST https://api.hao.ai/x-ai/v1/chat/completionsAuthentication
Pass your HaoAI API key as a Bearer token:
Authorization: Bearer <your HAOAI_API_KEY>Available models
Use canonical model IDs with the x-ai/ prefix.
| Model ID | Current use |
|---|---|
x-ai/grok-4.5 | Default frontier model for general, coding, and agentic work; 500,000-token context window. |
x-ai/grok-composer-2.5-fast | Text-only coding model for Grok Build workflows; 200,000-token context window. It does not accept image input. |
Request examples
cURL
curl https://api.hao.ai/x-ai/v1/chat/completions \
-H "Authorization: Bearer $HAOAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "x-ai/grok-4.5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain how an API gateway works."}
]
}'Streaming
Set stream: true to receive an SSE stream in the xAI-compatible Chat
Completions format:
stream = client.chat.completions.create(
model="x-ai/grok-4.5",
messages=[{"role": "user", "content": "Write a short welcome message."}],
stream=True,
)
for chunk in stream:
content = chunk.choices[0].delta.content
if content:
print(content, end="", flush=True)For the xAI-compatible Responses shape, use the SpaceXAI Responses API.