Installation
Initialize the client
The SDK uses a Bearer token for authentication. Obtain an access token by exchanging your SDK credentials and pass it when creating the client:Configuration options
Get recommendations
id, object, item_id, rank, score, and an embedded item object with the metadata you stored. The response also includes a request_id for event attribution.
Search
Usesearch when the user supplies a free-text query and you want ranked catalog items back through the Core API data plane:
https://api.neuronsearchlab.com/v1/search, not the console Platform API. Search responses use the same item shape as recommendations and include query, request_id, data, and recommendations.
Auto-generated sections
UsegetAutoRecommendations for paginated, auto-titled recommendation sections:
Track events
Events provide the feedback loop that powers personalization. The PHP SDK buffers events in memory for the lifetime of the current process.How batching works in PHP
1
Buffer events
Events are buffered with a timestamp that maps to
occurred_at in the API.2
Flush at max batch size
The buffer flushes when it reaches
maxBatchSize.3
Force delivery when needed
You can force delivery with
flushEvents() or by calling ->wait() on the returned PendingResult.4
Flush during shutdown
Remaining buffered events are flushed during PHP shutdown.
5
Retry failed sends
Failed sends are retried with exponential backoff.
Request ID propagation
WhenpropagateRecommendationRequestId is enabled, the SDK captures the request_id from getRecommendations() or search() and automatically attaches it to subsequent trackEvent() calls unless you explicitly provide requestId or request_id.
Manage catalog items
Create an item
Update an item
Delete items
Error handling
The SDK exposesSDKHttpError and SDKTimeoutError:
Logging
Configure structured logging for debugging and observability:TRACE, DEBUG, INFO, WARN, ERROR, FATAL.
Session management
The SDK auto-generates a session UUID on initialization whenautoSessionId is enabled. You can override or read it:

