[](https://badge.fury.io/py/py-context-llm7)
[](https://opensource.org/licenses/MIT)
[](https://pepy.tech/project/py-context-llm7)
[](https://www.linkedin.com/in/eugene-evstafev-716669181/)
# py-context-llm7
`py-context-llm7` is a minimal Python client for the `https://api.context.llm7.io` service.
It lets you authenticate, manage **projects** and **contexts**, and **search** (retrieve relevant context for a query) with a tiny, dependency‑light API (built on `requests`).
---
## Installation
```bash
pip install py-context-llm7
```
---
## Quickstart
### Authenticate with a **personal token**
```python
import os
import time
from py_context_llm7 import ContextClient
client = ContextClient(bearer=os.environ["CONTEXT_TOKEN"])
print(client.me())
# {'user_id': '...', 'email': '...'}
pid = client.create_project_and_fetch_id("My project")
client.add_context(pid, "The capital of France is Paris.")
client.add_context(pid, "The capital of Germany is Berlin.")
client.add_context(pid, "The capital of Italy is Rome.")
client.add_context(pid, "The capital of Spain is Madrid.")
client.add_context(pid, "The capital of Portugal is Lisbon.")
client.add_context(pid, "The capital of the Netherlands is Amsterdam.")
client.add_context(pid, "The capital of Belgium is Brussels.")
client.add_context(pid, "The capital of Greece is Athens.")
client.add_context(pid, "The capital of Sweden is Stockholm.")
print(client.list_projects())
print(client.list_contexts(pid))
print(f"pid: {pid}")
time.sleep(5) # allow a short delay for vector indexing
print(client.search(pid, "What is the capital of Italy?"))
# Example:
# {'context': 'The capital of Portugal is Lisbon.\nThe capital of Germany is Berlin.\nThe capital of Spain is Madrid.\nThe capital of Italy is Rome.\nThe capital of France is Paris.', 'query': 'What is the capital of Italy?'}
```
### First‑time setup via **Google ID token → app JWT → personal token**
Visit https://context.llm7.io/ and log in with your Google account. This will create an app JWT for you.
Then, you will be able to create a free token for API.
## Features
* **Simple auth**: Use a personal token directly or exchange a Google ID token for an app JWT.
* **Project management**: List, create, and delete projects.
* **Context management**: Add, list, and delete contexts (with a helper to delete by `vector_id`).
* **Search**: Query for relevant context across your stored items.
* **Minimal deps**: Only `requests`.
* **Clear errors**: Raises `ContextAPIError(status, message)` on non‑2xx responses.
---
## API Overview
```python
from py_context_llm7 import ContextClient, ContextAPIError
```
### Construction
* `ContextClient(base_url="https://api.context.llm7.io", bearer=None, timeout=30)`
### Auth
* `set_bearer(token: str) -> None`
Set an app JWT or personal token.
* `verify_google_id_token(id_token: str) -> dict`
GET `/verify?token=...` → returns `{"email": str, "token": "<app_jwt>"}` and sets bearer.
* `list_tokens() -> list[dict]` *(requires app JWT)*
* `create_personal_token(set_as_current: bool = True) -> dict` *(requires app JWT)*
* `delete_token(token_id: int) -> dict` *(requires app JWT)*
### User
* `me() -> dict`
GET `/me` → `{"user_id": str, "email": str}`.
### Projects
* `list_projects() -> list[dict]`
* `create_project(name: str) -> dict`
* `create_project_and_fetch_id(name: str) -> int` *(create then re‑list; newest id)*
* `delete_project(project_id: int) -> dict`
### Contexts
* `list_contexts(project_id: int) -> list[dict]`
Returns items like `{"id": int, "source": str, "vector_id": str}`.
* `add_context(project_id: int, source: str) -> dict`
Returns `{"status": "added", "vector_id": "..."}`.
* `delete_context(project_id: int, context_id: int) -> dict`
* `delete_context_by_vector_id(project_id: int, vector_id: str) -> dict`
### Search
* `search(project_id: int, query: str) -> dict`
Returns `{"context": "<joined sources>", "query": "..."}`.
### Error Handling
```python
try:
client.add_context(pid, "Some text")
except ContextAPIError as e:
print(e.status, e.message)
```
---
## Tips
* **Indexing delay:** after adding contexts, wait briefly (e.g., 2–5 seconds) before searching so the vectors are indexed.
* **Base URL:** override `base_url` if you run a self‑hosted deployment.
* **Security:** keep both app JWTs and personal tokens secret.
---
## Contributing
Issues and PRs are welcome. Please open them on the repo:
* Issues: [https://github.com/chigwell/py-context-llm7/issues](https://github.com/chigwell/py-context-llm7/issues)
* Source: [https://github.com/chigwell/py-context-llm7](https://github.com/chigwell/py-context-llm7)
---
## License
`py-context-llm7` is released under the [MIT License](https://choosealicense.com/licenses/mit/).
---
## Support
Email: **[support@llm7.io](mailto:support@llm7.io)**
Raw data
{
"_id": null,
"home_page": "https://github.com/chigwell/py-context-llm7",
"name": "py-context-llm7",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "llm, client, context, vector, rag",
"author": "Eugene Evstafev",
"author_email": "support@llm7.io",
"download_url": "https://files.pythonhosted.org/packages/b4/10/ca4f5f866a8eaa170069290af31ef395271416baebaed0cf63784b73f85b/py_context_llm7-0.1.0.tar.gz",
"platform": null,
"description": "[](https://badge.fury.io/py/py-context-llm7)\n[](https://opensource.org/licenses/MIT)\n[](https://pepy.tech/project/py-context-llm7)\n[](https://www.linkedin.com/in/eugene-evstafev-716669181/)\n\n# py-context-llm7\n\n`py-context-llm7` is a minimal Python client for the `https://api.context.llm7.io` service.\nIt lets you authenticate, manage **projects** and **contexts**, and **search** (retrieve relevant context for a query) with a tiny, dependency\u2011light API (built on `requests`).\n\n---\n\n## Installation\n\n```bash\npip install py-context-llm7\n```\n\n---\n\n## Quickstart\n\n### Authenticate with a **personal token**\n\n```python\nimport os\nimport time\n\nfrom py_context_llm7 import ContextClient\n\nclient = ContextClient(bearer=os.environ[\"CONTEXT_TOKEN\"])\n\nprint(client.me())\n# {'user_id': '...', 'email': '...'}\n\npid = client.create_project_and_fetch_id(\"My project\")\nclient.add_context(pid, \"The capital of France is Paris.\")\nclient.add_context(pid, \"The capital of Germany is Berlin.\")\nclient.add_context(pid, \"The capital of Italy is Rome.\")\nclient.add_context(pid, \"The capital of Spain is Madrid.\")\nclient.add_context(pid, \"The capital of Portugal is Lisbon.\")\nclient.add_context(pid, \"The capital of the Netherlands is Amsterdam.\")\nclient.add_context(pid, \"The capital of Belgium is Brussels.\")\nclient.add_context(pid, \"The capital of Greece is Athens.\")\nclient.add_context(pid, \"The capital of Sweden is Stockholm.\")\n\nprint(client.list_projects())\nprint(client.list_contexts(pid))\n\nprint(f\"pid: {pid}\")\ntime.sleep(5) # allow a short delay for vector indexing\n\nprint(client.search(pid, \"What is the capital of Italy?\"))\n# Example:\n# {'context': 'The capital of Portugal is Lisbon.\\nThe capital of Germany is Berlin.\\nThe capital of Spain is Madrid.\\nThe capital of Italy is Rome.\\nThe capital of France is Paris.', 'query': 'What is the capital of Italy?'}\n```\n\n### First\u2011time setup via **Google ID token \u2192 app JWT \u2192 personal token**\n\n\nVisit https://context.llm7.io/ and log in with your Google account. This will create an app JWT for you.\n\nThen, you will be able to create a free token for API.\n\n\n## Features\n\n* **Simple auth**: Use a personal token directly or exchange a Google ID token for an app JWT.\n* **Project management**: List, create, and delete projects.\n* **Context management**: Add, list, and delete contexts (with a helper to delete by `vector_id`).\n* **Search**: Query for relevant context across your stored items.\n* **Minimal deps**: Only `requests`.\n* **Clear errors**: Raises `ContextAPIError(status, message)` on non\u20112xx responses.\n\n---\n\n## API Overview\n\n```python\nfrom py_context_llm7 import ContextClient, ContextAPIError\n```\n\n### Construction\n\n* `ContextClient(base_url=\"https://api.context.llm7.io\", bearer=None, timeout=30)`\n\n### Auth\n\n* `set_bearer(token: str) -> None`\n Set an app JWT or personal token.\n\n* `verify_google_id_token(id_token: str) -> dict`\n GET `/verify?token=...` \u2192 returns `{\"email\": str, \"token\": \"<app_jwt>\"}` and sets bearer.\n\n* `list_tokens() -> list[dict]` *(requires app JWT)*\n\n* `create_personal_token(set_as_current: bool = True) -> dict` *(requires app JWT)*\n\n* `delete_token(token_id: int) -> dict` *(requires app JWT)*\n\n### User\n\n* `me() -> dict`\n GET `/me` \u2192 `{\"user_id\": str, \"email\": str}`.\n\n### Projects\n\n* `list_projects() -> list[dict]`\n* `create_project(name: str) -> dict`\n* `create_project_and_fetch_id(name: str) -> int` *(create then re\u2011list; newest id)*\n* `delete_project(project_id: int) -> dict`\n\n### Contexts\n\n* `list_contexts(project_id: int) -> list[dict]`\n Returns items like `{\"id\": int, \"source\": str, \"vector_id\": str}`.\n\n* `add_context(project_id: int, source: str) -> dict`\n Returns `{\"status\": \"added\", \"vector_id\": \"...\"}`.\n\n* `delete_context(project_id: int, context_id: int) -> dict`\n\n* `delete_context_by_vector_id(project_id: int, vector_id: str) -> dict`\n\n### Search\n\n* `search(project_id: int, query: str) -> dict`\n Returns `{\"context\": \"<joined sources>\", \"query\": \"...\"}`.\n\n### Error Handling\n\n```python\ntry:\n client.add_context(pid, \"Some text\")\nexcept ContextAPIError as e:\n print(e.status, e.message)\n```\n\n---\n\n## Tips\n\n* **Indexing delay:** after adding contexts, wait briefly (e.g., 2\u20135 seconds) before searching so the vectors are indexed.\n* **Base URL:** override `base_url` if you run a self\u2011hosted deployment.\n* **Security:** keep both app JWTs and personal tokens secret.\n\n---\n\n## Contributing\n\nIssues and PRs are welcome. Please open them on the repo:\n\n* Issues: [https://github.com/chigwell/py-context-llm7/issues](https://github.com/chigwell/py-context-llm7/issues)\n* Source: [https://github.com/chigwell/py-context-llm7](https://github.com/chigwell/py-context-llm7)\n\n---\n\n## License\n\n`py-context-llm7` is released under the [MIT License](https://choosealicense.com/licenses/mit/).\n\n---\n\n## Support\n\nEmail: **[support@llm7.io](mailto:support@llm7.io)**\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Minimal Python client for https://api.context.llm7.io",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/chigwell/py-context-llm7",
"Issues": "https://github.com/chigwell/py-context-llm7/issues",
"Source": "https://github.com/chigwell/py-context-llm7"
},
"split_keywords": [
"llm",
" client",
" context",
" vector",
" rag"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "90ffd1357bc609c5fc94789a60d3ffad88e3d3971a16d1a6d3cb132b5c020090",
"md5": "f44ce3155b393322bd4821db75736402",
"sha256": "714cec78c33c35ce7a171fbcfd28b486db6db8db1cbc4f098637c46ea21d0016"
},
"downloads": -1,
"filename": "py_context_llm7-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f44ce3155b393322bd4821db75736402",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6572,
"upload_time": "2025-07-29T20:42:34",
"upload_time_iso_8601": "2025-07-29T20:42:34.192299Z",
"url": "https://files.pythonhosted.org/packages/90/ff/d1357bc609c5fc94789a60d3ffad88e3d3971a16d1a6d3cb132b5c020090/py_context_llm7-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b410ca4f5f866a8eaa170069290af31ef395271416baebaed0cf63784b73f85b",
"md5": "bdac620818f82ec1d179f1021689d614",
"sha256": "f8ac4d173ba12a1bb9f16a0df689cad32676fc4fb0037b60bb49abc0cd821a5a"
},
"downloads": -1,
"filename": "py_context_llm7-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "bdac620818f82ec1d179f1021689d614",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6417,
"upload_time": "2025-07-29T20:42:36",
"upload_time_iso_8601": "2025-07-29T20:42:36.320956Z",
"url": "https://files.pythonhosted.org/packages/b4/10/ca4f5f866a8eaa170069290af31ef395271416baebaed0cf63784b73f85b/py_context_llm7-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-29 20:42:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "chigwell",
"github_project": "py-context-llm7",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "py-context-llm7"
}