Skip to Content
APISpaceXAI ProtocolChat Completions

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-ai

For the official OpenAI SDK, configure this SDK base URL:

https://api.hao.ai/x-ai/v1

The Chat Completions endpoint is:

POST https://api.hao.ai/x-ai/v1/chat/completions

Authentication

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 IDCurrent use
x-ai/grok-4.5Default frontier model for general, coding, and agentic work; 500,000-token context window.
x-ai/grok-composer-2.5-fastText-only coding model for Grok Build workflows; 200,000-token context window. It does not accept image input.

Request examples

Terminal
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:

grok_stream.py
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.