Note: QuantmLayer APIs are designed for compliance-aligned deployments with end-to-end encryption and audit logging. While we support HIPAA, SOX, and GDPR modes, we are not currently certified under any compliance framework.
POST/v1/chat/completions

Chat Completions

Create encrypted chat completions using GPT-4, GPT-3.5 Turbo, or Mistral models. Your data is encrypted end-to-end and never stored.

🔐 Security Features

  • • End-to-end quantum-safe encryption
  • • Zero data retention - immediate deletion after processing
  • • Complete audit trails for compliance
  • • HIPAA, SOX, and GDPR compliance modes

Parameters

modelstringrequired

AI model to use

Example: "gpt-4"
Options: gpt-4, gpt-4-turbo, gpt-3.5-turbo, mistral-7b, mistral-medium
messagesarrayrequired

Array of message objects

Example: [{"role": "user", "content": "Hello"}]
encryptionstring

Encryption algorithm to use

Example: "kyber512"
Options: kyber512, rsa4096, auto
Default: kyber512
temperaturenumber

Sampling temperature (0-2)

Example: 0.7
Default: 1.0
max_tokensinteger

Maximum tokens in response

Example: 1000
Default: Varies by model
compliance_modestring

Compliance framework to align behavior with (not certified)

Example: "hipaa"
Options: hipaa, sox, gdpr, standard
Default: standard (non-certified)

Request Examples

cURL

curl -X POST https://api.quantmlayer.com/v1/chat/completions \
  -H "Authorization: Bearer ql_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful medical assistant."
      },
      {
        "role": "user", 
        "content": "Analyze this patient data for potential risks..."
      }
    ],
    "encryption": "kyber512",
    "temperature": 0.7,
    "max_tokens": 1000,
    "compliance_mode": "hipaa"
  }'

Python

from quantmlayer import SecureGPT

client = SecureGPT(api_key="ql_your_api_key")

response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Analyze this sensitive data..."}
    ],
    encryption="kyber512",
    temperature=0.7,
    compliance_mode="hipaa"
)

print(response.choices[0].message.content)

Response

{
  "id": "qmchatcmpl-7QyqpwdfhqwajicIEznoc6Q47XAyW",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4",
  "usage": {
    "prompt_tokens": 56,
    "completion_tokens": 31,
    "total_tokens": 87
  },
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Based on the encrypted analysis..."
      },
      "finish_reason": "stop",
      "index": 0
    }
  ],
  "encryption": {
    "algorithm": "kyber512",
    "overhead_ms": 47,
    "key_id": "key_abc123"
  },
  "compliance": {
    "mode": "hipaa-aligned",
    "audit_id": "audit_def456",
    "retention_policy": "immediate_deletion"
  }
}

Response Fields

choices

Array of completion choices. Each choice contains the AI's response message.

usage

Token usage information including prompt tokens, completion tokens, and total.

encryption

Encryption metadata including algorithm used, overhead time, and key identifier.

compliance

Compliance information including mode, audit ID, and retention policy confirmation.

Error Codes

400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
429Rate Limited - Too many requests
500Server Error - Internal server error

Ready to Try It?

Test our API in the interactive playground or start building with a free trial.