Deploy an encrypted large language model (LLM) on the Platform for AI (PAI) Elastic Algorithm Service (EAS) secure encryption environment and send it inference requests. The model is encrypted before upload. At deployment, the remote attestation service (Trustee) verifies the runtime environment and then releases the decryption key, which the instance uses to decrypt and mount the model. Trusted Network Gateway (TNG) can transparently encrypt inference traffic. These layers of protection keep data and models secure throughout their lifecycle, which fits workloads that handle sensitive data, such as financial services, government, and enterprise applications.
Background
PAI-CC (PAI Confidential Computing) is a PAI-EAS inference service for confidential computing workloads. It builds on a standard EAS inference service and protects model inference end-to-end in the following ways:
CPU TEE (CPU-based confidential computing): The inference process runs in a trust domain that Intel TDX (Intel Trust Domain Extensions) isolates at the hardware level. On the CPU side, model loading, tokenization, scheduling, and the KV cache all stay inside the enclave, so neither the host nor the cloud platform can read plaintext data.
GPU TEE (GPU-based confidential computing): The GPU becomes part of the trusted execution environment (TEE). The TEE protects the model weights as they move from the CPU to the GPU. Inside the GPU, the TEE also protects the attention computation, the matrix multiplication, and the KV cache. The CPU-GPU interconnect is encrypted.
Encrypted model storage: The model is encrypted with gocryptfs (AES-256-GCM) and stored in Object Storage Service (OSS), and it is transferred to the instance as ciphertext. Trustee injects the decryption key into the TEE only after remote attestation succeeds. The key then decrypts and mounts the model. The key is never written to disk and never leaves the TEE.
Remote attestation: Before deployment and before inference starts, the Trustee service verifies the TEE hardware signature, firmware measurements, and runtime environment configuration of the instance. The model decryption key is released only after verification succeeds.
Model integrity measurement (verity): Optional. This capability generates a Merkle tree root hash for the model files and verifies it at deployment, which confirms that the loaded model matches the model you expect. Any weight-level change is detected and reported as an anomaly, so the model cannot be tampered with or replaced at runtime. Detection also covers hidden backdoors that change only a few weights and that routine spot checks miss.
Encrypted inference communication (TNG gateway protection): Optional. TNG transparently encrypts requests and responses between the client and the inference service, which protects inference data end-to-end. Keys are negotiated during the remote attestation handshake, and each inference request uses a unique key. This prevents eavesdropping and tampering in transit.
Install the pai-cc-tools client
pai-cc-tools provides commands to measure, encrypt, and upload models and to send secure inference requests. Install the client before you proceed:
curl -fsSL https://conf-ai.oss-cn-beijing.aliyuncs.com/pai-cc/pai-cc-tools-20261026-399ab05.tar.gz | tar -xz -C /opt && ln -sf /opt/pai-cc-tools/pai-cc /usr/local/bin/pai-cc
The pai-cc command is then available.
Step 1: Prepare the encrypted model
This step has three parts: measure the model (optional), encrypt it, and upload it. Because model files are large, this process can take a long time.
To try this workflow quickly, use the pre-encrypted model file listed below. You can then skip the measurement, encryption, and upload parts of this step and go directly to Step 2: Set up the Trustee remote attestation service.
You can use the integrity reference value from the table above as the reference value in the remote attestation policy in Step 2. The policy then uses this value to verify the model that the deployment instance loads. To use your own model, complete the following parts. The following steps use the Qwen3.8-27B model as an example.
1. Measure the model (optional)
Model measurement generates an integrity reference value for the model directory. The deployment instance uses this value to verify that the loaded model and the runtime checkpoint have not been tampered with. If you need to verify the model that the instance loads from a remote source and protect the runtime checkpoint from tampering, complete this part. Measure the model before you encrypt it.
# Pull the model online from ModelScope, or use a local directory
DIR=$(pai-cc model measure --modelscope Qwen/Qwen3.8-27B --hash-output /tmp/qwen-root.hash)
echo "Path of the measured model: ${DIR}"
The integrity reference value is written to the file specified by
--hash-output. Record this value. You can use it later as the remote attestation reference value.The metadata also records the model ID. For a ModelScope source, the model name is used as the model ID by default. For a local directory source, specify the model ID manually with
--model-id.
2. Encrypt the model
PAI-EAS encrypted inference uses gocryptfs, an AES-256-GCM-based encryption mode that follows the open-source gocryptfs standard.
pai-cc model encrypt encrypts the model. These examples use the user-provided key 0Bn4Q1wwY9fN3P throughout.
-
(Optional) To encrypt the measured model:
CIPHER=$(pai-cc model encrypt --model "$DIR" --method gocryptfs --key 0Bn4Q1wwY9fN3P) echo "Path of the measured and encrypted model: ${CIPHER}" -
To encrypt the model without measuring it first:
CIPHER=$(pai-cc model encrypt --modelscope Qwen/Qwen3.8-27B --method gocryptfs --key 0Bn4Q1wwY9fN3P) echo "Path of the encrypted model: ${CIPHER}"
3. Upload the model
Upload the ciphertext directory to an OSS bucket in the same region as the deployment instance. pai-cc model upload uses ossutil to upload the encrypted files without preserving the directory structure, and then verifies the file count.
URI=$(pai-cc model upload --cipher "$CIPHER" --bucket <your-bucket> --prefix qwen3.8-27b-gocryptfs)
The command prints the
oss://<your-bucket>/qwen3.8-27b-gocryptfs/URI to stdout. The Storage Mounts configuration in Step 3 uses this path.
Step 2: Set up the Trustee remote attestation service
The remote attestation service is under your control. It verifies the runtime environment where the model and the inference service run. Only when the deployment environment meets your trust requirements does Trustee inject the model decryption key, which then decrypts and mounts the model. In this topic, Trustee runs on an Alibaba Cloud Elastic Compute Service (ECS) instance.
-
Prepare a standard ECS instance with a public IP address and Alibaba Cloud Linux 3.2104 LTS 64-bit as the operating system. Run the remaining steps on this instance.
When your security requirements are extremely strict, deploy Trustee in your on-premises data center or on an on-premises server, and connect it to your VPC in the cloud through an Express Connect circuit or a VPN. This keeps the root of trust fully under your control.
-
Log on to the instance and install Trustee from the YUM repository:
yum install -y trustee-1.10.0Trustee starts automatically and listens on port 8081 by default. The endpoint is
http://<trustee-ip>:8081/api. In production environments, configure HTTPS for Trustee. -
Import the model decryption key into Trustee. As in Step 1, these examples use the user-provided key
0Bn4Q1wwY9fN3P. When you write the key, useecho -nto omit the trailing newline so that the value matches the encryption key byte for byte:sudo mkdir -p /opt/trustee/kbs/repository/default/aliyun/ sudo sh -c 'echo -n "0Bn4Q1wwY9fN3P" > /opt/trustee/kbs/repository/default/aliyun/model-decryption-key'Trustee then assigns the Key Broker Service (KBS) URI
kbs:///default/aliyun/model-decryption-keyto this key. This is the value ofdecryption_keyin the Step 3 configuration. -
Configure the remote attestation policy. The policy file is located at
/opt/trustee/attestation-service/policies/opa/default.rego. Trustee checks each instance of the PAI-CC service and decides whether to release the key. -
Restart Trustee:
sudo systemctl restart trustee
Step 3: Create the PAI-CC service
Create a Lingjun AI Computing resource group and purchase nodes. Follow Create a resource group and purchase Lingjun resources to create the resource group in the China (Beijing) region and purchase
ml.gu8tef.8.46xlarge.ccinstances. This instance type is in invitational preview. Contact your Alibaba Cloud account manager to request access.Create a VPC in the China (Beijing) region, create a vSwitch in the beijing-i zone, and then create a security group in the VPC. Later steps deploy the PAI-CC confidential inference containers in this VPC. Configure SNAT on an Internet NAT gateway for the VPC and associate an elastic IP address (EIP). The instances then reach the Internet to pull the model ciphertext and connect to Trustee. For more information, see Internet NAT gateway.
Allow the PAI-CC instances to reach the Trustee instance over the Internet. On the ECS instance that runs Trustee, add an inbound security group rule that allows traffic on port 8081 (Custom TCP). Set the authorization object to the public SNAT egress IP address of the VPC that you configured in the previous step.
Create a resource quota. Follow Create a resource quota and configure the following settings: Set Source Type to Lingjun AI Computing resource group, and then select the resource group, nodes, and instance type that you created. Set VPC to the VPC that you created. Set Associated Workspace to a PAI workspace. The resource quota is allocated to that workspace. If you have not created a workspace, follow Create and manage workspaces to create one.
Log on to the PAI console, select your region at the top of the page and your workspace on the right. Click Enter Elastic Algorithm Service (EAS). On the Inference Service tab, click Deploy Service. In the Custom Model Deployment section, click Custom Deployment.
-
Configure the following key parameters. For descriptions of the other parameters, see Custom deployment.
Parameter
Description
Resource Information
Resource Type
Select Resource Quota, and then select the Lingjun AI Computing resource quota that you created in the previous step.
Deployment Resources
Set GPU (Number of GPUs) to
1, CPU (Number of Cores) to20, and Memory (GB) to200. Adjust these values based on the selected model and your deployment method.Number of Instances
Set Number of Instances to
8. Adjust this value based on Deployment Resources.Environment Information
Deployment Method
Select Image-based Deployment.
Image Configuration
Select an image. In this example, select Official Image > vllm 0.25.0-gpu.
Storage Mounts
Select OSS. Set Uri to
oss://conf-ai/qwen3.8-27b-gocryptfs/, the ciphertext path that you uploaded in Step 1. Set Mount Path to/mnt/model/. Mount the storage as read-only.Command to Run
vllm serve /mnt/model/ --host 0.0.0.0 --port 8000 --served-model-name "Qwen3.8-27B". The model path/mnt/model/must be the same as the OSS Mount Path above.Port Number
8000.
Network Information
VPC
Select the VPC and vSwitch that you created.
Security Group
Select the security group that you created.
Service Features
GPU Driver Version
Set GPU Driver Version to
570.148.08-open. If you cannot select this field, edit the JSON configuration directly.Confidential computing distinguishes PAI-CC from a standard EAS service. When you create a PAI-CC service, turn on Configure Secure Encryption Environment and set the following options. After you turn on this option, the inference service runs in a confidential computing environment protected by both the CPU TEE and the GPU TEE. During inference, the model weights, the KV cache, and all intermediate computations stay inside the TEE, and no plaintext is exposed to the host. The model is decrypted and mounted at deployment only after remote attestation succeeds, and inference traffic is encrypted through TNG.

Configuration item
Value
File Encryption Method
gocryptfs (the same value as
--methodin Step 1)Enable Confidential Computing Environment
Enabled
Runtime Data Encryption
Enabled
TNG Gateway Protection
Enabled (inference traffic is encrypted through TNG)
Model Measurement
Enabled (if you measured the model in Step 1)
Trustee Endpoint
http://<trustee-ip>:8081/api(the endpoint of the Trustee service that you deployed)KBS URI of the decryption key
kbs:///default/aliyun/model-decryption-keyThe following example shows the resulting JSON configuration:
After you configure the parameters, click Deploy. When Service Status changes to Running, the service is deployed.
Step 4: Run secure inference
Traffic between your application and the inference service is encrypted through TNG. Inference runs in a confidential computing environment based on Intel TDX and the GPU TEE. Requests and responses, including streaming responses, are encrypted in transit.
Your application sends inference requests through a TNG client. Choose the access method that fits your use case:
|
Access method |
How to get it |
|
Proxy gateway (HTTP proxy / SOCKS5 proxy / transparent proxy) |
Download the binary or container image from the GitHub repository. For documentation and examples, see TNG configuration (Chinese). |
|
Python SDK |
|
|
Go SDK |
|
|
JavaScript SDK |
|
To keep the examples short, pai-cc-tools provides commands for these TNG calls.
1. View the service endpoint
On the Inference Service tab, click the name of your service to open the Overview page. In the Basic Information section, click View Call Information.

Record the service endpoint and token for the pai-cc secure command that you run later.
2. Run a single secure inference request
pai-cc secure run automatically downloads and configures the required TNG components. The gateway transparently encrypts every inference request that you send with curl:
Without model measurement
pai-cc secure run -- \
curl -sS -X POST http://<service-url>/v1/chat/completions \
-H "Authorization: <your-token>" -H "Content-Type: application/json" \
-d '{"model":"Qwen3.8-27B","messages":[{"role":"user","content":"Hello"}],"max_tokens":100,"stream":false}'
With model measurement
Before inference runs, pai-cc secure run verifies the model that the deployment instance loaded. If verification fails, the request is rejected locally and the inference prompt is never sent.
--model-idand--model-hashcorrespond to the Model ID and Integrity reference value columns in the Step 1 table.pai-cc model measureproduces both values.
pai-cc secure run --model-id Qwen/Qwen3.8-27B --model-hash <integrity-reference-value> -- \
curl -sS -X POST http://<service-url>/v1/chat/completions \
-H "Authorization: <your-token>" -H "Content-Type: application/json" \
-d '{"model":"Qwen3.8-27B","messages":[{"role":"user","content":"Hello"}],"max_tokens":100,"stream":false}'
Everything after -- is your original curl command, unchanged. You can replace curl with any other program. The verification still runs. The command output looks like this:
{"id":"chatcmpl-b1df6ef135765608","object":"chat.completion","created":1790173748,"model":"Qwen3.8-27B","choices":[{"index":0,"message":{"role":"assistant","content":"The user said \"Hello\" - a simple greeting. I should respond warmly and concisely, offering to help.\n```\n\n\nHello! How can I help you today?","refusal":null,"annotations":null,"audio":null,"function_call":null,"reasoning":null},"logprobs":null,"finish_reason":"stop","stop_reason":null,"token_ids":null,"routed_experts":null}],"service_tier":null,"system_fingerprint":"vllm-0.25.0-fb7f4d0a","usage":{"prompt_tokens":53,"total_tokens":90,"completion_tokens":37,"prompt_tokens_details":null},"prompt_logprobs":null,"prompt_token_ids":null,"prompt_text":null,"kv_transfer_params":null,"metrics":null}
3. Verify SDK compatibility
Run the following command to verify that this inference service works with all TNG client access methods: proxy mode, process injection (tng exec), the Python SDK, the Go SDK, and the JavaScript SDK.
pai-cc secure test \
--endpoint http://<service-url>/v1/chat/completions \
--token <your-token> --builtin-as -m all
── tng-launch ──────────────────────────────────
PASS tng-launch
── tng-exec ──────────────────────────────────
PASS tng-exec
── python-sdk ──────────────────────────────────
PASS python-sdk
── go-sdk ──────────────────────────────────
PASS go-sdk
── js-sdk ──────────────────────────────────
PASS js-sdk
summary: 5 passed, 0 failed, 0 skipped