{"id":50879174,"url":"https://github.com/cachly-dev/cachly-openclaw","last_synced_at":"2026-06-15T12:03:58.925Z","repository":{"id":351911853,"uuid":"1213039298","full_name":"cachly-dev/cachly-openclaw","owner":"cachly-dev","description":"Official Cachly adapter for OpenClaw – persistent sessions, semantic LLM cache, memory storage","archived":false,"fork":false,"pushed_at":"2026-06-06T21:58:44.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-06T23:19:35.242Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://cachly.dev/docs/openclaw","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cachly-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-17T01:37:29.000Z","updated_at":"2026-04-20T10:28:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cachly-dev/cachly-openclaw","commit_stats":null,"previous_names":["cachly-dev/sdk-openclaw","cachly-dev/cachly-openclaw"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cachly-dev/cachly-openclaw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachly-dev%2Fcachly-openclaw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachly-dev%2Fcachly-openclaw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachly-dev%2Fcachly-openclaw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachly-dev%2Fcachly-openclaw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cachly-dev","download_url":"https://codeload.github.com/cachly-dev/cachly-openclaw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachly-dev%2Fcachly-openclaw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34361404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-06-15T12:03:57.936Z","updated_at":"2026-06-15T12:03:58.920Z","avatar_url":"https://github.com/cachly-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @cachly-dev/openclaw\n\n\u003e **You paid $0.08 for that answer. The next 1,000 identical asks: $0.00.**  \n\u003e Semantic LLM cache + persistent sessions + AI memory. 3 lines. No embeddings required.\n\n[![npm](https://img.shields.io/npm/v/@cachly-dev/openclaw?color=red\u0026logo=npm)](https://www.npmjs.com/package/@cachly-dev/openclaw)\n[![npm downloads](https://img.shields.io/npm/dm/@cachly-dev/openclaw?color=blue)](https://www.npmjs.com/package/@cachly-dev/openclaw)\n[![Free tier](https://img.shields.io/badge/Free%20tier-€0%2Fmo-brightgreen)](https://cachly.dev)\n[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](../../LICENSE)\n\n---\n\n## Before / After\n\n```typescript\n// ❌ Before: Every user message calls OpenAI. Every time. No exceptions.\nconst reply = await openai.chat.completions.create({ model: 'gpt-4o', messages })\n\n// ✅ After: Same questions = zero API calls = zero cost\nconst cache = createSemanticLLMCache({ url: process.env.CACHLY_URL })\nconst reply = await cache.getOrSet(userMessage, () =\u003e\n  openai.chat.completions.create({ model: 'gpt-4o', messages })\n)\n```\n\n\"How do I reset my password?\" → \"How can I reset my pw?\" → **cache hit**. $0.00.\n\n---\n\n## Setup — 60 seconds\n\n```bash\nnpm install @cachly-dev/openclaw\n```\n\n```bash\n# Get a free Redis instance at cachly.dev (no credit card):\nCACHLY_URL=redis://:password@your-instance.cachly.dev:6379\n```\n\n---\n\n## ⚡ Semantic LLM Cache — 3 lines\n\nEvery time a user asks the same question in different words, you pay OpenAI again. This stops that.\n\n```typescript\nimport { createSemanticLLMCache } from '@cachly-dev/openclaw'\n\nconst cache = createSemanticLLMCache({ url: process.env.CACHLY_URL! })\n\n// Wrap any LLM call — that's it\nconst answer = await cache.getOrSet(\n  userPrompt,\n  () =\u003e openai.chat.completions.create({ model: 'gpt-4o', messages: [...] })\n)\n```\n\n**Without an embed function + no vectorUrl:** exact-match caching + **local BM25+ fuzzy search** kick in immediately (20–50% savings). No API calls. \"how do I reset password?\" matches \"password reset help\" — pure in-process.\n\n**Without an embed function + vectorUrl:** BM25 + hosted pgvector index, higher hit rates across large caches.\n\n**Add semantic matching** for 60–90% savings (10 more lines):\n\n```typescript\nconst cache = createSemanticLLMCache({\n  url:       process.env.CACHLY_URL!,\n  vectorUrl: process.env.CACHLY_VECTOR_URL,   // from cachly.dev dashboard\n  embedFn:   (text) =\u003e\n    openai.embeddings.create({ model: 'text-embedding-3-small', input: text })\n      .then(r =\u003e r.data[0].embedding),\n  threshold: 0.92,   // cosine similarity (default)\n  ttl:       3600,   // seconds\n})\n```\n\n\"How do I reset my password?\" → \"How can I reset my pw?\" → **same cache hit**. 💰\n\n---\n\n## 📊 What you save\n\n| Questions/day | Cache hit rate | Monthly saving (GPT-4o) |\n|---------------|---------------|------------------------|\n| 100           | 40% exact     | ~$8                    |\n| 100           | 70% semantic  | ~$22                   |\n| 1 000         | 70% semantic  | ~$220                  |\n| 10 000        | 70% semantic  | ~$2 200                |\n\nAfter 10 cache hits, the console logs:\n```\n🎯 cachly: 12,340 tokens saved this session (10 hits)\n   Full stats → cachly.dev/dashboard\n```\n(Cost breakdown available in the dashboard.)\n\n---\n\n## 🗄️ Session Store\n\nPersist conversation history in Redis — no cold starts, no lost context:\n\n```typescript\nimport { createCachlySessionStore } from '@cachly-dev/openclaw'\n\nconst sessions = createCachlySessionStore({\n  url: process.env.CACHLY_URL!,\n  ttl: 604800,  // 7 days\n})\n\nconst history = await sessions.get(userId)\nawait sessions.set(userId, [...history, { role: 'user', content: message }])\n```\n\nWorks with any LLM framework — OpenAI, LangChain, Vercel AI SDK, etc.\n\n---\n\n## 🧠 Memory Adapter\n\nLong-term semantic memory — store facts, recall by meaning:\n\n```typescript\nimport { createCachlyMemoryAdapter } from '@cachly-dev/openclaw'\n\nconst memory = createCachlyMemoryAdapter({\n  url:       process.env.CACHLY_URL!,\n  vectorUrl: process.env.CACHLY_VECTOR_URL!,\n  embedFn:   myEmbedFn,\n  ttl:       7776000,  // 90 days\n})\n\nawait memory.store({ id: 'pref-1', text: 'User prefers TypeScript over Python' })\nconst results = await memory.search('programming language preference', { topK: 5 })\n// → [{ text: 'User prefers TypeScript over Python', score: 0.97 }]\n```\n\n---\n\n## 🔍 Brain Search (BM25+)\n\nFull-text search over cached data — no embeddings needed:\n\n```typescript\nimport { brainSearch } from '@cachly-dev/openclaw'\n\nconst results = await brainSearch(process.env.CACHLY_VECTOR_URL!, 'deploy authentication error')\n// → [{ key: 'lesson:fix:auth', score: 4.2, preview: '...' }]\n```\n\n---\n\n## 🧩 Standalone — works with any LLM stack\n\nNo OpenClaw needed. Drop into LangChain, Vercel AI SDK, plain `fetch`, or any custom pipeline:\n\n### LangChain\n```typescript\nimport { createSemanticLLMCache } from '@cachly-dev/openclaw'\nimport { ChatOpenAI } from '@langchain/openai'\n\nconst cache = createSemanticLLMCache({ url: process.env.CACHLY_URL! })\nconst llm = new ChatOpenAI()\n\nasync function cachedInvoke(prompt: string) {\n  return cache.getOrSet(\n    prompt,\n    () =\u003e llm.invoke(prompt).then(r =\u003e ({ content: r.content as string, model: 'gpt-4o' }))\n  )\n}\n```\n\n### Vercel AI SDK\n```typescript\nimport { createSemanticLLMCache } from '@cachly-dev/openclaw'\nimport { generateText } from 'ai'\nimport { openai } from '@ai-sdk/openai'\n\nconst cache = createSemanticLLMCache({ url: process.env.CACHLY_URL! })\n\nexport async function POST(req: Request) {\n  const { prompt } = await req.json()\n  const result = await cache.getOrSet(\n    prompt,\n    () =\u003e generateText({ model: openai('gpt-4o'), prompt }).then(r =\u003e ({ content: r.text, model: 'gpt-4o' }))\n  )\n  return Response.json(result)\n}\n```\n\n### Plain fetch / any provider\n```typescript\nimport { createSemanticLLMCache } from '@cachly-dev/openclaw'\n\nconst cache = createSemanticLLMCache({ url: process.env.CACHLY_URL! })\n\nconst answer = await cache.getOrSet(\n  userMessage,\n  async () =\u003e {\n    const res = await fetch('https://api.anthropic.com/v1/messages', {\n      method: 'POST',\n      headers: { 'x-api-key': process.env.ANTHROPIC_KEY!, 'content-type': 'application/json' },\n      body: JSON.stringify({ model: 'claude-opus-4-5', max_tokens: 1024, messages: [{ role: 'user', content: userMessage }] }),\n    })\n    const json = await res.json()\n    return { content: json.content[0].text, model: 'claude-opus-4-5', inputTokens: json.usage.input_tokens, outputTokens: json.usage.output_tokens }\n  }\n)\n```\n\n---\n\n## 🦾 OpenClaw adapter (bonus)\n\nIf you use [OpenClaw](https://openclaw.dev) (22-channel AI assistant), one function wires everything:\n\n```typescript\nimport { createCachlyOpenClawConfig } from '@cachly-dev/openclaw'\nimport OpenAI from 'openai'\n\nconst openai = new OpenAI()\n\nconst cachlyConfig = await createCachlyOpenClawConfig({\n  url:       process.env.CACHLY_URL!,\n  vectorUrl: process.env.CACHLY_VECTOR_URL,\n  embedFn:   (t) =\u003e\n    openai.embeddings.create({ model: 'text-embedding-3-small', input: t })\n      .then(r =\u003e r.data[0].embedding),\n})\n\nconst app = new OpenClawApp({\n  ...cachlyConfig,\n  // ... rest of your config\n})\n```\n\nThis gives you: semantic cache + persistent sessions + Redis memory — all across WhatsApp, Telegram, Slack, Discord at once.\n\n---\n\n## 👥 Team Brain\n\nOne shared cachly instance → every team member gets smarter from each other's work:\n\n```typescript\n// Alice fixes a deploy issue:\nawait brain.learnFromAttempts({ topic: 'deploy:k8s', outcome: 'success', whatWorked: '...' })\n\n// Bob starts a session the next day:\nawait brain.sessionStart()\n// → \"💡 alice solved deploy:k8s 1d ago: ...\"\n```\n\nTeam plans from €99/mo (10 seats) at [cachly.dev/teams](https://cachly.dev/teams).\n\n---\n\n## 🚀 Upgrade path\n\n| Level | What you get | Setup |\n|-------|-------------|-------|\n| **Free — Exact + BM25** | 20–50% reduction, in-process BM25+ fuzzy, zero config | `CACHLY_URL` only |\n| **Free — Semantic cache** | 60–90% cost reduction | + `embedFn` |\n| **Speed tier** | Hosted pgvector, higher hit rates at scale | Speed plan at cachly.dev |\n| **Team Brain** | Shared knowledge, team lessons, analytics | cachly.dev/teams |\n\n---\n\n## 🤖 Use with Python AI Agents\n\nOpenClaw has a TypeScript SDK, but Python AI agents can use Cachly's REST API directly for persistent memory and semantic caching. Here are patterns for the most popular frameworks.\n\n### LangChain — Persistent Agent Memory\n\n```python\nimport os, requests\nfrom langchain.memory import ConversationBufferMemory\nfrom langchain.schema import BaseMemory\nfrom typing import Any\n\nCACHLY_URL = os.environ[\"CACHLY_URL\"]\nCACHLY_JWT = os.environ[\"CACHLY_JWT\"]\nINSTANCE_ID = os.environ[\"CACHLY_BRAIN_INSTANCE_ID\"]\nHEADERS = {\"Authorization\": f\"Bearer {CACHLY_JWT}\", \"Content-Type\": \"application/json\"}\n\nclass CachlyBrainMemory(BaseMemory):\n    \"\"\"LangChain memory backed by Cachly Brain — survives restarts.\"\"\"\n\n    @property\n    def memory_variables(self):\n        return [\"brain_context\"]\n\n    def load_memory_variables(self, inputs: dict) -\u003e dict:\n        query = inputs.get(\"input\", \"\")\n        r = requests.post(\n            f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/brain/smart-recall\",\n            headers=HEADERS,\n            json={\"query\": query, \"topK\": 3},\n        )\n        lessons = r.json().get(\"results\", [])\n        context = \"\\n\".join(f\"- {l['whatWorked']}\" for l in lessons if l.get(\"whatWorked\"))\n        return {\"brain_context\": context or \"No relevant memory found.\"}\n\n    def save_context(self, inputs: dict, outputs: dict) -\u003e None:\n        # Learn from what the agent discovered\n        output = outputs.get(\"output\", \"\")\n        if output:\n            requests.post(\n                f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/brain/learn\",\n                headers=HEADERS,\n                json={\"topic\": \"agent:langchain\", \"outcome\": \"success\", \"whatWorked\": output[:500]},\n            )\n\n    def clear(self):\n        pass  # Brain is persistent — clear not supported by design\n\n\n# Usage:\nfrom langchain.agents import initialize_agent, AgentType\nfrom langchain.chat_models import ChatOpenAI\n\nmemory = CachlyBrainMemory()\nagent = initialize_agent(\n    tools=[...],\n    llm=ChatOpenAI(model=\"gpt-4o\"),\n    agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,\n    memory=memory,\n    system_message=\"You have access to a persistent Brain. brain_context = {brain_context}\",\n)\n```\n\n### CrewAI — Shared Team Brain Tool\n\n```python\nimport os, requests\nfrom crewai_tools import BaseTool\nfrom pydantic import BaseModel, Field\n\nCACHLY_URL = os.environ[\"CACHLY_URL\"]\nCACHLY_JWT = os.environ[\"CACHLY_JWT\"]\nINSTANCE_ID = os.environ[\"CACHLY_BRAIN_INSTANCE_ID\"]\nHEADERS = {\"Authorization\": f\"Bearer {CACHLY_JWT}\"}\n\nclass RecallInput(BaseModel):\n    query: str = Field(description=\"What to search for in the Brain\")\n\nclass CachlyRecallTool(BaseTool):\n    name: str = \"cachly_brain_recall\"\n    description: str = \"Search persistent memory for lessons, solutions, and context from past work\"\n    args_schema: type[BaseModel] = RecallInput\n\n    def _run(self, query: str) -\u003e str:\n        r = requests.post(\n            f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/brain/smart-recall\",\n            headers={**HEADERS, \"Content-Type\": \"application/json\"},\n            json={\"query\": query, \"topK\": 5},\n        )\n        results = r.json().get(\"results\", [])\n        if not results:\n            return \"No relevant memory found.\"\n        return \"\\n\".join(f\"[{l['topic']}] {l['whatWorked']}\" for l in results)\n\nclass LearnInput(BaseModel):\n    topic: str = Field(description=\"Category slug like 'deploy:api' or 'fix:auth'\")\n    what_worked: str = Field(description=\"What solution worked\")\n    outcome: str = Field(default=\"success\", description=\"success | failure | partial\")\n\nclass CachlyLearnTool(BaseTool):\n    name: str = \"cachly_brain_learn\"\n    description: str = \"Store a lesson in persistent memory so future agents can benefit from it\"\n    args_schema: type[BaseModel] = LearnInput\n\n    def _run(self, topic: str, what_worked: str, outcome: str = \"success\") -\u003e str:\n        requests.post(\n            f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/brain/learn\",\n            headers={**HEADERS, \"Content-Type\": \"application/json\"},\n            json={\"topic\": topic, \"outcome\": outcome, \"whatWorked\": what_worked},\n        )\n        return f\"✅ Stored lesson: {topic}\"\n\n\n# Usage with CrewAI:\nfrom crewai import Agent, Task, Crew\n\nresearcher = Agent(\n    role=\"Research Analyst\",\n    goal=\"Research topics and store findings for the team\",\n    tools=[CachlyRecallTool(), CachlyLearnTool()],\n    backstory=\"You have a persistent memory that survives across sessions.\",\n)\n```\n\n### AutoGen / Microsoft AutoGen\n\n```python\nimport os, requests\nfrom autogen import AssistantAgent, UserProxyAgent\n\nCACHLY_URL = os.environ[\"CACHLY_URL\"]\nCACHLY_JWT = os.environ[\"CACHLY_JWT\"]\nINSTANCE_ID = os.environ[\"CACHLY_BRAIN_INSTANCE_ID\"]\nHEADERS = {\"Authorization\": f\"Bearer {CACHLY_JWT}\", \"Content-Type\": \"application/json\"}\n\ndef recall_brain(query: str) -\u003e str:\n    \"\"\"Search Cachly Brain for relevant memory.\"\"\"\n    r = requests.post(\n        f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/brain/smart-recall\",\n        headers=HEADERS, json={\"query\": query, \"topK\": 5},\n    )\n    results = r.json().get(\"results\", [])\n    return \"\\n\".join(f\"• [{l['topic']}] {l['whatWorked']}\" for l in results) or \"No memory found.\"\n\ndef store_lesson(topic: str, what_worked: str, outcome: str = \"success\") -\u003e str:\n    \"\"\"Store a lesson in Cachly Brain.\"\"\"\n    requests.post(\n        f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/brain/learn\",\n        headers=HEADERS, json={\"topic\": topic, \"outcome\": outcome, \"whatWorked\": what_worked},\n    )\n    return f\"Stored: {topic}\"\n\nassistant = AssistantAgent(\n    name=\"CachlyAssistant\",\n    system_message=\"\"\"You are a helpful AI with persistent memory via Cachly Brain.\nALWAYS start by calling recall_brain() with the user's query.\nALWAYS end by calling store_lesson() with what you discovered.\"\"\",\n    llm_config={\n        \"functions\": [\n            {\"name\": \"recall_brain\", \"description\": \"Search persistent memory\", \"parameters\": {\"type\": \"object\", \"properties\": {\"query\": {\"type\": \"string\"}}, \"required\": [\"query\"]}},\n            {\"name\": \"store_lesson\", \"description\": \"Store a lesson\", \"parameters\": {\"type\": \"object\", \"properties\": {\"topic\": {\"type\": \"string\"}, \"what_worked\": {\"type\": \"string\"}, \"outcome\": {\"type\": \"string\"}}, \"required\": [\"topic\", \"what_worked\"]}},\n        ],\n    },\n)\n```\n\n### LlamaIndex — QueryEngine with Cachly Memory\n\n```python\nimport os, requests\nfrom llama_index.core.memory import BaseMemory\nfrom llama_index.core.schema import TextNode\n\nCACHLY_URL = os.environ[\"CACHLY_URL\"]\nCACHLY_JWT = os.environ[\"CACHLY_JWT\"]\nINSTANCE_ID = os.environ[\"CACHLY_BRAIN_INSTANCE_ID\"]\nHEADERS = {\"Authorization\": f\"Bearer {CACHLY_JWT}\", \"Content-Type\": \"application/json\"}\n\nclass CachlyMemory(BaseMemory):\n    \"\"\"LlamaIndex memory backed by Cachly Brain.\"\"\"\n\n    def get(self, input: str, **kwargs) -\u003e list[TextNode]:\n        r = requests.post(\n            f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/brain/smart-recall\",\n            headers=HEADERS, json={\"query\": input, \"topK\": 5},\n        )\n        return [\n            TextNode(text=f\"[{l['topic']}] {l.get('whatWorked', '')}\")\n            for l in r.json().get(\"results\", [])\n        ]\n\n    def put(self, messages) -\u003e None:\n        for msg in messages:\n            if hasattr(msg, \"content\") and msg.content:\n                requests.post(\n                    f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/brain/learn\",\n                    headers=HEADERS,\n                    json={\"topic\": \"agent:llamaindex\", \"outcome\": \"success\", \"whatWorked\": str(msg.content)[:500]},\n                )\n\n    def reset(self) -\u003e None:\n        pass  # Persistent by design\n\n\n# Usage:\nfrom llama_index.core.chat_engine import CondensePlusContextChatEngine\n\nchat_engine = CondensePlusContextChatEngine.from_defaults(\n    index.as_retriever(),\n    memory=CachlyMemory(),\n    verbose=True,\n)\nresponse = chat_engine.chat(\"How did we fix the last deployment issue?\")\n```\n\n### Semantic Cache for LLM API Calls (Python)\n\nSkip expensive LLM calls for semantically similar prompts — no embeddings needed on your side:\n\n```python\nimport os, hashlib, requests\n\nCACHLY_URL = os.environ[\"CACHLY_URL\"]\nCACHLY_JWT = os.environ[\"CACHLY_JWT\"]\nINSTANCE_ID = os.environ[\"CACHLY_BRAIN_INSTANCE_ID\"]\nHEADERS = {\"Authorization\": f\"Bearer {CACHLY_JWT}\", \"Content-Type\": \"application/json\"}\n\ndef cached_llm_call(prompt: str, llm_fn, namespace: str = \"cachly:sem:qa\") -\u003e str:\n    \"\"\"Call LLM with semantic caching via Cachly.\"\"\"\n    # 1. Check semantic cache\n    r = requests.post(\n        f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/cache/semantic-search\",\n        headers=HEADERS,\n        json={\"query\": prompt, \"namespace\": namespace, \"threshold\": 0.85},\n    )\n    hit = r.json().get(\"hit\")\n    if hit:\n        return hit[\"value\"]  # Cache hit — no LLM call needed 🎉\n\n    # 2. Cache miss — call LLM\n    response = llm_fn(prompt)\n\n    # 3. Store in semantic cache\n    key = hashlib.sha256(prompt.encode()).hexdigest()[:16]\n    requests.post(\n        f\"{CACHLY_URL}/api/v1/instances/{INSTANCE_ID}/cache/semantic\",\n        headers=HEADERS,\n        json={\"key\": key, \"value\": response, \"namespace\": namespace, \"prompt\": prompt},\n    )\n    return response\n\n\n# Usage with any LLM:\nimport openai\nclient = openai.OpenAI()\n\ndef call_gpt(prompt: str) -\u003e str:\n    return client.chat.completions.create(\n        model=\"gpt-4o\", messages=[{\"role\": \"user\", \"content\": prompt}]\n    ).choices[0].message.content\n\nanswer = cached_llm_call(\"What is the capital of France?\", call_gpt)\n```\n\n### Environment Setup for Python Agents\n\n```bash\npip install requests python-dotenv\n\n# .env\nCACHLY_URL=https://api.cachly.dev\nCACHLY_JWT=cky_live_...          # from cachly.dev → Dashboard → API Keys\nCACHLY_BRAIN_INSTANCE_ID=...     # from cachly.dev → Dashboard → Brain\n```\n\nGet your free instance at **[cachly.dev/setup-ai](https://cachly.dev/setup-ai)** — no credit card required.\n\n---\n\n## Links\n\n- 📖 [cachly.dev docs](https://cachly.dev/docs)\n- 🧠 [AI Memory / MCP Server](https://cachly.dev/docs/ai-memory)\n- 📦 [`@cachly-dev/mcp-server`](https://www.npmjs.com/package/@cachly-dev/mcp-server) — give your AI editor persistent memory (51 MCP tools)\n- 🤖 [OpenClaw](https://openclaw.dev)\n- 📦 [npm](https://www.npmjs.com/package/@cachly-dev/openclaw)\n- 🐛 [Issues](https://github.com/cachly-dev/cachly/issues)\n\n---\n\nApache-2.0 © [cachly.dev](https://cachly.dev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcachly-dev%2Fcachly-openclaw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcachly-dev%2Fcachly-openclaw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcachly-dev%2Fcachly-openclaw/lists"}