Use memex-sdk when you want a typed npm client for the public Memex REST API instead of calling the endpoints manually.
memex-sdk is currently in beta. The SDK surface and API response shapes
will likely change as the Memex API evolves.
Install
What it wraps
The SDK currently wraps the public REST endpoints documented on:
Included client methods:
search
searchContent
saveContentEntity
saveContentByUrl
getAvailablePlans
getAvailableTagNames
agentCreateUser
Use saveContentEntity for new URL saves:
Use saveContentByUrl when you have a flat URL payload.
Basic usage
Search modes
The SDK follows the same search contract as the REST API:
- omit
raw or pass raw: false to get the default compact response with a results array of slim result objects
- pass
raw: true to get the richer machine-readable response
- if a wrapper asks for
llm or full, choose llm for raw: false and full for raw: true
- compact
raw=false search defaults reranking on for eligible queries
- raw
raw=true search defaults reranking off unless you set enableRerank: true
For the full shape details, including compact user_notes/media fields and raw referencesByResultId, see Response shape.
Authentication
For most SDK calls, use either:
apiKey, which the SDK sends as X-Api-Key: <apiKey>
bearerToken, which the SDK sends as Authorization: Bearer <token>
agentCreateUser is different. It requires x-agent-service-token:
Error handling
The SDK throws MemexApiError for non-2xx responses and preserves the parsed response body when possible.