Name | Grok3API JSON |
Version |
0.1.0rc1
JSON |
| download |
home_page | None |
Summary | Python-библиотека для взаимодействия с Grok3, ориентированная на максимальную простоту использования. Автоматически получает cookies, поэтому ничего не нужно указывать. A Python library for interacting with Grok3, focused on maximum ease of use. Automatically gets cookies, so you don't have to specify anything. |
upload_time | 2025-09-02 16:24:02 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
grok3api
grok 3 api
grok api
grok3api python
grok ai
unofficial grok3api api
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
🚀 A Python library for interacting with the Grok 3 API without requiring login or manual cookie input. Perfect for out-of-the-box use.
## [➡ Ru ReadMe](docs/Ru/RuReadMe.md)
# 🤖 Grok3API: Client for Working with Grok





**Grok3API** is a powerful and user-friendly unofficial tool for interacting with Grok models (including Grok3), allowing you to send requests, receive text responses, and, most excitingly, **generated images** — all with automatic cookie management! 🎨✨ The project is designed with simplicity and automation in mind, so you can focus on creativity rather than technical details.
---
## [📦 Full Changelog](docs/En/ChangeLog.md)
### 🆕 v0.1.0b1
#### ✨ New:
* 🛠 **Improved code block handling**
Added automatic transformation of nested blocks `<xaiArtifact contentType="text/...">...</xaiArtifact>` into standard Markdown code blocks with language indication.
* ☑️ The feature can be disabled by setting the `auto_transform_code_blocks=False` parameter when creating `GrokClient`.
---
## 🌟 Features
- 🚀 **Automatic cookie retrieval** via browser with Cloudflare bypass — no manual setup required!
- 🖼️ **Convenient retrieval of generated images** with the `save_to` method, enabling one-click saving.
- 🔧 **Flexible request customization**: model selection, image generation control, attachment support, and more.
- 📦 **Attachment support**: send files and images along with requests.
- 🛠️ **Error handling**: the client automatically resolves cookie issues and retries requests if something goes wrong.
- 🤖 **[Example Telegram bot](tests/SimpleTgBot/SimpleTgBot.py) (`grok3api` + `aiogram`)**
---
## 📦 Installation
To start using GrokClient, install the required dependencies. It’s simple:
```bash
pip install grok3api
```
> ⚠️ **Important**: Ensure **Google Chrome** is installed, as `undetected_chromedriver` relies on it.
After installation, you’re ready to go! 🎉
---
## 🚀 Usage
### Quick Start
🍀 Minimal working example:
```python
from grok3api.client import GrokClient
client = GrokClient()
answer = client.ask("Hi! How are you?")
print(answer.modelResponse.message)
```
Here’s a complete example of sending a request and saving a generated image:
```python
from grok3api.client import GrokClient
# Create a client (cookies are automatically retrieved if not provided)
client = GrokClient()
# Create a request
message = "Create an image of a ship"
# Send the request
result = client.ask(message=message,
images="C:\\Folder\\photo1_to_grok.jpg") # You can send an image to Grok
print("Grok's response:", result.modelResponse.message)
# Save the first image, if available
if result.modelResponse.generatedImages:
result.modelResponse.generatedImages[0].save_to("ship.jpg")
print("Image saved as ship.jpg! 🚀")
```
This code:
1. **Creates a client** — automatically retrieves cookies if none are provided.
2. **Sends a request** to generate an image.
3. **Saves the image** to the file `ship.jpg`.
📌 **What will we see?**
Grok will generate an image of a **ship**, for example, something like this:
<img src="assets/ship.jpg" alt="Ship example" width="500">
🐹 Or, for instance, if you request "**A gopher on Elbrus**":
<img src="assets/gopher.jpg" alt="Gopher on Elbrus" width="500">
> 💡 **Cool feature**: You don’t need to manually fetch cookies — the client handles it for you!
---
## 🔧 Request Parameters
The `GrokClient.ask` method accepts various parameters to customize your request. Here’s an example with settings:
```python
from grok3api.client import GrokClient
client = GrokClient(history_msg_count=5, always_new_conversation=False) # to use conversation history from grok.com
client.history.set_main_system_prompt("Respond briefly and with emojis.")
# Send a request with settings
result = client.ask(
message="Draw a cat like in this picture",
modelName="grok-3", # Default is grok-3 anyway
images=["C:\\Users\\user\\Downloads\\photo1_to_grok.jpg",
"C:\\Users\\user\\Downloads\\photo2_to_grok.jpg"] # You can send multiple images to Grok!
)
print(f"Grok3 response: {result.modelResponse.message}")
# Save all images
for i, img in enumerate(result.modelResponse.generatedImages):
img.save_to(f"cat_{i}.jpg")
print(f"Saved: cat_{i}.jpg 🐾")
```
> 🌟 **The best part? It works with automatically retrieved cookies!** No need to worry about access — the client sets everything up for you.
---
## 🔄 Automatic Cookie Retrieval
If cookies are missing or expired, Grok3API automatically:
1. Uses the Chrome browser (ensure it’s installed).
2. Visits `https://grok.com/`.
3. Bypasses Cloudflare protection.
4. Continues operation.
You don’t need to do anything manually — just run the code, and it works!
### [💼️ `GrokClient` Class Description](docs/En/ClientDoc.md)
### [✈️ `ask` Method Description](docs/En/askDoc.md)
### [📋 `History` Class Description](docs/En/HistoryDoc.md)
### [📬 `GrokResponse` Class Description](docs/En/GrokResponse.md)
### [🐧 Working with `Linux`](docs/En/LinuxDoc.md)
### [🌐 Running an OpenAI-Compatible Server](docs/En/OpenAI_Server.md)
---
## 🖼️ Convenient Image Retrieval
One of the standout features of GrokClient is its **super-convenient handling of generated images**. Here’s a complete example:
```python
from grok3api.client import GrokClient
client = GrokClient()
result = client.ask("Draw a sunset over the sea")
for i, image in enumerate(result.modelResponse.generatedImages):
image.save_to(f"sunset_{i}.jpg")
print(f"Saved: sunset_{i}.jpg 🌅")
```
---
## 📋 Response Handling
The `ask` method returns a `GrokResponse` object.
Fields of the `GrokResponse` object:
- **`modelResponse`**: The main model response.
- `message` (str): The text response.
- `generatedImages` (List[GeneratedImage]): List of images.
- **`isThinking`**: Whether the model was thinking (bool).
- **`isSoftStop`**: Soft stop (bool).
- **`responseId`**: Response ID (str).
- **`newTitle`**: New chat title, if available (Optional[str]).
### [📬 Detailed `GrokResponse` Class Description](docs/En/GrokResponse.md)
---
If something’s unclear, feel free to raise an issue — we’ll figure it out together! 🌟
## Disclaimer
Grok3API has no affiliation with xAI or the Grok developers. It is an independent project created by a third party and is not supported, sponsored or endorsed by xAI. Any issues with Grok should be addressed directly to xAI.
You are responsible for ensuring that your use of Grok3API complies with all applicable laws and regulations. The developer does not encourage illegal use.
Raw data
{
"_id": null,
"home_page": null,
"name": "Grok3API",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "grok3api, grok 3 api, grok api, grok3api python, grok ai, unofficial grok3api api",
"author": null,
"author_email": "boykopovar <boykopovar@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/08/fd/0db18c97a9fea5c3926177071582a9bc81ebb55b25134ced3e5be2281f7a/grok3api-0.1.0rc1.tar.gz",
"platform": null,
"description": "\ud83d\ude80 A Python library for interacting with the Grok 3 API without requiring login or manual cookie input. Perfect for out-of-the-box use.\r\n\r\n\r\n\r\n## [\u27a1 Ru ReadMe](docs/Ru/RuReadMe.md)\r\n\r\n# \ud83e\udd16 Grok3API: Client for Working with Grok\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n**Grok3API** is a powerful and user-friendly unofficial tool for interacting with Grok models (including Grok3), allowing you to send requests, receive text responses, and, most excitingly, **generated images** \u2014 all with automatic cookie management! \ud83c\udfa8\u2728 The project is designed with simplicity and automation in mind, so you can focus on creativity rather than technical details.\r\n\r\n\r\n---\r\n\r\n## [\ud83d\udce6 Full Changelog](docs/En/ChangeLog.md)\r\n\r\n### \ud83c\udd95 v0.1.0b1\r\n\r\n#### \u2728 New:\r\n\r\n* \ud83d\udee0 **Improved code block handling**\r\n Added automatic transformation of nested blocks `<xaiArtifact contentType=\"text/...\">...</xaiArtifact>` into standard Markdown code blocks with language indication.\r\n\r\n* \u2611\ufe0f The feature can be disabled by setting the `auto_transform_code_blocks=False` parameter when creating `GrokClient`.\r\n\r\n\r\n---\r\n\r\n\r\n\r\n## \ud83c\udf1f Features\r\n\r\n- \ud83d\ude80 **Automatic cookie retrieval** via browser with Cloudflare bypass \u2014 no manual setup required! \r\n- \ud83d\uddbc\ufe0f **Convenient retrieval of generated images** with the `save_to` method, enabling one-click saving. \r\n- \ud83d\udd27 **Flexible request customization**: model selection, image generation control, attachment support, and more. \r\n- \ud83d\udce6 **Attachment support**: send files and images along with requests. \r\n- \ud83d\udee0\ufe0f **Error handling**: the client automatically resolves cookie issues and retries requests if something goes wrong. \r\n- \ud83e\udd16 **[Example Telegram bot](tests/SimpleTgBot/SimpleTgBot.py) (`grok3api` + `aiogram`)** \r\n---\r\n\r\n## \ud83d\udce6 Installation\r\n\r\nTo start using GrokClient, install the required dependencies. It\u2019s simple:\r\n\r\n```bash\r\npip install grok3api\r\n```\r\n\r\n> \u26a0\ufe0f **Important**: Ensure **Google Chrome** is installed, as `undetected_chromedriver` relies on it.\r\n\r\nAfter installation, you\u2019re ready to go! \ud83c\udf89\r\n\r\n---\r\n\r\n## \ud83d\ude80 Usage\r\n\r\n### Quick Start \r\n\r\n\ud83c\udf40 Minimal working example:\r\n```python\r\nfrom grok3api.client import GrokClient\r\n\r\nclient = GrokClient()\r\nanswer = client.ask(\"Hi! How are you?\")\r\n\r\nprint(answer.modelResponse.message)\r\n```\r\n\r\n\r\nHere\u2019s a complete example of sending a request and saving a generated image:\r\n\r\n```python\r\nfrom grok3api.client import GrokClient\r\n\r\n# Create a client (cookies are automatically retrieved if not provided)\r\nclient = GrokClient()\r\n\r\n# Create a request\r\nmessage = \"Create an image of a ship\"\r\n\r\n# Send the request\r\nresult = client.ask(message=message,\r\n images=\"C:\\\\Folder\\\\photo1_to_grok.jpg\") # You can send an image to Grok\r\n\r\nprint(\"Grok's response:\", result.modelResponse.message)\r\n\r\n# Save the first image, if available\r\nif result.modelResponse.generatedImages:\r\n result.modelResponse.generatedImages[0].save_to(\"ship.jpg\")\r\n print(\"Image saved as ship.jpg! \ud83d\ude80\")\r\n```\r\n\r\nThis code: \r\n1. **Creates a client** \u2014 automatically retrieves cookies if none are provided. \r\n2. **Sends a request** to generate an image. \r\n3. **Saves the image** to the file `ship.jpg`. \r\n\r\n\ud83d\udccc **What will we see?** \r\nGrok will generate an image of a **ship**, for example, something like this: \r\n\r\n<img src=\"assets/ship.jpg\" alt=\"Ship example\" width=\"500\">\r\n\r\n\ud83d\udc39 Or, for instance, if you request \"**A gopher on Elbrus**\":\r\n\r\n<img src=\"assets/gopher.jpg\" alt=\"Gopher on Elbrus\" width=\"500\">\r\n\r\n> \ud83d\udca1 **Cool feature**: You don\u2019t need to manually fetch cookies \u2014 the client handles it for you!\r\n\r\n---\r\n\r\n## \ud83d\udd27 Request Parameters\r\n\r\nThe `GrokClient.ask` method accepts various parameters to customize your request. Here\u2019s an example with settings:\r\n\r\n```python\r\nfrom grok3api.client import GrokClient\r\n\r\n\r\nclient = GrokClient(history_msg_count=5, always_new_conversation=False) # to use conversation history from grok.com\r\nclient.history.set_main_system_prompt(\"Respond briefly and with emojis.\")\r\n\r\n# Send a request with settings\r\nresult = client.ask(\r\n message=\"Draw a cat like in this picture\",\r\n modelName=\"grok-3\", # Default is grok-3 anyway\r\n images=[\"C:\\\\Users\\\\user\\\\Downloads\\\\photo1_to_grok.jpg\",\r\n \"C:\\\\Users\\\\user\\\\Downloads\\\\photo2_to_grok.jpg\"] # You can send multiple images to Grok!\r\n)\r\nprint(f\"Grok3 response: {result.modelResponse.message}\")\r\n\r\n# Save all images\r\nfor i, img in enumerate(result.modelResponse.generatedImages):\r\n img.save_to(f\"cat_{i}.jpg\")\r\n print(f\"Saved: cat_{i}.jpg \ud83d\udc3e\")\r\n```\r\n\r\n> \ud83c\udf1f **The best part? It works with automatically retrieved cookies!** No need to worry about access \u2014 the client sets everything up for you.\r\n\r\n---\r\n\r\n## \ud83d\udd04 Automatic Cookie Retrieval\r\n\r\nIf cookies are missing or expired, Grok3API automatically: \r\n1. Uses the Chrome browser (ensure it\u2019s installed). \r\n2. Visits `https://grok.com/`. \r\n3. Bypasses Cloudflare protection. \r\n4. Continues operation. \r\n\r\nYou don\u2019t need to do anything manually \u2014 just run the code, and it works!\r\n\r\n### [\ud83d\udcbc\ufe0f `GrokClient` Class Description](docs/En/ClientDoc.md) \r\n### [\u2708\ufe0f `ask` Method Description](docs/En/askDoc.md) \r\n### [\ud83d\udccb `History` Class Description](docs/En/HistoryDoc.md) \r\n### [\ud83d\udcec `GrokResponse` Class Description](docs/En/GrokResponse.md) \r\n### [\ud83d\udc27 Working with `Linux`](docs/En/LinuxDoc.md) \r\n### [\ud83c\udf10 Running an OpenAI-Compatible Server](docs/En/OpenAI_Server.md) \r\n\r\n---\r\n\r\n## \ud83d\uddbc\ufe0f Convenient Image Retrieval\r\n\r\nOne of the standout features of GrokClient is its **super-convenient handling of generated images**. Here\u2019s a complete example:\r\n\r\n```python\r\nfrom grok3api.client import GrokClient\r\n\r\nclient = GrokClient()\r\nresult = client.ask(\"Draw a sunset over the sea\")\r\n\r\nfor i, image in enumerate(result.modelResponse.generatedImages):\r\n image.save_to(f\"sunset_{i}.jpg\")\r\n print(f\"Saved: sunset_{i}.jpg \ud83c\udf05\")\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udccb Response Handling\r\n\r\nThe `ask` method returns a `GrokResponse` object.\r\n\r\nFields of the `GrokResponse` object: \r\n- **`modelResponse`**: The main model response. \r\n - `message` (str): The text response. \r\n - `generatedImages` (List[GeneratedImage]): List of images. \r\n- **`isThinking`**: Whether the model was thinking (bool). \r\n- **`isSoftStop`**: Soft stop (bool). \r\n- **`responseId`**: Response ID (str). \r\n- **`newTitle`**: New chat title, if available (Optional[str]). \r\n\r\n### [\ud83d\udcec Detailed `GrokResponse` Class Description](docs/En/GrokResponse.md)\r\n\r\n---\r\n\r\nIf something\u2019s unclear, feel free to raise an issue \u2014 we\u2019ll figure it out together! \ud83c\udf1f\r\n\r\n## Disclaimer\r\nGrok3API has no affiliation with xAI or the Grok developers. It is an independent project created by a third party and is not supported, sponsored or endorsed by xAI. Any issues with Grok should be addressed directly to xAI.\r\nYou are responsible for ensuring that your use of Grok3API complies with all applicable laws and regulations. The developer does not encourage illegal use.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 Grok3, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 cookies, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c. A Python library for interacting with Grok3, focused on maximum ease of use. Automatically gets cookies, so you don't have to specify anything.",
"version": "0.1.0rc1",
"project_urls": {
"Homepage": "https://github.com/boykopovar/Grok3API"
},
"split_keywords": [
"grok3api",
" grok 3 api",
" grok api",
" grok3api python",
" grok ai",
" unofficial grok3api api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3b7ee3df7b71118e9856ecc60570e0d6d7833ac4d5f5173ac2031d766b6906fc",
"md5": "2af131e23f666c2136c51e967738425a",
"sha256": "943c5363b2f6eaabdb7d731bee0eb1b4057d7abb49235c769f317ea9b69788b6"
},
"downloads": -1,
"filename": "grok3api-0.1.0rc1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2af131e23f666c2136c51e967738425a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 29450,
"upload_time": "2025-09-02T16:24:00",
"upload_time_iso_8601": "2025-09-02T16:24:00.629787Z",
"url": "https://files.pythonhosted.org/packages/3b/7e/e3df7b71118e9856ecc60570e0d6d7833ac4d5f5173ac2031d766b6906fc/grok3api-0.1.0rc1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "08fd0db18c97a9fea5c3926177071582a9bc81ebb55b25134ced3e5be2281f7a",
"md5": "050000bcb553c4cfaf29dad08fd2c2b8",
"sha256": "2bf1635bff570e5ba8a9a3cf49395b06c2130d40ec73de6b4d7cf51b7a53568e"
},
"downloads": -1,
"filename": "grok3api-0.1.0rc1.tar.gz",
"has_sig": false,
"md5_digest": "050000bcb553c4cfaf29dad08fd2c2b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 27218,
"upload_time": "2025-09-02T16:24:02",
"upload_time_iso_8601": "2025-09-02T16:24:02.024957Z",
"url": "https://files.pythonhosted.org/packages/08/fd/0db18c97a9fea5c3926177071582a9bc81ebb55b25134ced3e5be2281f7a/grok3api-0.1.0rc1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-02 16:24:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "boykopovar",
"github_project": "Grok3API",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "grok3api"
}