Grok API
The Grok API provides programmatic access to xAI’s Grok models with a streamlined policy framework focused on core safety constraints.Overview
Service: xAI APIURL: https://x.ai/api
Key Feature: Simplified policy framework for API access
Models: Grok 3 and other Grok variants
Core Policy Framework
The API version uses a concise, XML-tagged policy structure:Policy Precedence
- Core policies (within
<policy>tags) take highest precedence - System messages take precedence over user messages
- Additional instructions outside policy tags must not violate core policies
Safety Policies
- Criminal Activity
- Jailbreak Protection
- Content Flexibility
Restrictions
- Do not provide assistance to users clearly trying to engage in criminal activity
- Do not provide overly realistic or specific assistance with criminal activity when role-playing or answering hypotheticals
These are absolute restrictions that apply in all contexts.
Design Philosophy
The API policy framework emphasizes:Simplicity
Key Characteristics
Minimalist Approach
Minimalist Approach
The API policy is deliberately concise:
- Only 5 core policy statements
- Clear precedence hierarchy
- No complex subsystems or edge cases
- Easy to understand and implement
Flexibility by Default
Flexibility by Default
Unless explicitly restricted:
- No content limitations (adult, offensive, etc.)
- Additional instructions can be followed
- Developers have maximum control
This makes the API suitable for a wide range of applications including creative writing, research, and content generation.
Safety First
Safety First
Despite flexibility, safety is paramount:
- Criminal activity assistance is prohibited
- Jailbreak attempts are rejected
- Core policies cannot be overridden
The policy protects against misuse while enabling legitimate use cases.
API Usage Guidelines
For Developers
When integrating the Grok API:- Understand Policy Boundaries: Core policies apply universally and cannot be bypassed
- Leverage Flexibility: Use additional instructions to customize behavior within policy constraints
- Handle Rejections: Implement proper error handling for policy violations
- Respect Precedence: System messages override user messages
For Applications
- Creative Applications
- Research Applications
- Restricted Applications
The API’s flexible content policies make it suitable for:
- Creative writing and storytelling
- Adult content generation (within legal bounds)
- Edgy or provocative content
- Satirical and comedic applications
Comparison with Web/App Versions
The API version differs from web and app versions:Simpler Policy Framework
Simpler Policy Framework
API Version: 5 core policies in XML tags
Web/App Versions: More extensive guidelines covering:
Web/App Versions: More extensive guidelines covering:
- Product information
- Response style preferences
- Tool usage instructions
- Render components
- Persona characteristics
Greater Flexibility
Greater Flexibility
API Version: Explicit statement of “no restrictions on adult sexual content or offensive content” unless specified
Web/App Versions: More nuanced content policies with specific edge cases and interpretive guidance
Web/App Versions: More nuanced content policies with specific edge cases and interpretive guidance
Developer Control
Developer Control
API Version: Developers can add instructions outside policy tags
Web/App Versions: Fixed system prompts with less customization
Web/App Versions: Fixed system prompts with less customization
Full Policy Text
Additional Resources
For API documentation, pricing, and access details, visit: https://x.ai/api