1#### Advanced API Usage
2
3# Regional Endpoints
4
5`https://api.x.ai` is the global endpoint. SpaceXAI may route requests between regions for capacity or reliability, so the processing location is not guaranteed.
6
7If you need API request handling and model inference to happen in the United States, use the US regional endpoint, `https://us.api.x.ai/v1`. It is available to every team, and your existing API keys work on both endpoints.
8
9> [!NOTE]
10>
11> The US endpoint currently serves one model, `grok-4.6`, and none of the image generation, video generation, or voice APIs. Token usage costs 10% more than on the global endpoint. The US guarantee covers API request handling, inference, moderation, and retained request data. It does not cover Files, Collections, server-side tools, or the network path from your systems to SpaceXAI. See [What the guarantee covers](#what-the-guarantee-covers).
12
13## Using the US endpoint
14
15Point your client at `https://us.api.x.ai/v1`; the Python SDK (`xai_sdk`) takes the bare host, `us.api.x.ai`.
16
17```javascript customLanguage="javascriptAISDK"
18import { createXai } from '@ai-sdk/xai';
19import { generateText } from 'ai';
20
21const xai = createXai({
22 apiKey: process.env.XAI_API_KEY,
23 baseURL: 'https://us.api.x.ai/v1',
24});
25
26const { text } = await generateText({
27 model: xai.responses('grok-4.6'),
28 prompt: 'Explain latency versus throughput in two sentences.',
29});
30
31console.log(text);
32```
33
34```python customLanguage="pythonXAI"
35import os
36
37from xai_sdk import Client
38from xai_sdk.chat import user
39
40client = Client(
41 api_key=os.getenv("XAI_API_KEY"),
42 api_host="us.api.x.ai",
43)
44
45chat = client.chat.create(model="grok-4.6")
46chat.append(user("Explain latency versus throughput in two sentences."))
47
48print(chat.sample().content)
49```
50
51```python customLanguage="pythonOpenAISDK"
52import os
53from openai import OpenAI
54
55client = OpenAI(
56 api_key=os.getenv("XAI_API_KEY"),
57 base_url="https://us.api.x.ai/v1",
58)
59
60response = client.responses.create(
61 model="grok-4.6",
62 input="Explain latency versus throughput in two sentences.",
63)
64
65print(response.output_text)
66```
67
68```javascript customLanguage="javascriptOpenAISDK"
69import OpenAI from 'openai';
70
71const client = new OpenAI({
72 apiKey: process.env.XAI_API_KEY,
73 baseURL: 'https://us.api.x.ai/v1',
74});
75
76const response = await client.responses.create({
77 model: 'grok-4.6',
78 input: 'Explain latency versus throughput in two sentences.',
79});
80
81console.log(response.output_text);
82```
83
84```bash customLanguage="bash"
85curl https://us.api.x.ai/v1/responses \
86 -H "Authorization: Bearer $XAI_API_KEY" \
87 -H "Content-Type: application/json" \
88 -d '{
89 "model": "grok-4.6",
90 "input": "Explain latency versus throughput in two sentences."
91 }'
92```
93
94### Model availability
95
96`grok-4.6` is currently the only model available on the US endpoint; the [models page in the console](https://console.x.ai/team/default/models?cluster=us-central-1\&utm_source=docs\&utm_medium=referral\&utm_campaign=developers-advanced-api-usage-regions\&utm_content=models) and `GET https://us.api.x.ai/v1/models` always show the current list. Requesting a model that is not on that list, including `grok-latest`, fails with `404 Not Found`:
97
98```json customLanguage="json"
99{
100 "code": "not-found",
101 "error": "The model grok-4-1-fast-reasoning does not exist or your team <team_id> does not have access to it. If you believe this is a mistake, please contact support and quote your team ID and the model name."
102}
103```
104
105If a request for a globally available model returns this error, confirm that your client is calling the intended endpoint before troubleshooting model access. The image generation, video generation, and voice APIs are not served by the US endpoint; use the global endpoint for those.
106
107## Pricing
108
109Token usage on the US endpoint costs 10% more than on the global endpoint. The premium applies to input, output, and cached input tokens, including long-context rates, and [prompt caching](/developers/advanced-api-usage/prompt-caching) discounts still apply. The current per-token rates are on each model's detail page, reached from the [models page](/developers/models), and on the [Pricing](/developers/pricing) page.
110
111## What the guarantee covers
112
113When you call `https://us.api.x.ai/v1`, SpaceXAI guarantees that the following happen in the United States:
114
115* Handling of the request by SpaceXAI's API servers.
116* Inference for the model you request.
117* Safety moderation of the request and the response.
118* Storage of the request metadata, prompt inputs, and model outputs that SpaceXAI retains. The [Security FAQ](/developers/faq/security#does-xai-train-on-customers-api-requests) describes what is retained and for how long.
119
120The image generation, video generation, and voice APIs are not served by the US endpoint. [Files](/developers/files), [Collections](/developers/files/collections), and server-side tools such as [web search](/developers/tools/web-search), [X search](/developers/tools/x-search), and [code execution](/developers/tools/code-execution) still work on the US endpoint, but they are outside the US guarantee and may process data outside the United States. If your requirements cover these features as well, avoid them when calling the US endpoint, or contact [support@x.ai](mailto:support@x.ai) to discuss your configuration.
121
122The guarantee also does not cover the network path between your own users or infrastructure and the endpoint.
123
124> [!WARNING]
125>
126> A regional endpoint is not, by itself, a comprehensive data-residency guarantee. If you have contractual requirements about where your data is processed or stored, contact [sales@x.ai](mailto:sales@x.ai) before relying on the US endpoint for compliance.
127
128## FAQ
129
130### Does the US endpoint support tools, files, and structured outputs?
131
132Yes. Requests to the US endpoint accept the same parameters as the global endpoint, including function calling, server-side tools, file attachments, and structured outputs. However, server-side tools and files are outside the US guarantee; see [What the guarantee covers](#what-the-guarantee-covers).
133
134### Do prompt caches carry over between endpoints?
135
136Prompt cache hits are not guaranteed across endpoints. Keep each conversation on one endpoint and set a [`prompt_cache_key`](/developers/advanced-api-usage/prompt-caching/maximizing-cache-hits) so its requests are routed together.
137
138### Does Zero Data Retention apply on the US endpoint?
139
140Yes. [Zero Data Retention](/developers/faq/security#what-is-zero-data-retention-zdr) is a team-level setting, so it applies to every request your team makes regardless of the endpoint.