repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | title: Keywords AI |
| #3 | --- |
| #4 | |
| #5 | Build AI applications with persistent memory and comprehensive LLM observability by integrating Mem0 with Keywords AI. |
| #6 | |
| #7 | ## Overview |
| #8 | |
| #9 | Mem0 is a self-improving memory layer for LLM applications, enabling personalized AI experiences that save costs and delight users. Keywords AI provides complete LLM observability. |
| #10 | |
| #11 | Combining Mem0 with Keywords AI allows you to: |
| #12 | 1. Add persistent memory to your AI applications |
| #13 | 2. Track interactions across sessions |
| #14 | 3. Monitor memory usage and retrieval with Keywords AI observability |
| #15 | 4. Optimize token usage and reduce costs |
| #16 | |
| #17 | <Note> |
| #18 | You can get your Mem0 API key, user_id, and org_id from the [Mem0 dashboard](https://app.mem0.ai/). These are required for proper integration. |
| #19 | </Note> |
| #20 | |
| #21 | ## Setup and Configuration |
| #22 | |
| #23 | Install the necessary libraries: |
| #24 | |
| #25 | ```bash |
| #26 | pip install mem0 keywordsai-sdk |
| #27 | ``` |
| #28 | |
| #29 | Set up your environment variables: |
| #30 | |
| #31 | ```python |
| #32 | import os |
| #33 | |
| #34 | # Set your API keys |
| #35 | os.environ["MEM0_API_KEY"] = "your-mem0-api-key" |
| #36 | os.environ["KEYWORDSAI_API_KEY"] = "your-keywords-api-key" |
| #37 | os.environ["KEYWORDSAI_BASE_URL"] = "https://api.keywordsai.co/api/" |
| #38 | ``` |
| #39 | |
| #40 | ## Basic Integration Example |
| #41 | |
| #42 | Here's a simple example of using Mem0 with Keywords AI: |
| #43 | |
| #44 | ```python |
| #45 | from mem0 import Memory |
| #46 | import os |
| #47 | |
| #48 | # Configuration |
| #49 | api_key = os.getenv("MEM0_API_KEY") |
| #50 | keywordsai_api_key = os.getenv("KEYWORDSAI_API_KEY") |
| #51 | base_url = os.getenv("KEYWORDSAI_BASE_URL") # "https://api.keywordsai.co/api/" |
| #52 | |
| #53 | # Set up Mem0 with Keywords AI as the LLM provider |
| #54 | config = { |
| #55 | "llm": { |
| #56 | "provider": "openai", |
| #57 | "config": { |
| #58 | "model": "gpt-4.1-nano-2025-04-14", |
| #59 | "temperature": 0.0, |
| #60 | "api_key": keywordsai_api_key, |
| #61 | "openai_base_url": base_url, |
| #62 | }, |
| #63 | } |
| #64 | } |
| #65 | |
| #66 | # Initialize Memory |
| #67 | memory = Memory.from_config(config_dict=config) |
| #68 | |
| #69 | # Add a memory |
| #70 | result = memory.add( |
| #71 | "I like to take long walks on weekends.", |
| #72 | user_id="alice", |
| #73 | metadata={"category": "hobbies"}, |
| #74 | ) |
| #75 | |
| #76 | print(result) |
| #77 | ``` |
| #78 | |
| #79 | ## Advanced Integration with OpenAI SDK |
| #80 | |
| #81 | For more advanced use cases, you can integrate Keywords AI with Mem0 through the OpenAI SDK: |
| #82 | |
| #83 | ```python |
| #84 | from openai import OpenAI |
| #85 | import os |
| #86 | import json |
| #87 | |
| #88 | # Initialize client |
| #89 | client = OpenAI( |
| #90 | api_key=os.environ.get("KEYWORDSAI_API_KEY"), |
| #91 | base_url=os.environ.get("KEYWORDSAI_BASE_URL"), |
| #92 | ) |
| #93 | |
| #94 | # Sample conversation messages |
| #95 | messages = [ |
| #96 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #97 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #98 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #99 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #100 | ] |
| #101 | |
| #102 | # Add memory and generate a response |
| #103 | response = client.chat.completions.create( |
| #104 | model="openai/gpt-4.1-nano", |
| #105 | messages=messages, |
| #106 | extra_body={ |
| #107 | "mem0_params": { |
| #108 | "user_id": "test_user", |
| #109 | "org_id": "org_1", |
| #110 | "api_key": os.environ.get("MEM0_API_KEY"), |
| #111 | "add_memories": { |
| #112 | "messages": messages, |
| #113 | }, |
| #114 | } |
| #115 | }, |
| #116 | ) |
| #117 | |
| #118 | print(json.dumps(response.model_dump(), indent=4)) |
| #119 | ``` |
| #120 | |
| #121 | For detailed information on this integration, refer to the official [Keywords AI Mem0 integration documentation](https://docs.keywordsai.co/integration/development-frameworks/mem0). |
| #122 | |
| #123 | ## Key Features |
| #124 | |
| #125 | 1. **Memory Integration**: Store and retrieve relevant information from past interactions |
| #126 | 2. **LLM Observability**: Track memory usage and retrieval patterns with Keywords AI |
| #127 | 3. **Session Persistence**: Maintain context across multiple user sessions |
| #128 | 4. **Cost Optimization**: Reduce token usage through efficient memory retrieval |
| #129 | |
| #130 | ## Conclusion |
| #131 | |
| #132 | Integrating Mem0 with Keywords AI provides a powerful combination for building AI applications with persistent memory and comprehensive observability. This integration enables more personalized user experiences while providing insights into your application's memory usage. |
| #133 | |
| #134 | <CardGroup cols={2}> |
| #135 | <Card title="OpenAI Agents SDK" icon="cube" href="/integrations/openai-agents-sdk"> |
| #136 | Build monitored agents with OpenAI SDK |
| #137 | </Card> |
| #138 | <Card title="AgentOps Integration" icon="chart-line" href="/integrations/agentops"> |
| #139 | Monitor agent performance with AgentOps |
| #140 | </Card> |
| #141 | </CardGroup> |
| #142 | |
| #143 |