How-To: Install Query Client
The query client encrypts inputs, sends them to a model and decrypts the results. This guide shows how to install it for Python or TypeScript.
Before you start
Anyone who only queries a model, such as an app or a partner, with a User Access Token from the model's owner.
If you followed Installation & Setup, the Python query client is already installed with lattica-studio. Skip the Python tab.
The client keeps your secret key on your machine. Only encrypted data is sent to Lattica.
Install the client
- Python
- TypeScript
You need Python 3.11 or newer. Install the lattica-query package:
pip install lattica-query
Check that it works:
python -c "from lattica_query import QueryClient, QueryToken; print('lattica-query is ready')"
Keep your User Access Token in an environment variable rather than in code:
export LATTICA_QUERY_TOKEN="<your-user-access-token>"
Install the @lattica-ai/query package:
npm install @lattica-ai/query
The client runs its encryption in WebAssembly, so call initWasm() once before creating a client. Check that it works:
import { initWasm, LatticaQueryClient } from '@lattica-ai/query';
await initWasm();
console.log('query client ready:', typeof LatticaQueryClient === 'function');
In a browser app, don't hard-code the token in your bundle. Load it at runtime from your own backend or the user's session.
Next
- Upload Evaluation Key: generate your keys for the model.
- Run an Encrypted Query.