https://github.com/ultracontext/ultracontext-python
The context API for AI agents
https://github.com/ultracontext/ultracontext-python
agents ai ai-agents api context-api context-engineering context-management context-window llm llm-ops python sdk ultracontext versioning
Last synced: 3 months ago
JSON representation
The context API for AI agents
- Host: GitHub
- URL: https://github.com/ultracontext/ultracontext-python
- Owner: ultracontext
- License: mit
- Created: 2026-01-07T07:44:00.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-01-09T19:22:42.000Z (4 months ago)
- Last Synced: 2026-01-12T17:53:46.308Z (3 months ago)
- Topics: agents, ai, ai-agents, api, context-api, context-engineering, context-management, context-window, llm, llm-ops, python, sdk, ultracontext, versioning
- Language: Python
- Homepage: https://ultracontext.ai
- Size: 10.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
The context API for AI agents.
Quickstart
·
Documentation
·
API Reference
📚 Guides
Store & Retrieve
·
Edit Contexts
·
Fork & Clone
·
View History
UltraContext is the simplest way to control what your agents see.
Replace messages, compact/offload context, replay decisions and roll back mistakes — with a single API call. Versioned context out of the box. Full history. Zero complexity.
## Why Context Matters
Context is the RAM of LLMs — everything they can see.
As context grows, model attention spreads thin — this is known as **context rot**. We should aim to provide the smallest set of high-signal tokens that get the job done.
Right now, we're reinventing the wheel for every car we build. Instead of tackling interesting problems, we catch ourselves spending most of our time gluing context together.
**It's time to simplify.**
## Why UltraContext
- **Simple API** — Five methods. That's it.
- **Automatic versioning** — Updates/deletes create versions. Nothing is lost.
- **Time-travel** — Jump to any point by version, index, or timestamp.
- **Schema-free** — Store any JSON. Own your data structure.
- **Framework-agnostic** — Works with any LLM framework.
- **Fast** — Globally distributed. Low latency.
Just plug & play.
## Install
```bash
pip install ultracontext
```
## 🚀 Quick Start
```python
from ultracontext import UltraContext
uc = UltraContext(api_key="uc_live_...")
ctx = uc.create()
uc.append(ctx["id"], {"role": "user", "content": "Hello!"})
# use with any LLM framework
response = generate_text(model=model, messages=uc.get(ctx["id"])["data"])
```
### Async
```python
import asyncio
from ultracontext import AsyncUltraContext
async def main():
uc = AsyncUltraContext(api_key="uc_live_...")
ctx = await uc.create()
await uc.append(ctx["id"], {"role": "user", "content": "Hello!"})
asyncio.run(main())
```
Get an API key from the [UltraContext Dashboard](https://ultracontext.ai/dashboard).
## API
```python
# create - new context or fork
ctx = uc.create()
ctx = uc.create(from_="ctx_abc123")
ctx = uc.create(from_="ctx_abc123", version=2)
ctx = uc.create(from_="ctx_abc123", at=5)
ctx = uc.create(metadata={"user_id": "123"})
# get - retrieve context (or list all)
ctxs = uc.get()
ctxs = uc.get(limit=10)
data = uc.get("ctx_abc123")
data = uc.get("ctx_abc123", version=2)
data = uc.get("ctx_abc123", at=5)
data = uc.get("ctx_abc123", history=True)
# append - add messages (schema-free)
uc.append(ctx["id"], {"role": "user", "content": "Hi"})
uc.append(ctx["id"], [{"role": "user", "content": "Hi"}, {"foo": "bar"}])
# update - modify by id or index (auto-versions)
uc.update(ctx["id"], id="msg_xyz", content="Fixed!")
uc.update(ctx["id"], index=-1, content="Fix last message")
uc.update(ctx["id"], id="msg_xyz", content="Fixed!", metadata={"reason": "typo"})
# delete - remove by id or index (auto-versions)
uc.delete(ctx["id"], "msg_xyz")
uc.delete(ctx["id"], -1)
uc.delete(ctx["id"], ["msg_a", "msg_b", -1], metadata={"reason": "cleanup"})
```
## Documentation
- [Quickstart](https://ultracontext.ai/docs/quickstart/python) — Get running in 2 minutes
- [Guides](https://ultracontext.ai/docs/guides/store-retrieve-contexts) — Practical patterns for common use cases
- [API Reference](https://ultracontext.ai/docs/api-reference/introduction) — Full endpoint documentation
## License
MIT
---