Examples
Python + OpenAI
Add persistent memory to an OpenAI-powered Python agent in two lines.
1. Install
pip install "coorda[openai]"2. Wrap your OpenAI client
One import, one wrap line. Every completion call now reads and writes through Coorda.
from openai import OpenAI
from coorda import Coorda
coorda = Coorda(api_key="ck_live_...")
client = coorda.wrap(OpenAI(), agent_id="triage-bot")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Customer asking about billing"}],
coorda={"entity_id": "customer_123"},
)What happens on every call
Before the call, Coorda searches for prior context tagged to
customer_123 and prepends it as a system message. After the call, the input/output pair is stored in a background thread so the next agent (even a different one) can retrieve it.Before and after
Without the SDK, the same integration requires manual HTTP calls around every LLM invocation. With wrap(), Coorda becomes invisible.
Without the SDK
import requests
from openai import OpenAI
COORDA = "https://coorda-app.vercel.app"
H = {"X-API-Key": "ck_live_...", "Content-Type": "application/json"}
def handle(entity_id, user_msg):
prior = requests.get(
f"{COORDA}/api/context/inject",
params={"query": user_msg, "entityId": entity_id},
headers=H,
).json()
messages = [{"role": "user", "content": user_msg}]
if prior.get("hasContext"):
messages = [{"role": "system", "content": prior["context"]}] + messages
resp = OpenAI().chat.completions.create(
model="gpt-4o", messages=messages,
)
output = resp.choices[0].message.content
requests.post(f"{COORDA}/api/context", headers=H, json={
"taskId": "t1", "entityId": entity_id, "agentId": "triage",
"input": user_msg, "output": output,
})
return outputWith wrap()
from openai import OpenAI
from coorda import Coorda
coorda = Coorda(api_key="ck_live_...")
client = coorda.wrap(OpenAI(), agent_id="triage")
def handle(entity_id, user_msg):
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": user_msg}],
coorda={"entity_id": entity_id},
)
return resp.choices[0].message.contentPer-call options
client.chat.completions.create(
model="gpt-4o",
messages=[...],
coorda={
"entity_id": "customer_123",
"skip_inject": True, # don't pull prior context for this call
"skip_store": True, # don't save the output
"min_similarity": 0.5, # stricter relevance threshold
"limit": 3, # fewer pieces of prior context
"metadata": {"priority": "high"},
},
)
# Pass coorda=False to fully bypass Coorda for one call.
client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "internal-only query"}],
coorda=False,
)Safe by default
If Coorda is unreachable or returns an error, your agent still runs. All Coorda errors are swallowed — the underlying OpenAI call always executes, and storage happens asynchronously.