twikit_grok
Extension for using Grok with Twikit.
Installing
pip install twikit_grok
Quick Example
Streaming
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
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)
Metadata
Release files for twikit-grok 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| twikit_grok-0.0.3.tar.gz | 7.0 kB | Without provenance | Details for twikit_grok-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| twikit_grok-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for twikit_grok-0.0.3-py3-none-any.whl |
Total release size: 14.9 kB
Release files / twikit_grok-0.0.3.tar.gz
| Download URL | twikit_grok-0.0.3.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ad28857b3fc7c12d0d076ecbea32f475b974f37ca899626802394b2909d0d85
|
|
BLAKE2b-256 checksum How to use checksums |
25449c1390ec35c5332ad9aaa98b4982254e3af02890f2f094c9b548f335ee2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.5
|
Release files / twikit_grok-0.0.3-py3-none-any.whl
| Download URL | twikit_grok-0.0.3-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f886f8e2b3380109ae9448417ab3caf6c4bed0a45bf501790bb435ad77277cc1
|
|
BLAKE2b-256 checksum How to use checksums |
13ba692128b624112858f45a1015d25cb5fe8864eb948105384d7ceb30b2d9b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.5
|
Security for twikit-grok 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.