--- title: "Basic Usage" slug: "usage" updated: 2026-04-18T19:49:26Z published: 2026-04-18T19:49:26Z canonical: "docs.xgen.ai/usage" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.xgen.ai/llms.txt > Use this file to discover all available pages before exploring further. # Basic Usage Basic Usage focuses on how to use the SDK once it’s installed. Below, find example code for importing the client, creating an instance, and calling service methods like search or recommend. More detailed API docs and copy-paste examples can be found in the [API documentation for each service](https://docs.xgen.ai/apidocs). Please also reference our [XSearch Service](/v1/docs/xsearch-services), [XRecommend Service](/v1/docs/xrecommend-service), [Tracking Service](/v1/docs/tracking) section for more examples. ```javascript import XGenClient from '@xgenai/sdk-core'; const xg = new XGenClient({        /* Customer Information */        key: '',        secret: '',        clientId: '',        trackerId: '',        /* Env Functions */        getEnv: () => 'stage', //optional: function that returns the environment (`stage` or `prod`) - This overrides the env globally        getTrackerEnv: () => 'stage', //optional: function that returns the tracker env. Can override independently        getRecommendationEnv: () => 'stage', //optional: function that returns the recommendation env. Can override independently        getSearchEnv: () => 'stage', //optional: function that returns the search env. Can override independently        /* custom Auth store */        authStore: new LocalCookieAuthStore(), //default - can pass in a custom auth store instance           /* Tracking Information */        locale: () => "", // returns the locale string for event tracking and will be used for all events.        group: () => "" // returns the current group for tracking to track AB tests }); // get recommendations by element id const result = await xg.recommend.getResultsById({elementId: ''}) // and much more... ```