# Query Submission

{% hint style="info" %}

#### Public Models for Demonstration

For providers who want to showcase their AI models and demonstrate how they operate with homomorphic encryption, LatticaAI offers the option to create a dedicated **Demo Web Page**. This page allows potential users to interact securely with the model without the need to set up a separate Query Client or define individual access tokens.

Once the demo page is created, a unique link will be provided to the AI provider. This link can be used in presentations, marketing materials, or shared directly with potential customers, making it easy to highlight the model’s capabilities and secure processing in a real-world scenario.

Providers can explore[ **LatticaAI’s demo**](https://platformdocs.lattica.ai/platform-workflows/www.lattica.ai/#demo-catalogue) as an example of how the demo page works.
{% endhint %}

## Overview

* **Query Client**:

  All end-user activities are performed via the **Query Client**, which handles secure data encryption and communication with the LatticaAI backend.
* **Access Token**:

  Each user receives a unique **Access Token** from the Computation Provider. This token is specific to the user and the computation it is associated with. The token is used for authentication and is required for all communications with LatticaAI.

{% hint style="info" %}
LatticaAI provides a Python and TypeScript SDK packages for query submission, allowing providers to implement their own user interface for end-users. It is the AI provider’s responsibility to build the UI using the provided SDK packages.
{% endhint %}

***

## Query Submission Workflow

<img src="/files/y4GCGHmcsZx8yxyw3Tls" alt="Communication phases between the Query Client and an Access Point." class="gitbook-drawing">

{% stepper %}
{% step %}

### **H**andshake

The first step in query submission is the **handshake** process.&#x20;

* The Query Client establishes a connection with the corresponding computation using the **Access Token**.
* The handshake ensures the client receives all necessary metadata related to the computation.
  {% endstep %}

{% step %}

### G**enerate Encryption Key (evk)**

Before submitting queries, the user must create a pair of encryption keys:

* **Secret Key**: Used to encrypt and decrypt messages.
* **Evaluation Key**: Sent to the LatticaAI backend to enable efficient computation.

{% hint style="info" %}
&#x20;This is a one-time setup. The same keys can be reused for all interactions with the computation.
{% endhint %}
{% endstep %}

{% step %}

### E**ncrypt the Query**

The user encrypts the query message using their **Secret Key**.
{% endstep %}

{% step %}

### S**end the Encrypted Query**

* The encrypted query and **Access Token** are transmitted to the LatticaAI backend for processing.
* LatticaAI verifies the token, processes the query, and returns the result as an encrypted message.
  {% endstep %}

{% step %}

### D**ecrypt the Result**

The user decrypts the encrypted result using their **Secret Key** to obtain the final output.
{% endstep %}
{% endstepper %}

***

{% hint style="info" %} <mark style="color:blue;">⫸</mark> Queries can only be processed when a worker is running for the associated model.

<mark style="color:blue;">⫸</mark> Computation Providers are responsible for running and monitoring workers through our console or Python SDK
{% endhint %}

***

## Quick Links to Related How-To Pages

* \[How-To: [Generate Evaluation Key](/how-to-guides/secure-query-processing/how-to-upload-evaluation-key.md)]
* \[How-To: [Encrypt Input Message](/how-to-guides/secure-query-processing/how-to-encrypt-input-message.md)]
* \[How-To: [Execute Query](/how-to-guides/secure-query-processing/how-to-execute-query.md)]
* \[How-To: [Decrypt Output data](/how-to-guides/secure-query-processing/how-to-decrypt-output-data.md)]

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platformdocs.lattica.ai/platform-workflows/query-submission.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
