Skip to content

Instantly share code, notes, and snippets.

@h4x3rotab
Last active February 24, 2025 22:26
Show Gist options
  • Save h4x3rotab/92c850722b7d44ac76e0abecedfcb759 to your computer and use it in GitHub Desktop.
Save h4x3rotab/92c850722b7d44ac76e0abecedfcb759 to your computer and use it in GitHub Desktop.
Phala verifiable inference on RedPill

Step 1. Get an API key on red-pill.ai

Step 2. Query (using phala/deepseek-r1-70b as example here)

curl -X 'POST' \
  'https://api.red-pill.ai/v1/chat/completions' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <redpill-key>' \
  -d '{
  "messages": [
    {
      "content": "You are a helpful assistant.",
      "role": "system"
    },
    {
      "content": "What is your model name?",
      "role": "user"
    }
  ],
  "stream": true,
  "model": "phala/deepseek-r1-70b"
}'

Sample output:

data: {"id":"chatcmpl-4af943a924c8414facd482d159ba99e7","object":"chat.completion.chunk","created":1738970726,"model":"deepseek-r1-70b/deepseek-r1-70b","choices":[{"index":0,"delta":{"content":""},"logprobs":null,"finish_reason":"stop","stop_reason":128001}]}
data: [DONE]

Available verifiable inference models:

Step 3. Get both CPU and GPU Remote Attestation quotes

curl 'https://api.red-pill.ai/v1/attestation/report?model=phala/deepseek-r1-70b' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <redpill-key>' | jq

Sample output:

{
  "signing_address": "0x2371C9D132D257d62EB7131AacAeAd189Cff43Dd",
  "intel_quote": "...",
  "nvidia_payload": "..."
}

Step 4. Get the signed inference results. You can get CHAT_ID from a query result. All the chats will be cached for 5 minutes for you to retrive the signatre.

CHAT_ID=chatcmpl-4af9...
curl "https://api.red-pill.ai/v1/signature/${CHAT_ID}?model=phala/deepseek-r1-70b&signing_algo=ecdsa" \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <redpill-key>' | jq

Sample output:

{
  "text": "e5542b0757e0b9d05bfa4a15da7bac97a03bd35d21b648ec492152708e795ff9:4687c2bfe9ea1b7dfded85de3e737a59de464b987ba43e9a2dd41be5f680d517",
  "signature": "95afa6cd5ccf05d85628821d9cdbeaed4107d78ff4063362f152d936f5c3b9825d5a933aa4dd9589675ac2fcf6a4e2094b793c016c84261fe4f07dd7395bf65e1b",
  "signing_algo": "ecdsa"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment