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: Anthropic |
| #3 | --- |
| #4 | |
| #5 | |
| #6 | To use Anthropic's models, please set the `ANTHROPIC_API_KEY` which you find on their [Account Settings Page](https://console.anthropic.com/account/keys). |
| #7 | |
| #8 | ## Usage |
| #9 | |
| #10 | <CodeGroup> |
| #11 | ```python Python |
| #12 | import os |
| #13 | from mem0 import Memory |
| #14 | |
| #15 | os.environ["OPENAI_API_KEY"] = "your-api-key" # used for embedding model |
| #16 | os.environ["ANTHROPIC_API_KEY"] = "your-api-key" |
| #17 | |
| #18 | config = { |
| #19 | "llm": { |
| #20 | "provider": "anthropic", |
| #21 | "config": { |
| #22 | "model": "claude-sonnet-4-20250514", |
| #23 | "temperature": 0.1, |
| #24 | "max_tokens": 2000, |
| #25 | } |
| #26 | } |
| #27 | } |
| #28 | |
| #29 | m = Memory.from_config(config) |
| #30 | messages = [ |
| #31 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #32 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #33 | {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, |
| #34 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #35 | ] |
| #36 | m.add(messages, user_id="alice", metadata={"category": "movies"}) |
| #37 | ``` |
| #38 | |
| #39 | ```typescript TypeScript |
| #40 | import { Memory } from 'mem0ai/oss'; |
| #41 | |
| #42 | const config = { |
| #43 | llm: { |
| #44 | provider: 'anthropic', |
| #45 | config: { |
| #46 | apiKey: process.env.ANTHROPIC_API_KEY || '', |
| #47 | model: 'claude-sonnet-4-20250514', |
| #48 | temperature: 0.1, |
| #49 | maxTokens: 2000, |
| #50 | }, |
| #51 | }, |
| #52 | }; |
| #53 | |
| #54 | const memory = new Memory(config); |
| #55 | const messages = [ |
| #56 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #57 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #58 | {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, |
| #59 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #60 | ] |
| #61 | await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); |
| #62 | ``` |
| #63 | </CodeGroup> |
| #64 | |
| #65 | ## Config |
| #66 | |
| #67 | All available parameters for the `anthropic` config are present in [Master List of All Params in Config](../config). |