Back to index

POST: Generate Chat Completions

This service offers an equivalent endpoint to OpenAI's chat completion endpoint. With the added functionality of substituting any PHI (Protected Health Information) in your messages with tokens before being sent to OpenAI. Upon receiving a response, these tokens are replaced with the original data to construct the complete response, ensuring HIPAA compliance. Note that neither your messages nor your PHI are stored on our systems.

POST: https://api.compliantchatgpt.com/v1/chat/completions

This endpoint is used to authenticate the API keys from the request header and generate a model response for the given chat conversation while ensuring HIPAA compliance.

Request Headers

  • x-compliantchatgpt-key: API key for the CompliantChatGPT service. (Required)
  • x-openai-key: API key for the OpenAI service. (Required)
  • Content-Type: The format of the request payload. Must be 'application/json'.

Request Body

  • model: ID of the model to use. Examples include "gpt-3.5-turbo", "gpt-4o-2024-05-13". Default is "gpt-3.5-turbo".
  • messages: A list of messages constituting the conversation so far. Each message in the list should be a dictionary with "role" and "content" keys. "role" can be one of "system", "user", or "assistant". (Required)
  • temperature: Sampling temperature to use, between 0 and 2. Default is 0.7.
  • n: How many chat completion choices to generate for each input message. Default is 1.
  • max_tokens: The maximum number of tokens to generate in the chat completion. (Optional)

Response

  • content: The generated completion from the model.

Error Responses

  • 400: Invalid request body or missing/invalid OpenAI API key.
  • 401: Missing or invalid CompliantChatGPT API key.
  • 429: Quota limit exceeded.
  • 500: Server error, details in the description.

Example Request

      
        import requests
        import json

        url = "https://api.compliantchatgpt.com/v1/chat/completions"

        headers = {
            'x-compliantchatgpt-key': {your_CompliantChatGPT_key},
            'x-openai-key': {your_OpenAI_key},
            'Content-Type': 'application/json'
        }

        data = {
            "model": "gpt-4o-2024-05-13",
            "messages": [
                {"role": "system", "content": "You are a helpful medical assistant." },
                {"role": "user", "content": "Patient John Doe has complained about recurring headaches for the past two weeks. "}
            ]
        }

        response = requests.post(url, headers=headers, data=json.dumps(data))

        print(response.json())
      
    

Example Response

      
        {
          "content": "Thank you for letting me know. Have they seen a doctor or received any treatment for their headaches?"
        }
      
    

This example response assumes that the model generated the assistant's reply as "Hello there, how may I assist you today?".