# Decision API The **Decision** API answers typed questions about a text, with calibrated probabilities. ## Introduction A decision model reads a **state** (a message, an e-mail, a ticket, a JSON document...) and a set of **questions**, and returns for each question a typed answer together with the probability of every possible outcome. Unlike a chat model, it does not generate text: it reads the state once and gives a structured, reproducible answer, which makes it a good fit for routing, triage, moderation or any step of an agent that has to decide how to act. clef-flash takes **text only**. There are three types of questions: - **`choice`**: pick one option. `criteria` is an object of `option: description` (the description may be `null`), with 2 to 255 options. The answer gives the chosen option and the probability of each option. `instructions` states what is asked and is recommended. - **`score`**: rate on ordered levels. `criteria` is the list of the level labels, from lowest to highest (2 to 10 levels). The answer gives the expected level (0-indexed, so it can be fractional) and the probability of each level. `instructions` states what is asked and is recommended. - **`noul`**: a yes / no question, only `instructions` is needed. The answer is the probability of yes. Several questions can be asked in a single request: the state is read once. The order matters: the model labels the options A, B, C... and the levels 0, 1, 2... in the order received, so keep the order of the questions, options and levels stable. The API follows the *System One* format introduced by TypeSafe, so its clients only need a new base URL. ## How to? ### With a simple HTTP client (requests) First install the *requests* library: ```bash pip install requests ``` Next, export your access token to the *OVH_AI_ENDPOINTS_ACCESS_TOKEN* environment variable: ```bash export OVH_AI_ENDPOINTS_ACCESS_TOKEN= ``` *If you do not have an access token key yet, follow the instructions in the [AI Endpoints – Getting Started](https://help.ovhcloud.com/csm/en-gb-public-cloud-ai-endpoints-getting-started?id=kb_article_view&sysparm_article=KB0065401).* Finally, run the following Python code: ```python import os import requests url = "https://oai.endpoints.kepler.ai.cloud.ovh.net/api/v1/systemone" headers = { "Authorization": f"Bearer {os.getenv('OVH_AI_ENDPOINTS_ACCESS_TOKEN')}", "Content-Type": "application/json" } payload = { "model": "clef-flash", "state": "Hi, I just deployed my first Public Cloud instance and I would like to enable automatic backups before launching my website next week. How can I set this up, and what does it cost?", "questions": { "department": { "type": "choice", "criteria": { "billing": "Invoice, payment or subscription issues", "technical": "Outages, bugs or infrastructure problems", "sales": "Pricing, offers or account questions" } }, "frustration": { "type": "score", "criteria": [ "Calm, just stating facts", "Frustrated but civil", "Very angry, strong language" ] }, "is_urgent": { "type": "noul", "instructions": "The message conveys urgency or time-sensitivity" } } } response = requests.post(url, json=payload, headers=headers) if response.status_code == 200: for question, answer in response.json()["answers"].items(): print(question, answer) else: print("Error:", response.status_code, response.text) ``` ### With cURL ```bash curl https://oai.endpoints.kepler.ai.cloud.ovh.net/api/v1/systemone \ -H "Authorization: Bearer $OVH_AI_ENDPOINTS_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "model": "clef-flash", "state": "Hello, I would like to download the invoice of the previous month for my Public Cloud project. Where can I find it?", "questions": { "department": { "type": "choice", "criteria": {"billing": "Payments and invoices", "technical": "Bugs", "sales": null} } } }' ``` The request and the response follow the System One format, so its clients only need this base URL. Want to explore the full capabilities of the Decision API? Dive into our dedicated [Decision Models guide](https://docs.ovhcloud.com/en/guides/public-cloud/ai-machine-learning/ai-endpoints-decision-models) to discover the question types in detail and ready to run code examples in Python, JavaScript, and cURL. ## Response ```json { "model": "clef-flash", "answers": { "department": { "type": "choice", "choice": "sales", "confidence": 0.8309, "probabilities": {"billing": 0.0862, "technical": 0.0829, "sales": 0.8309} }, "frustration": { "type": "score", "score": 0.0292, "confidence": 0.9726, "legend": {"0": "Calm, just stating facts", "1": "Frustrated but civil", "2": "Very angry, strong language"}, "probabilities": {"0": 0.9726, "1": 0.0255, "2": 0.0018} }, "is_urgent": {"type": "noul", "noul": 0.069} }, "usage": {"input_tokens": 368, "output_tokens": 0}, "object": "decision" } ``` Only the tokens of the state and of the questions (`input_tokens`) are billed. ## Limits - The `state` is a string, or any JSON structure (an object, a list of messages). - The state and the questions share the context of the model: 16k tokens for Clef-Flash. A short question costs about 90 tokens, so a request holds around 180 of them with an empty state. A request that does not fit is not answered: keep it well below the context. - A `choice` has 2 to 255 options and a `score` 2 to 10 levels. - Images, audio and video are not supported: the fields `images`, `audio` and `videos` are refused. Unknown fields are refused rather than ignored. ## Model rate limit - **Anonymous**: 2 requests per minute, per IP and per model. - **Authenticated with an API access key**: 400 requests per minute, per Public Cloud project and per model. If you exceed this limit, a **429** error code will be returned. ## Going Further For a broader overview of AI Endpoints, explore the full [AI Endpoints Documentation](https://help.ovhcloud.com/csm/en-gb-documentation-public-cloud-ai-and-machine-learning-ai-endpoints?id=kb_browse_cat&kb_id=574a8325551974502d4c6e78b7421938&kb_category=ea1d6daa918a1a541e11d3d71f8624aa). Reach out to our support team or join the [OVHcloud Discord](https://discord.gg/ovhcloud) #ai-endpoints channel to share your questions, feedback, and suggestions for improving the service, to the team and the community.