{"id":37649614,"url":"https://github.com/contextco/context-py","last_synced_at":"2026-01-16T11:31:00.553Z","repository":{"id":171718542,"uuid":"647946229","full_name":"contextco/context-py","owner":"contextco","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-05T12:51:56.000Z","size":486,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-05T14:45:42.759Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/contextco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-31T21:45:46.000Z","updated_at":"2024-08-05T12:51:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"2eb2d95e-94ea-4caf-b9db-fb27784e2a91","html_url":"https://github.com/contextco/context-py","commit_stats":null,"previous_names":["contextco/context-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/contextco/context-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contextco%2Fcontext-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contextco%2Fcontext-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contextco%2Fcontext-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contextco%2Fcontext-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contextco","download_url":"https://codeload.github.com/contextco/context-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contextco%2Fcontext-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-16T11:31:00.444Z","updated_at":"2026-01-16T11:31:00.548Z","avatar_url":"https://github.com/contextco.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Context Python Library\n\n[![PyPI version](https://badge.fury.io/py/context-python.svg)](https://badge.fury.io/py/context-python)\n\nThe Context Python library provides a convenient way to interface with the Context APIs. We include pre-defined classes and operations to interact with API resources.\n\n## Installation\n\n```\npip install --upgrade context-python\n```\n\n## Usage\n\nThe library needs to be configured with your Context API key, which is available in the [Context Settings Dashboard](https://go.getcontext.ai/settings).\n\n### Synchronous Example\n\n```python\nimport getcontext\nfrom getcontext.generated.models import Conversation, Message, MessageRole, Rating\nfrom getcontext.token import Credential\nimport os\n\ntoken = os.environ.get(\"GETCONTEXT_TOKEN\")\n\nc = getcontext.ContextAPI(credential=Credential(token))\n\nc.log.conversation(\n    body={\n        \"conversation\": Conversation(\n            messages=[\n                Message(\n                    message=\"You are a helpful assistant!\",\n                    role=MessageRole.SYSTEM,\n                ),\n                Message(\n                    message=\"Hello, world!\",\n                    role=MessageRole.USER,\n                ),\n                Message(\n                    message=\"Hi, how can I help?\",\n                    role=MessageRole.ASSISTANT,\n                    rating=Rating.POSITIVE,\n                ),\n            ],\n        )\n    }\n)\n```\n\n### Async Example\n\n```python\nimport asyncio\n\nimport getcontext.generated.aio as getcontext\nfrom getcontext.generated.models import Conversation, Message, MessageRole, Rating\nfrom getcontext.token import AsyncCredential\nimport os\n\ntoken = os.environ.get(\"GETCONTEXT_TOKEN\")\n\n\nasync def log():\n    async with getcontext.ContextAPI(credential=AsyncCredential(token)) as client:\n        await client.log.conversation(\n            body={\n                \"conversation\": Conversation(\n                    messages=[\n                        Message(\n                            message=\"You are a helpful assistant!\",\n                            role=MessageRole.SYSTEM,\n                        ),\n                        Message(\n                            message=\"Hello, world!\",\n                            role=MessageRole.USER,\n                        ),\n                        Message(\n                            message=\"Hi, how can I help?\",\n                            role=MessageRole.ASSISTANT,\n                            rating=Rating.POSITIVE,\n                        ),\n                    ],\n                )\n            }\n        )\n\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(log())\nloop.close()\n```\n\n## Appendix\n\n```yaml\npython: true\noutput-folder: getcontext/generated/\nno-namespace-folders: true\ncredential-default-policy-type: BearerTokenCredentialPolicy\nblack: true\npython3-only: true\nadd-credential: true\ncredential-scopes: all\nmodels-mode: msrest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontextco%2Fcontext-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontextco%2Fcontext-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontextco%2Fcontext-py/lists"}