xAI
docs.x.ai › docs › tutorial
The Hitchhiker's Guide to Grok | xAI
Certain grok models can accept both text AND images as an input. For example: ... import os from xai_sdk import Client from xai_sdk.chat import user, image client = Client( api_key=os.getenv("XAI_API_KEY"), timeout=3600, # Override default timeout with longer timeout for reasoning models ) chat = client.chat.create(model="grok-4") chat.append( user( "What's in this image?", image("https://science.nasa.gov/wp-content/uploads/2023/09/web-first-images-release.png") ) ) response = chat.sample() print(response.content)
Videos
12:11
How to use Grok API with Free Credits!!! - YouTube
01:13
How to Generate the xAI Grok API Key - YouTube
08:29
Grok API: Crash Course for Beginners in 8 Mins! - YouTube
44:45
Grok 4 CLI: Full Setup, Live Test & Cost Breakdown - YouTube
03:43
Grok xAI API in Python - Getting Started - YouTube
19:41
xAI has released their Grok Public API! How to use it in Clay - ...
xAI
docs.x.ai › docs › overview
xAI API
Grok is our flagship AI model designed to deliver truthful, insightful answers. ... Create an API Key and make your first request.
Grok API
grok-api.apidog.io › chat-15796842e0
Chat - Grok API
curl --location --request POST 'https://api.x.ai/v1/chat/completions' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data-raw '{ "messages": [ { "role": "system", "content": "You are Grok, a chatbot inspired by the Hitchhikers Guide to the Galaxy."
DataCamp
datacamp.com › tutorial › grok-3-api
Grok 3 API: A Step-by-Step Guide With Examples | DataCamp
May 1, 2025 - To use the API, we need to buy credits. Using prepaid credits rather than automatic invoice billing is recommended in the beginning, as it is a good safeguard against unexpected costs. You can buy tokens and get an overview of your usage in the xAI console under Invoices > Credits.
Analytics Vidhya
analyticsvidhya.com › home › how to access grok 3 api?
How to Access the Grok 3 API? - Analytics Vidhya
1. Visit grok.com and log in with your account credentials. 2. Click on your profile avatar in the top-right corner, choose Settings, and then select Manage. You’ll be redirected to the xAI Accounts page.
Published July 25, 2025
DataCamp
datacamp.com › tutorial › grok-4-api
Grok 4 API: A Step-by-Step Guide With Examples | DataCamp
July 15, 2025 - Although its context window size almost doubled in comparison to its predecessor, Grok 4 is priced exactly the same as the standard Grok 3 model. You’ll pay $3 for every million input tokens and $15 for every million output tokens. To access the API, you’ll need to purchase credits. Starting out, it’s wise to use prepaid credits instead of automatic billing—this helps you avoid surprise charges. You can buy tokens and track your usage in the xAI console, under Invoices > Credits.
Apidog
apidog.com › blog › grok-3-api
How to Use the Grok-3 API
November 16, 2025 - After downloading, run the installer and follow the prompts to set it up on your system. Once installed, launch Apidog and create a new project dedicated to your Grok-3 API work. This project serves as your workspace for all API-related tasks. ... Next, you need an API key to authenticate your requests. Head to the xAI console at .
xAI
docs.x.ai › docs › guides › chat
Responses API
import os from xai_sdk import Client from xai_sdk.chat import user, system client = Client( api_key=os.getenv("XAI_API_KEY"), management_api_key=os.getenv("XAI_MANAGEMENT_API_KEY"), timeout=3600, ) chat = client.chat.create(model="grok-4", store_messages=False) chat.append(system("You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy.")) chat.append(user("What is the meaning of life, the universe, and everything?")) response = chat.sample() print(response)
Groq
console.groq.com › docs › api-reference
API Reference - GroqDocs
import Groq from "groq-sdk"; const groq = new Groq({ apiKey: process.env.GROQ_API_KEY }); async function main() { const model = await groq.models.retrieve("llama-3.3-70b-versatile"); console.log(model); } main();
AI/ML API
docs.aimlapi.com › api-references › text-models-llm › xai › grok-4
grok-4 | AI/ML API Documentation
async function main() { const response = await fetch('https://api.aimlapi.com/v1/chat/completions', { method: 'POST', headers: { 'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>', 'Content-Type': 'application/json', }, body: JSON.stringify({ model: 'x-ai/grok-4-07-09', messages:[ { role:'user', content: 'Hello' } ], }), }); const data = await response.json(); console.log(JSON.stringify(data, null, 2)); } main();
Groq
console.groq.com › docs › overview
Overview - GroqDocs
import OpenAI from "openai"; const ... "openai/gpt-oss-20b", input: "Explain the importance of fast language models", }); console.log(response.output_text);...
AI SDK
ai-sdk.dev › providers › ai-sdk-providers › xai
AI SDK Providers: xAI Grok
It defaults to the XAI_API_KEY environment variable. ... Custom headers to include in the requests. fetch (input: RequestInfo, init?: RequestInit) => Promise<Response> Custom fetch implementation. Defaults to the global fetch function. You can use it as a middleware to intercept requests, or to provide a custom fetch implementation for e.g. testing. You can create xAI models using a provider instance. The first argument is the model id, e.g. grok-3.