🌐
xAI
docs.x.ai › docs › tutorial
The Hitchhiker's Guide to Grok | xAI
With your xAI API key exported as an environment variable, you're ready to make your first API request. Let's test out the API using curl. Paste the following directly into your terminal. ... curl https://api.x.ai/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $XAI_API_KEY" \ -m 3600 \ -d '{ "messages": [ { "role": "system", "content": "You are Grok, a highly intelligent, helpful AI assistant." }, { "role": "user", "content": "What is the meaning of life, the universe, and everything?"
🌐
DataCamp
datacamp.com › tutorial › grok-3-api
Grok 3 API: A Step-by-Step Guide With Examples | DataCamp
May 1, 2025 - We can combine the function calling ... the packages and functions mentioned before; ... Defining the output schema. We start with an API call using the create() function to trigger the tool call....
People also ask

🌐
Grok API
grok-api.apidog.io › introduction-933934m0
Introduction - Grok API
Build with Grok 3To access the Grok 3 models via API, please create an xAI account and an API key. ... The xAI API is a toolkit for developers to integrate xAI's Grok models into their own applications, the xAI API provides the building blocks to create new AI experiences.
🌐
Apidog
apidog.com › blog › xai-grok-api
Overview of xAI Grok & How to Use Its API
August 1, 2025 - ... Step 1: Before using the SDK, save your API key in the XAI_API_KEY environment variable. ... Step 2: Use the following command to verify that you have access permission to the API.
🌐
Merge.dev
merge.dev › blog › grok-api-key
How to get your Grok API key (5 steps)
January 2, 2025 - Once you select “Create API key,” you should see a pop-up that prompts you to name the key, select the endpoints you want to grant it, and pick the models it can use. Finally, you’ll be able to preview and generate the key.
🌐
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. ... Let Grok perform actions and look up information.
🌐
LabLab
lablab.ai › t › xai-beginner-tutorial
Getting Started with xAI’s Grok API: Your First AI Integration | LabLab
Discover how to use xAI’s Grok API to create powerful AI-driven applications with ease.
🌐
xAI
x.ai › api
API | xAI
Contact us to discuss your specific enterprise needs. ... Our API is compatible with OpenAI and Anthropic’s SDKs. Migrating is as easy as generating an API key and changing a URL.Start building · Installing Grok...
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › grok-4-api
Grok 4 API: A Step-by-Step Guide With Examples | DataCamp
July 15, 2025 - Learn how to use Grok 4’s API through practical examples featuring image recognition, reasoning, function calling, and structured output.
🌐
Analytics Vidhya
analyticsvidhya.com › home › how to access grok 3 api?
How to Access the Grok 3 API? - Analytics Vidhya
It should notify the user when stock is low. Create a plan for the directory structure and provide code snippets for the key components. """ client = OpenAI( api_key=os.getenv("GROK_API_KEY"), base_url="https://api.x.ai/v1", ) response = ...
Published   July 25, 2025
🌐
Puter
developer.puter.com › tutorials › free-unlimited-grok-api
Free, Unlimited Grok API
December 14, 2025 - To use Grok 4.1 Fast, you'll use the puter.ai.chat() function with the model parameter set to x-ai/grok-4.1-fast.
🌐
Medium
medium.com › @okanyenigun › grok-api-f180e5a7fa67
Grok API. Running Grok on local consumer… | by Okan Yenigün | Medium
October 28, 2024 - Interestingly, you can also use the OpenAI package for this purpose. import os from openai import OpenAI os.environ["XAI_API_KEY"] = "your-key" XAI_API_KEY = os.getenv("XAI_API_KEY") client = OpenAI( api_key=XAI_API_KEY, base_url="https://api.x.ai/v1", ) completion = client.chat.completions.create( model="grok-beta", messages=[ {"role": "system", "content": "You are Grok, a chatbot inspired by the Hitchhikers Guide to the Galaxy."}, {"role": "user", "content": "Explain the risks of improper AI usage and its contribution to autocratic regimes."}, ], ) print(completion.choices[0].message) """ ChatCompletionMessage(content='Here is a humorous take on the risks of improper AI usage and its potential contribution to autocratic regimes:\n\n---\n\n**The Perils of Improper AI Usage: A Hitchhiker\'s Guide**\n\n**1.
🌐
Griptapenodes
docs.griptapenodes.com › en › stable › how_to › keys › grok
How to get and use an xAI Grok API key - Griptape Nodes
Grok is a family of Large Language Models (LLMs) developed by xAI. You can access these models via the GrokPrompt config node. To make use of these, however, you'll need to have an XAI account, and generate an API key.
🌐
OpenRouter
openrouter.ai › x-ai › grok-4.1-fast
Grok 4.1 Fast - API, Providers, Stats | OpenRouter
Use the reasoning parameter in your request to enable reasoning, and access the reasoning_details array in the response to see the model's internal reasoning before the final answer. When continuing a conversation, preserve the complete reasoning_details when passing messages back to the model so it can continue reasoning from where it left off.
🌐
Apideck
apideck.com › blog › how-to-get-your-grok-xai-api-key
How to Get Your Grok (XAI) API Key
September 10, 2025 - import os import requests headers = { "Authorization": f"Bearer {os.getenv('GROK_API_KEY')}", "Content-Type": "application/json" } # Query with real-time X context payload = { "model": "grok-1", "messages": [ { "role": "user", "content": "What are people saying about the Olympics right now?" } ], "enable_x_context": True, # Enable real-time X data "include_trending": True, # Include trending topics "max_tokens": 1000 } response = requests.post( "https://api.x.ai/v1/chat/completions", headers=headers, json=payload )
🌐
xAI
x.ai › news › api
API Public Beta | xAI
We are happy to announce the immediate availability of our API, which gives developers programmatic access to our Grok series of foundation models. To get started, head to console.x.ai and sign up to create an account.
🌐
xAI
docs.x.ai › docs › introduction
Introduction | xAI
To access the grok-4 models via API, please create an xAI account and an API key.
🌐
Groq
console.groq.com › keys
API Keys - GroqCloud
Manage your project API keys. Remember to keep your API keys safe to prevent unauthorized access. ... Only team owners or users with the developer role may create or manage API keys.
🌐
Elephas
elephas.app › blog › how-to-get-grok-api-key
How to Get Grok API Key (Step by Step Guide) | 2026
2 weeks ago - Head over to the Grok PromptIDE at ide.x.ai and log in using your existing X account. ... Once logged in, click on your username displayed in the top right corner. From the dropdown menu, select "API Keys."