Grok API Overview: Unlock Real-Time AI Solutions
For detailed information about using models with APIpie, check out our Models Overview and Completions Guide.
Description
The Grok Series represents xAI's family of state-of-the-art large language models. These models, developed by xAI, leverage cutting-edge technology to deliver exceptional performance in natural language processing, instruction-following tasks, and multimodal interactions. Grok is known for its real-time knowledge capabilities through X platform integration and its unique personality that combines intelligence with wit. The models are available through APIpie's routing system.
For technical details and performance metrics, see the Grok technical report.
Key Features
- Extended Token Capacity: Models support context lengths up to 131K tokens for handling extensive text processing needs.
- Multimodal Capabilities: Vision-enabled models for processing both text and images with state-of-the-art performance.
- Real-time Knowledge: Access to current information through X platform integration, setting it apart from other LLMs.
- Provider Availability: Accessible through OpenRouter.
- Diverse Applications: Optimized for chat, instruction-following, vision tasks, and real-time data analysis.
- Unique Personality: Combines factual responses with wit and humor, creating engaging interactions.
Model List in the Grok Series
Model List updates dynamically please see the Models Route for the up to date list of models
Model Name | Max Tokens | Response Tokens | Provider | Subtype | Type |
grok-beta | 131,072 | 131,072 | openrouter | chatx | llm |
grok-vision-beta | 8,192 | 8,192 | openrouter | multimodal | vision |
grok-2-1212 | 131,072 | 131,072 | openrouter | chatx | llm |
grok-2-vision-1212 | 32,768 | 32,768 | openrouter | multimodal | vision |
Example API Call
Below is an example of how to use the Chat Completions API to interact with a model from the Grok Series, such as grok-beta
.
curl -L -X POST 'https://apipie.ai/v1/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
--data-raw '{
"provider": "openrouter",
"model": "grok-beta",
"max_tokens": 150,
"messages": [
{
"role": "user",
"content": "Can you explain how photosynthesis works?"
}
]
}'
Response Example
The expected response structure for the Grok model might look like this:
{
"id": "chatcmpl-12345example12345",
"object": "chat.completion",
"created": 1729535643,
"provider": "openrouter",
"model": "grok-beta",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Photosynthesis is the process by which green plants, algae, and some bacteria convert light energy into chemical energy. Here's how it works:\n\n1. **Light Absorption**: Plants capture light energy using a pigment called chlorophyll, which is found in chloroplasts.\n\n2. **Water and Carbon Dioxide**: They absorb water through their roots and carbon dioxide from the air.\n\n3. **Glucose Production**: The light energy is used to convert water and carbon dioxide into glucose (a sugar) and oxygen. The equation is:\n \n 6CO2 + 6H2O + light energy → C6H12O6 + 6O2\n\nThis process provides energy for the plant and releases oxygen into the atmosphere."
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 125,
"total_tokens": 140,
"prompt_characters": 45,
"response_characters": 520,
"cost": 0.002250,
"latency_ms": 3100
},
"system_fingerprint": "fp_123abc456def"
}
API Highlights
- Provider: Specify "openrouter" as the provider or leave blank for automatic selection.
- Model: Use any model from the Grok Series, such as
grok-beta
orgrok-vision-beta
. See Models Guide. - Max Tokens: Set the maximum response token count (e.g., 150 in this example).
- Messages: Format your request with a sequence of messages, including user input and system instructions. See message formatting.
This example demonstrates how to seamlessly query models from the Grok Series for conversational or instructional tasks.
Applications and Integrations
- Conversational AI: Powering chatbots, virtual assistants, and other dialogue-based systems. Try it with LibreChat or OpenWebUI.
- Vision Tasks: Using vision-enabled models like
grok-vision-beta
andgrok-2-vision-1212
for image understanding and multimodal applications. Learn more about vision capabilities. - Extended Context Tasks: Processing long documents with models supporting up to 131K tokens. Learn more in our Models Guide.
- Real-time Analysis: Leveraging Grok's connection to the X platform for current events, trends, and social media analysis.
- Research & Development: Supporting academic and industrial research with reproducible results
Ethical Considerations
The Grok models are powerful tools that should be used responsibly. Users should implement appropriate safeguards and consider potential biases in model outputs. For guidance on responsible AI usage, refer to AI Safety Approach and Ethical AI Guidelines. The development team maintains transparency through their open science initiative and regular safety assessments.
Licensing
For detailed licensing information and usage terms, consult xAI terms.
Try out the Grok models in APIpie's various supported integrations.