GuidesUsing the SDK
Authentication
Configure API key authentication in the TypeScript SDK.
The MemNexus SDK uses API keys for authentication. Keys are passed as Bearer tokens in every request.
API key format
cmk_live_<id>.<secret>
Get your API key from memnexus.ai or create one with the CLI:
mx apikeys create --label "My App"
Configuring the client
From environment variable (recommended)
import { MemnexusClient } from "@memnexus-ai/mx-typescript-sdk";
const client = new MemnexusClient({
apiKey: process.env.MX_API_KEY,
});
From a secrets manager
import { MemnexusClient } from "@memnexus-ai/mx-typescript-sdk";
import { getSecret } from "./secrets"; // Your secrets manager
const apiKey = await getSecret("memnexus-api-key");
const client = new MemnexusClient({ apiKey });
Managing API keys programmatically
List keys
const keys = await client.apiKeys.list();
for (const key of keys.data) {
console.log(`${key.id}: ${key.label} (created ${key.createdAt})`);
}
Create a key
const newKey = await client.apiKeys.create({
label: "Production App",
expiresAt: "2027-01-01T00:00:00Z",
});
// Save this immediately — it's only shown once
console.log("New key:", newKey.apiKey);
Delete a key
await client.apiKeys.delete("key_abc123");
Security best practices
- Never hardcode API keys in source code
- Use environment variables or a secrets manager
- Set expirations on keys used for temporary access
- Use separate keys per environment and application
- Rotate keys periodically
Next steps
- Memory Operations — Create and manage memories
- Search — Find memories programmatically