Skip to main content

Lattica Query Client

The Lattica Query Client executes inference against Lattica workers. Encrypted queries encrypt the input locally, process it remotely as ciphertext, and decrypt the response locally before returning a clear tensor.

Installation

pip install lattica-query

Query API

from lattica_query import QueryClient, QueryToken

token = QueryToken("<credential>")
with QueryClient(token) as client:
    key = client.keys.ensure()
    result = client.query.encrypted(plaintext, key=key)

The client exposes three focused namespaces:

  • client.keys.ensure() loads a local key or generates and registers one. generate() always replaces the current key, while load() only reads local state and never contacts the service.
  • client.query.encrypted() performs client preprocessing, encryption, worker execution, decryption, and postprocessing. clear() executes a clear query.
  • client.encrypted_data.upload(path) uploads a custom encrypted-data artifact and asks the worker to load it.

QueryClient owns one HTTP session. Use it as a context manager or call close(); repeated calls to close() are safe. Do not execute concurrent queries through one client instance because its session and latest timing state are shared.

Credentials

QueryToken keeps the secret credential out of its representation. If you omit TokenIdentity, the client decodes the stable token ID locally from the credential; constructing a client does not make a token-information request. The optional token name is a display and storage label supplied by Studio.

Stored tokens are organized by encoded token name and ID under ~/.lattica/tokens. A name is required to save a token. Credential files use owner-only permissions.

Key storage and recovery

Keys are stored under ~/.lattica/keys/<encoded-token-id>. Each replacement is written as a complete revision and then committed atomically, so an interrupted generation leaves the previous revision usable. Operations for one token are serialized with a file lock.

The evaluation key remains on disk and is streamed during registration. It is not loaded when an already registered query key is reused. The persisted evaluation_key_uploaded state means that upload and backend registration completed; worker preprocessing may happen later if no worker was running. When an upload is interrupted, the key stays pending and the next client.keys.ensure() resumes registration from the stored file.

Timing and output

Pass show_timing=True to render client and server timing after an encrypted query:

result = client.query.encrypted(plaintext, key=key, show_timing=True)

Interactive terminals receive colored animation. Redirected output is plain text. Output can be suppressed for a block:

from lattica_query import OutputConfig, output_context

with output_context(OutputConfig(enabled=False)):
    result = client.query.encrypted(plaintext, key=key)

Configuration and errors

Production endpoints are used by default. Tests and local tools can inject an immutable per-client configuration:

from lattica_query import QueryClient, TransportConfig

config = TransportConfig(backend_url="http://localhost:3050")
with QueryClient(token, config=config) as client:
    result = client.query.encrypted(plaintext, key=key)

All client failures derive from LatticaClientError. The root package also exports the stable categories AuthenticationError, ClientVersionError, InvalidCredentialError, SerializationError, StorageError, and TransportError. More specific diagnostic exceptions live in lattica_query.errors.

See the full documentation at platformdocs.lattica.ai.

License

Proprietary - © Lattica AI. See LICENSE.md for details.

Metadata

Release files for lattica-query 2.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for lattica-query 2.9.0
File Interpreter ABI Platform Actions
lattica_query-2.9.0-py3-none-any.whl Python 3 none any Details for lattica_query-2.9.0-py3-none-any.whl

Release files / lattica_query-2.9.0-py3-none-any.whl

Download URL lattica_query-2.9.0-py3-none-any.whl
Size 48.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d34e7f5ad8cb05325889e7ea2a40ac8effce29c08603030a23521fbba15431ce
BLAKE2b-256 checksum
How to use checksums
d4d9636338f7878629beb6b889fc530e88e5b75b9c9b1aba8bf5da9ac155a747
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.12

Security for lattica-query 2.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.9.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page