Contents
The Grok API, by xAI, is an AI platform designed for natural language processing and, more recently, multi-modal tasks including image understanding.
In this article, we show how to get setup with Grok and perform your first REST API call, asking Grok to describe an image.
How to Get Your Grok API Key
To begin, you’ll need an API key from xAI.
Visit console.x.ai to sign up and generate your key.

Top up your Grok account in The X.AI Console
You only need to add around $5 / £5 to get started
Add pre-paid credits to your account.
Install Postman
Postman is useful for testing API calls before incorporating them into your script or application.
Ensure Postman is installed, available at postman.com.
How do I make the Grok REST API call?
In postman, create a new request:
Type | POST |
URL | https://api.x.ai/v1/chat/completions |
Headers | Content-type application/json |
Authorization Bearer APIKEYHERE |
Body:
{
"messages": [
{
"role": "system",
"content": "You are a helpful AI assistant created by xAI."
},
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://virtualg.uk/wp-content/uploads/2024/06/image-1-1.jpg",
"detail": "high"
}
},
{
"type": "text",
"text": "Provide a concise description of the technology featured in this image"
}
]
}
],
"model": "grok-2-vision-latest",
"temperature": 0.5
}

Hit Send
Inspecting the Grok Response
Within the request you should see a choices variable, containing “content” as your response:
“The image features a Raspberry Pi setup with an attached touchscreen display, encased in a protective frame. The display shows a Linux-based operating system, likely running on the Raspberry Pi.”


Final Thoughts
That’s it, once you know the syntax it’s really easy to integrate Grok into your script / app! Enjoy!