Enable image understanding in web search
Enable image understanding in web search
Set enable_image_understanding to true on the web_search tool. Grok gets the view_image tool and can analyze images it encounters while browsing pages. Usage shows up as SERVER_SIDE_TOOL_VIEW_IMAGE in response.server_side_tool_usage. Base setup: Add web search to a Grok API request. To embed image search results as Markdown instead, see Enable image search in web search.
xAI SDK
import os
from xai_sdk import Client
from xai_sdk.chat import user
from xai_sdk.tools import web_search
client = Client(api_key=os.getenv("XAI_API_KEY"))
chat = client.chat.create(
model="grok-4.6",
tools=[
web_search(enable_image_understanding=True),
],
)
chat.append(user("What is included in the image on xAI's official website?"))
response = chat.sample()
print(response.content)
print(response.server_side_tool_usage)
OpenAI Responses
response = client.responses.create(
model="grok-4.6",
input=[
{
"role": "user",
"content": "What is included in the image on xAI's official website?",
},
],
tools=[
{
"type": "web_search",
"enable_image_understanding": True,
},
],
)
print(response)
Vercel AI SDK
import { xai } from '@ai-sdk/xai';
import { generateText } from 'ai';
const { text } = await generateText({
model: xai.responses('grok-4.6'),
prompt: "What is included in the image on xAI's official website?",
tools: {
web_search: xai.tools.webSearch({
enableImageUnderstanding: true,
}),
},
});
console.log(text);
Pitfalls
- Enabling this on Web Search also enables image understanding for X Search when that tool is on the same request.
enable_image_searchis a different flag: it finds images and embeds them as Markdown. This flag inspects images on pages already being browsed.- Console API credits are separate from SuperGrok's weekly pool on grok.com.