AI Gateway REST: xai/grok-4.5 native web_search broken (search_parameters 500s; /responses rejects Responses shape)
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 345
- Avg merge
- 13h 31m
- Merged PRs (30d)
- 1
Description
## Summary
Native web search for `xai/grok-4.5` is broken / unsupported on the documented Cloudflare AI REST path (`POST /client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/...`), despite the [grok-4.5 model page](https://developers.cloudflare.com/ai/models/xai/grok-4.5/) advertising `search_parameters`, `web_search_options`, and `tools` on chat completions.
Basic chat completions for `xai/grok-4.5` succeed (HTTP 200). Any attempt to enable native search fails in one of two contradictory ways depending on endpoint/shape.
## Root-cause framing
This looks like a **docs / gateway wiring gap**, not an upstream xAI outage:
1. The [AI Gateway web search docs](https://developers.cloudflare.com/ai-gateway/usage/web-search/) explicitly state that **only** `xai/grok-4.20-multi-agent-0309` accepts `web_search` via AI Gateway, on `POST /ai/v1/responses` with `input` + `tools: [{ "type": "web_search" }]`.
2. The same docs list other Grok chat-completions models under “Models without web search support,” but **do not mention `xai/grok-4.5`**.
3. The [xai/grok-4.5 model page](https://developers.cloudflare.com/ai/models/xai/grok-4.5/) exposes `search_parameters`, `web_search_options`, and `tools` on the chat-completions schema — implying search is available — but those fields fail in practice.
4. Sending a Responses-API-shaped body (`input` + `tools: [{type:"web_search"}]`) to `/ai/v1/responses` for `xai/grok-4.5` is rejected as if the gateway is treating the request as **chat completions** (unsupported field `input`; expects `messages`).
**Hypothesis:** AI Gateway only wires native xAI `web_search` for the multi-agent model on the Responses path. `xai/grok-4.5` is catalogued with search-related schema fields, but the gateway does not implement chat-side `search_parameters` / `web_search_options`, nor Responses-side `web_search` for this model ID.
## Environment
- Product: FRAME (Workers / Agents SDK app)
- Client: `@ai-sdk/openai` chat completions against Cloudflare OpenAI-compatible AI REST
- Base URL: `https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1`
- Auth: `Authorization: Bearer $CLOUDFLARE_API_TOKEN` (Unified Billing / account token; no per-vendor xAI key)
- Model: `xai/grok-4.5`
- Date observed: 2026-07-22
## Steps to reproduce
### 1. Baseline — chat without search (works)
```bash
curl -sS -X POST "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/chat/completions" \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "xai/grok-4.5",
"messages": [
{ "role": "user", "content": "Say hello in one sentence." }
]
}'
```
**Actual:** HTTP 200 with a normal chat completion.
### 2. Chat completions with `search_parameters` (fails — HTTP 500)
```bash
curl -sS -X POST "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/chat/completions" \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "xai/grok-4.5",
"messages": [
{ "role": "user", "content": "What were the top news stories about Cloudflare this week? Summarize in three bullets." }
],
"search_parameters": {
"mode": "auto",
"return_citations": true
}
}'
```
Also fails with the equivalent top-level `web_search_options` body (same endpoint / model).
**Actual:**
```json
HTTP 500
{
"errors": [
{
"message": "Model execution failed (Error)",
"code": 2002
}
],
"success": false
}
```
### 3. Responses-shaped request on `/ai/v1/responses` (fails — HTTP 400)
This is the shape documented for xAI web search on the multi-agent model, adapted to `xai/grok-4.5`:
```bash
curl -sS -X POST "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/responses" \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "xai/grok-4.5",
"input": "What were the top news stories about Cloudflare this week? Summarize in three bullets.",
"tools": [
{ "type": "web_search" }
]
}'
```
**Actual:** HTTP 400 rejecting field `input` and indicating the gateway expects `messages` (chat-completions shape), not Responses API `input`.
## Expected
Either:
**A (preferred):** Native web search works for `xai/grok-4.5` on the documented AI REST path — ideally both:
- Chat completions: `search_parameters` / `web_search_options` (as advertised on the model page), and/or
- Responses: `input` + `tools: [{ "type": "web_search" }]` (as documented for xAI in the web search guide)
…and ideally also xAI-native `x_search` / `code_execution` tools where applicable.
**B:** If intentionally unsupported, the [grok-4.5 model page](https://developers.cloudflare.com/ai/models/xai/grok-4.5/) should not advertise `search_parameters` / `web_search_options`, and the [web search docs](https://developers.cloudflare.com/ai-gateway/usage/web-search/) should list `xai/grok-4.5` under “Models without web search support” (or explicitly document the supported model list only). Failures should be a clear **4xx validation error**, not an opaque HTTP 500 `code: 2002`.
## Ask
Please support native `web_search` (and ideally `x_search` / `code_execution`) for `xai/grok-4.5` on the documented AI REST / AI Gateway path, **or** clarify the model-page params if they are intentionally unsupported.
If the intended path is only `xai/grok-4.20-multi-agent-0309` on `/ai/v1/responses`, please:
1. Wire `xai/grok-4.5` the same way (or document why it cannot be), and
2. Align the model-page schema + “Models without web search support” list so developers are not sent down a 500 path.
## Related docs
- https://developers.cloudflare.com/ai-gateway/usage/web-search/
- https://developers.cloudflare.com/ai/models/xai/grok-4.5/
## Notes
- No existing `cloudflare/ai` issue appears to cover `grok-4.5` + `web_search` / `search_parameters` specifically (searched 2026-07-22).
- Related but distinct: #548 (Unified Billing rejection on `/ai/v1/responses`), #399 (Azure Responses API support). This report is specifically about **xAI Grok 4.5 native search capability and endpoint/schema mismatch**.
Contributor guide
Research direction
Reproduce the three requests against the documented /ai/v1/chat/completions and /ai/v1/responses endpoints, then compare the AI Gateway web-search guide with the xai/grok-4.5 model page. Done means native search works with a clear contract, or both pages accurately mark it unsupported and failures return a clear 4xx validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100