# twikit_grok
Extension for using Grok with Twikit.
## Installing
```
pip install twikit_grok
```
## Quick Example
### Streaming
```python
import asyncio
from twikit_grok import Client
USERNAME = 'example_user'
EMAIL = 'email@example.com'
PASSWORD = 'password0000'
client = Client('en-US')
async def main():
# Login to an account
if os.path.exists('cookies.json'):
client.load_cookies('cookies.json')
else:
await client.login(
auth_info_1=USERNAME,
auth_info_2=EMAIL,
password=PASSWORD
)
client.save_cookies('cookies.json')
# Create a new conversation
conversation = await client.create_grok_conversation()
# Generate a response
async for chunk in conversation.stream('hello'):
print(chunk)
# Generate a response with images
attachments = [
await client.upload_grok_attachment('image1.jpg'),
await client.upload_grok_attachment('image2.jpg')
]
async for chunk in conversation.stream('please describe these images', attachments):
print(chunk)
# Continue from an existing conversation
conversation = await client.get_grok_conversation('123456789') # Get conversation by ID
async for chunk in conversation.stream('hello'):
print(chunk)
asyncio.run(main())
```
### Non Streaming
```python
conversation = await client.create_grok_conversation()
content = await conversation.generate('generate images of cats.')
await content.attachments[0].download('image.jpg')
content2 = await conversation.generate('hello')
print(content2.message)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/d60/twikit_grok",
"name": "twikit-grok",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/25/44/9c1390ec35c5332ad9aaa98b4982254e3af02890f2f094c9b548f335ee2a/twikit_grok-0.0.3.tar.gz",
"platform": null,
"description": "# twikit_grok \r\nExtension for using Grok with Twikit.\r\n\r\n## Installing\r\n```\r\npip install twikit_grok\r\n```\r\n\r\n## Quick Example\r\n\r\n\r\n### Streaming\r\n```python\r\nimport asyncio\r\nfrom twikit_grok import Client\r\n\r\nUSERNAME = 'example_user'\r\nEMAIL = 'email@example.com'\r\nPASSWORD = 'password0000'\r\n\r\nclient = Client('en-US')\r\n\r\nasync def main():\r\n # Login to an account\r\n if os.path.exists('cookies.json'):\r\n client.load_cookies('cookies.json')\r\n else:\r\n await client.login(\r\n auth_info_1=USERNAME,\r\n auth_info_2=EMAIL,\r\n password=PASSWORD\r\n )\r\n client.save_cookies('cookies.json')\r\n\r\n # Create a new conversation\r\n conversation = await client.create_grok_conversation()\r\n # Generate a response\r\n async for chunk in conversation.stream('hello'):\r\n print(chunk)\r\n\r\n # Generate a response with images\r\n attachments = [\r\n await client.upload_grok_attachment('image1.jpg'),\r\n await client.upload_grok_attachment('image2.jpg')\r\n ]\r\n async for chunk in conversation.stream('please describe these images', attachments):\r\n print(chunk)\r\n\r\n\r\n # Continue from an existing conversation\r\n conversation = await client.get_grok_conversation('123456789') # Get conversation by ID\r\n async for chunk in conversation.stream('hello'):\r\n print(chunk)\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n### Non Streaming\r\n\r\n```python\r\nconversation = await client.create_grok_conversation()\r\ncontent = await conversation.generate('generate images of cats.')\r\nawait content.attachments[0].download('image.jpg')\r\n\r\ncontent2 = await conversation.generate('hello')\r\nprint(content2.message)\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Twikit Grok",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/d60/twikit_grok"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "13ba692128b624112858f45a1015d25cb5fe8864eb948105384d7ceb30b2d9b7",
"md5": "af6e79b6d7ce986c87bb20eea0ae9050",
"sha256": "f886f8e2b3380109ae9448417ab3caf6c4bed0a45bf501790bb435ad77277cc1"
},
"downloads": -1,
"filename": "twikit_grok-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af6e79b6d7ce986c87bb20eea0ae9050",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7921,
"upload_time": "2025-07-21T03:34:09",
"upload_time_iso_8601": "2025-07-21T03:34:09.528729Z",
"url": "https://files.pythonhosted.org/packages/13/ba/692128b624112858f45a1015d25cb5fe8864eb948105384d7ceb30b2d9b7/twikit_grok-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "25449c1390ec35c5332ad9aaa98b4982254e3af02890f2f094c9b548f335ee2a",
"md5": "40737819a06aedd9cf12e474ceadc7a6",
"sha256": "2ad28857b3fc7c12d0d076ecbea32f475b974f37ca899626802394b2909d0d85"
},
"downloads": -1,
"filename": "twikit_grok-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "40737819a06aedd9cf12e474ceadc7a6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6959,
"upload_time": "2025-07-21T03:34:10",
"upload_time_iso_8601": "2025-07-21T03:34:10.661224Z",
"url": "https://files.pythonhosted.org/packages/25/44/9c1390ec35c5332ad9aaa98b4982254e3af02890f2f094c9b548f335ee2a/twikit_grok-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-21 03:34:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "d60",
"github_project": "twikit_grok",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "twikit",
"specs": []
}
],
"lcname": "twikit-grok"
}