API reference

API Reference

The ChatMDR and ChatIVDR API is a subset of the industry-standard OpenAI API. OpenAI is the company behind ChatGPT, whose models also power ChatMDR and ChatIVDR. The elegant API that this company released so that third parties (like ChatMDR) can integrate with the ChatGPT servers is also widely supported by libraries, making integration into your own software very easy.

In what follows, we will refer to the ChatMDR API. ChatIVDR (and in future, potentially other regulation tools) can simply be accessed by choosing another Model in the request to the API

API location

The base URL of the API is https://api.chatmdr.eu for both ChatMDR and ChatIVDR.

Secret key

Access to the API is regulated with a secret key in the format sk-12345678. This key is used to track your usage and bill you at the end of each calendar month.

During the beta, access to the API is free. You can obtain a key by contacting us through the Contact form. Tokens consumed during the beta period will not be billed, even after the beta ends.

After the beta, you will be able to access your secret key through your ChatMDR account and see how many tokens your application(s) have used.

Models

The following models are available, as also shown when you execute the /models endpoint:

ModelUnderlying base modelRegulationRemarks
chatmdr-fast-openaiGPT-4o-miniMDR
chatmdr-fast-llama3_70bMeta LLama 3 70BMDRDefault model for ChatMDR app “Fast”
chatmdr-smart-openaiGPT-4oMDRDefault model for ChatMDR app “Smart”
chativdr-fast-openaiGPT-4o-miniIVDR
chativdr-fast-llama3_70bMeta LLama 3 70BIVDRDefault model for ChatIVDR app “Fast”
chativdr-smart-openaiGPT-4oIVDRDefault model for ChatIVDR app “Smart”

API endpoints

The OpenAI API has grown to become a very comprehensive API that extends beyond chat applications to image generation, text to speech and even speech to text. The ChatMDR API is a small subset of this larger interface, making it simpler to implement.

/v1/models endpoint – GET

Obtains the available models for chat completion. Please see the OpenAI Models documentation for more information on the model schema.

This endpoint does not require a secret key. It can be provided, but it will be ignored.

Python example:

import openai

# Create the client object from the OpenAI library
# Please note that the library requires an api_key for this request, 
# even if ChatMDR doesn't
client = openai.OpenAI(
    base_url = "https://api.chatmdr.eu/v1/",
    api_key = "sk-1234"                         
    )

print(client.models.list())

Sample output:

{
  "object": "list",
  "data": [
    {
      "id": "chatmdr-fast-openai",
      "object": "model",
      "created": 1686935002,
      "owned_by": "ChatMDR"
    },
    {
      "id": "chativdr-new-gpt5",
      "object": "model",
      "created": 1686935002,
      "owned_by": "ChatMDR",
    },
    {
      "id": "chatfda-mistral",
      "object": "model",
      "created": 1686935002,
      "owned_by": "ChatMDR"
    },
  ],
  "object": "list"
}

/v1/models/{model} endpoint – GET

Gets the properties of a particular model. Provides the same information as the /v1/models endpoint. Can be used to see if a model exists; does not provide any additional information.

This endpoint does not require a secret key. It can be provided, but it will be ignored.

curl example:

curl https://api.chatmdr.eu/v1/models/chatmdr-smart-openai

Sample output

{
    "id":"chatmdr-smart-openai",
    "created":0,
    "owned_by":"ChatMDR",
    "object":"model"
}

/v1/chat/completions endpoint – POST

This is the endpoint that actually sends input to and receives input from ChatMDR or ChatIVDR. It implements the endpoint of the same name in the OpenAI API endpoint of the same name, but with some simplifications:

  • messages
    If you provide a system prompt, it has to be the first message. It will be added to ChatMDR’s own system prompt, which you cannot override.
    The optional “name” parameter of each message is ignored.
  • model
    Has to be the id of one of the models obtained from the /v1/models endpoint
  • max_tokens
    The maximum number of output tokens emitted by the model. Must be at least 100 and maximum 4,096
  • temperature
    Level of creativity of the model. Has to be between 0.0 and 1.0 as a floating-point number, with 1.0 the most random and 0.0 the most deterministic.
  • All other options are ignored, whether they are part of the original OpenAI specification (e.g. top_p) or not (e.g. foobar)

Node.js example:

const { OpenAI } = require("openai");

// Initialize OpenAI to point to ChatMDR
const openai = new OpenAI({
    baseURL: "https://api.chatmdr.eu/v1/",
    apiKey: "sk-1234"                        // Fill out real key or (better) store in OPENAI_API_KEY env variable
});

async function main() {
  const completion = await openai.chat.completions.create({
    messages: [
        { role: "system", content: "You are a helpful MDR assistant and you speak French only." },
        { role: "user", content: "Which device classes exist?" }
    ],
    model: "chatmdr-smart-openai",
  });

  console.log(completion.choices[0].message.content);
}

main();

Sample output. Please note that ChatMDR responds in French because of the system prompt in the example code above. The default language, of course, is English.

{
    "object": "chat.completion",
    "id": "72ce862d-bc19-4f18-882e-14561b71dea8",
    "model": "chatmdr-smart-openai",
    "created": 1724330118.606,
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "Les dispositifs médicaux sont classés en quatre classes selon le Règlement sur les dispositifs médicaux (MDR) : classe I, classe IIa, classe IIb et classe III. La classification dépend de la finalité prévue des dispositifs et de leurs risques inhérents (Article 51 du MDR). Voici un aperçu des classes :\\n\\n1. **Classe I** : Dispositifs présentant un faible risque. Ils incluent souvent des dispositifs non invasifs ou des dispositifs invasifs à usage transitoire.\\n\\n2. **Classe IIa** : Dispositifs présentant un risque modéré. Ils incluent des dispositifs non invasifs destinés à canaliser ou stocker des liquides corporels, ou des dispositifs invasifs à usage à court terme.\\n\\n3. **Classe IIb** : Dispositifs présentant un risque plus élevé. Ils incluent des dispositifs non invasifs modifiant la composition biologique ou chimique des tissus humains, ou des dispositifs invasifs à usage à long terme.\\n\\n4. **Classe III** : Dispositifs présentant le risque le plus élevé. Ils incluent des dispositifs implantables ou des dispositifs invasifs chirurgicaux destinés à un usage à long terme, ou des dispositifs non invasifs utilisés en contact direct avec des cellules humaines in vitro.\\n\\nLa classification est effectuée conformément à l'Annexe VIII du MDR."
            }
        }
    ],
    "usage": {
        "prompt_tokens": 4832,
        "completion_tokens": 274,
        "total_tokens": 5106
    }
}

Libraries

You can use the many OpenAI libraries available, or implement your own REST client by submitting the appropriate JSON messages and decoding the responses.

A comprehensive list of libraries to connect to OpenAI APIs including ChatMDR can be found on the OpenAI library page. This includes open source alternatives to some of the OpenAI libraries listed above.