The Grok OpenAI Wrapper project provides a standardized interface to interact with X.com's services and Grok AI endpoints. The system handles:
- Authentication: A secure login flow that integrates with X.com APIs.
- Data Aggregation: Parsing and converting responses from Grok AI endpoints into an OpenAI-compatible protocol.
- Extensibility: A modular design that allows easy integration with other products and services that utilize OpenAI's API structure.
This project is ideal for developers looking to harness the combined power of X.com's Grok AI technology while maintaining compatibility with existing OpenAI-based workflows. Specifically cursorai.
- X.com Premium Account
- Python 3.8 or later
- Optional: Virtual environment tools (e.g.,
venv
orvirtualenv
) - Flask for serving API endpoints
- pycryptodome
- requests
- pyotp
-
Clone the repository:
git clone https://github.com/Dont-Copy-That-Floppy/Grok-Wrapper cd Grok-Wrapper
-
Optional: Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Run Middleware:
python grok.py
Example Structure:
{
"responses": [
{
"message": "Your message text here",
"sender": 1,
"promptSource": "",
"fileAttachments": []
}
],
"systemPromptName": "",
"grokModelOptionId": "grok-3",
"conversationId": "unique_conversation_id",
"returnSearchResults": true,
"returnCitations": true,
"promptMetadata": {
"promptSource": "NATURAL",
"action": "INPUT"
},
"imageGenerationCount": 4,
"requestFeatures": {
"eagerTweets": true,
"serverHistory": true
},
"enableCustomization": true,
"enableSideBySide": true,
"toolOverrides": {},
"isDeepsearch": false,
"isReasoning": false
}
The integration layer takes queries to the localhost at port 8080 that are openai requests, formats them to grok's protocol, then sends them to grok's endpoint. When the response is received, it parses back to openai comaptible response and send the packet back to source. Effectively a simple wrapper proxy server.
To use the service insert this as the base url in cursor,
http://localhost:8080/
No authentication requireed.
This project is licensed under the GPLv3 License.
For further inquiries or support, please contact:
- Contact/Donate: LINKs