> For the complete documentation index, see [llms.txt](https://docs.aimlapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aimlapi.com/api-references/decision-models/openai/gpt-6-luna.md).

# GPT-6 Luna

{% columns %}
{% column width="66.66666666666666%" %}
{% hint style="info" %}
This documentation is valid for the following list of our models:

* `openai/gpt-6-luna`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/openai/gpt-6-luna" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

## Model Overview

On `/v1/decisions` GPT-6 Luna does not generate text. You give it some content and a list of typed questions, and it returns a typed answer for each with calibrated probabilities — a yes/no probability, one option out of a set, or a position on an ordered scale.

It is the same model served on [`/v1/chat/completions` and `/v1/responses`](/api-references/text-models-llm/openai/gpt-6-luna.md): fast and cost-efficient, text and image input, a 1,050,000-token context. The decision surface is simply a different way to call it, and the one to reach for when you want a verdict your code can branch on rather than prose it has to parse.

{% hint style="warning" %}
**Luna's request shape is not the one Jev and d1 use.** The endpoint serves two contracts and gives no hint which it got — sending the wrong one is a plain `400`.

|                | Luna                                  | [Jev](/api-references/decision-models/typesafe/jev.md) / [d1](/api-references/decision-models/liquid-ai/d1.md) |
| -------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| content field  | `input`                               | `state`                                                                                                        |
| `questions`    | an **array**, each item with a `name` | an **object** keyed by name                                                                                    |
| yes/no type    | `predicate` → `probability`           | `noul` → `noul`                                                                                                |
| choice options | `choices: [{value, description}]`     | `criteria: {key: description}`                                                                                 |
| score levels   | `levels: [{label, description}]`      | `criteria: ["Low", "High"]`                                                                                    |
| `answers`      | an **array**, each echoing its `name` | an **object** keyed by name                                                                                    |
| {% endhint %}  |                                       |                                                                                                                |

{% hint style="success" %}
[Create AI/ML API Key](https://aimlapi.com/app/keys)
{% endhint %}

<details>

<summary>How to make the first API call</summary>

**1️⃣ Required setup (don’t skip this)**\
▪ **Create an account:** Sign up on the AI/ML API website (if you don’t have one yet).\
▪ **Generate an API key:** In your account dashboard, create an API key and make sure it’s **enabled** in the UI.

**2️ Copy the code example**\
At the bottom of this page, pick the snippet for your preferred programming language (Python / Node.js) and copy it into your project.

**3️ Update the snippet for your use case**\
▪ **Insert your API key:** replace `<YOUR_AIMLAPI_KEY>` with your real AI/ML API key.\
▪ **Select a model:** set the `model` field to `openai/gpt-6-luna`.\
▪ **Provide input:** put the content to evaluate in `input` and the questions in `questions`.

**4️ (Optional) Tune the request**\
See the API schema below for the three question types (`predicate`, `choice`, `score`) and `prompt_cache_key`.

**5️ Run your code**\
Run the updated code in your development environment.

{% hint style="success" %}
For a detailed walkthrough, use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

## API Schema

## POST /v1/decisions

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/decisions":{"post":{"operationId":"_v1_decisions","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"model":{"type":"string","enum":["openai/gpt-6-luna"]},"input":{"anyOf":[{"type":"string","minLength":1,"maxLength":1048576},{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["message"]},"role":{"type":"string","enum":["user"]},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["input_text"]},"text":{"type":"string"}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["input_image"]},"image_url":{"type":"string","description":"A base64 `data:` URL (`data:image/png;base64,…`) or an http(s) URL; we pass it to OpenAI inline."},"detail":{"type":"string","description":"Image detail, as OpenAI reads it (`low`, `high`, `auto`)."}},"required":["type","image_url"]}]},"minItems":1}]}},"required":["role","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["message"]},"role":{"type":"string","enum":["system","developer"]},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["input_text"]},"text":{"type":"string"}},"required":["type","text"]},"minItems":1}]}},"required":["role","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["message"]},"role":{"type":"string","enum":["assistant"]},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["output_text"]},"text":{"type":"string"}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["refusal"]},"refusal":{"type":"string"}},"required":["type","refusal"]}]},"minItems":1}]}},"required":["role","content"]}]},"minItems":1}],"description":"Shared evidence for every question: a text string, or user/system/developer/assistant messages. User messages may combine `input_text` and `input_image` parts."},"questions":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["predicate"],"description":"Check a condition; the answer is the probability that it is true."},"name":{"type":"string","minLength":1,"description":"A unique name; the answer echoes it."},"instructions":{"type":"string","minLength":1,"description":"What to evaluate: the condition, the routing rule, the rubric."}},"required":["type","name","instructions"]},{"type":"object","properties":{"type":{"type":"string","enum":["choice"],"description":"Select one of `choices`."},"name":{"type":"string","minLength":1,"description":"A unique name; the answer echoes it."},"instructions":{"type":"string","minLength":1,"description":"What to evaluate: the condition, the routing rule, the rubric."},"choices":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string","minLength":1},"description":{"type":"string"}},"required":["value"]},"minItems":1,"description":"The options: a distinct `value` each, and when it applies. Include a fallback like `other` when the options do not cover every input."}},"required":["type","name","instructions","choices"]},{"type":"object","properties":{"type":{"type":"string","enum":["score"],"description":"Rate against ordered `levels`; the answer is the probability-weighted level index (0-based)."},"name":{"type":"string","minLength":1,"description":"A unique name; the answer echoes it."},"instructions":{"type":"string","minLength":1,"description":"What to evaluate: the condition, the routing rule, the rubric."},"levels":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string","minLength":1},"description":{"type":"string"}},"required":["label"]},"minItems":2,"description":"Ordered levels, lowest first."}},"required":["type","name","instructions","levels"]}]},"minItems":1,"maxItems":200,"description":"1–200 independent questions about the input; answers come back in the same order."},"prompt_cache_key":{"type":"string","maxLength":64,"description":"Partitions prompt cache reuse by a key you choose."}},"required":["model","input","questions"],"title":"openai/gpt-6-luna"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"model":{"type":"string","description":"Resolved model version that answered."},"answers":{"type":"object","additionalProperties":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["noul"]},"noul":{"type":"number","description":"Probability that the answer is \"yes\" (0–1)."}},"required":["type","noul"]},{"type":"object","properties":{"type":{"type":"string","enum":["choice"]},"choice":{"type":"string","description":"The selected option key from `criteria`."},"confidence":{"type":"number","description":"Calibrated confidence in the choice (0–1)."},"probabilities":{"type":"object","additionalProperties":{"type":"number"},"description":"Probability of each option; sums to 1."}},"required":["type","choice","confidence","probabilities"]},{"type":"object","properties":{"type":{"type":"string","enum":["score"]},"score":{"type":"number","description":"Expected level on the ordered scale (may be fractional, e.g. 1.34)."},"confidence":{"type":"number","description":"Calibrated confidence in the score (0–1)."},"legend":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"object","additionalProperties":{"nullable":true}},{"type":"array","items":{"nullable":true}}]},"description":"Level index → level description, as the request gave it (text, or a JSON object/array)."},"probabilities":{"type":"object","additionalProperties":{"type":"number"},"description":"Probability of each option; sums to 1."}},"required":["type","score","confidence","legend","probabilities"]},{"type":"object","properties":{"type":{"type":"string","enum":["box"]},"box":{"type":"object","properties":{"top":{"type":"number"},"bottom":{"type":"number"},"left":{"type":"number"},"right":{"type":"number"}},"required":["top","bottom","left","right"],"description":"The edges of the box around the target, each a fraction (0–1) from the top-left corner: `left` and `right` of the width, `top` and `bottom` of the height."},"confidence":{"type":"number","description":"How sure the model is of the box (0–1)."}},"required":["type","box","confidence"]}]},"description":"One typed answer per question key from the request."},"usage":{"type":"object","properties":{"input_tokens":{"type":"integer"},"output_tokens":{"type":"integer"}},"required":["input_tokens","output_tokens"],"description":"Token usage reported by the provider."}},"required":["model","answers","usage"]},{"type":"object","properties":{"model":{"type":"string","description":"The model that answered."},"answers":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["predicate"]},"name":{"type":"string","description":"The question’s `name`."},"probability":{"type":"number","description":"Probability that the condition is true (0–1)."}},"required":["type","name","probability"]},{"type":"object","properties":{"type":{"type":"string","enum":["choice"]},"name":{"type":"string","description":"The question’s `name`."},"choice":{"type":"string","description":"The selected `value` from `choices`."},"confidence":{"type":"number","description":"Confidence (0–1)."},"probabilities":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"probability":{"type":"number"}},"required":["value","probability"]},"description":"Probability of each choice."}},"required":["type","name","choice","confidence","probabilities"]},{"type":"object","properties":{"type":{"type":"string","enum":["score"]},"name":{"type":"string","description":"The question’s `name`."},"score":{"type":"number","description":"Probability-weighted average of the level indices (0-based; may fall between levels)."},"confidence":{"type":"number","description":"Confidence (0–1)."},"probabilities":{"type":"array","items":{"type":"object","properties":{"value":{"type":"integer"},"label":{"type":"string"},"probability":{"type":"number"}},"required":["value","label","probability"]},"description":"Probability of each level."}},"required":["type","name","score","confidence","probabilities"]},{"type":"object","properties":{"type":{"type":"string","enum":["refusal"]},"name":{"type":"string","description":"The question’s `name`."}},"required":["type","name"]}]},"description":"One answer per question, in request order."},"usage":{"type":"object","properties":{"input_tokens":{"type":"integer"},"input_tokens_details":{"type":"object","properties":{"cached_tokens":{"type":"integer"},"cache_write_tokens":{"type":"integer"}}},"output_tokens":{"type":"integer"},"total_tokens":{"type":"integer"}},"required":["input_tokens","output_tokens","total_tokens"],"description":"Token usage reported by the provider."}},"required":["model","answers","usage"]}]}}}}}}}}}
```

## Code Example

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
import json

response = requests.post(
    "https://api.aimlapi.com/v1/decisions",
    headers={
        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    json={
        "model": "openai/gpt-6-luna",
        "input": "Help! My payments have been failing for 3 days and nobody answers support.",
        "questions": [
            {
                "type": "predicate",
                "name": "is_urgent",
                "instructions": "Does this convey urgency?",
            },
            {
                "type": "choice",
                "name": "department",
                "instructions": "Which team should handle this?",
                "choices": [
                    {"value": "billing", "description": "Payments, invoicing, refunds"},
                    {"value": "technical", "description": "Bugs, outages, integrations"},
                    {"value": "sales", "description": "Pricing, upgrades, new accounts"},
                ],
            },
            {
                "type": "score",
                "name": "frustration",
                "instructions": "How frustrated is the customer?",
                "levels": [{"label": "Calm"}, {"label": "Frustrated"}, {"label": "Very angry"}],
            },
        ],
    },
)

print(json.dumps(response.json(), indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code overflow="wrap" %}

```javascript
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/decisions', {
    method: 'POST',
    headers: {
      // insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'openai/gpt-6-luna',
      input: 'Help! My payments have been failing for 3 days and nobody answers support.',
      questions: [
        {
          type: 'predicate',
          name: 'is_urgent',
          instructions: 'Does this convey urgency?',
        },
        {
          type: 'choice',
          name: 'department',
          instructions: 'Which team should handle this?',
          choices: [
            { value: 'billing', description: 'Payments, invoicing, refunds' },
            { value: 'technical', description: 'Bugs, outages, integrations' },
            { value: 'sales', description: 'Pricing, upgrades, new accounts' },
          ],
        },
        {
          type: 'score',
          name: 'frustration',
          instructions: 'How frustrated is the customer?',
          levels: [{ label: 'Calm' }, { label: 'Frustrated' }, { label: 'Very angry' }],
        },
      ],
    }),
  });

  console.log(JSON.stringify(await response.json(), null, 2));
}

main();
```

{% endcode %}
{% endtab %}
{% endtabs %}

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "model": "gpt-6-luna",
  "answers": [
    {
      "type": "predicate",
      "name": "is_urgent",
      "probability": 0.98
    },
    {
      "type": "choice",
      "name": "department",
      "choice": "billing",
      "probabilities": [
        { "value": "billing", "probability": 1 },
        { "value": "technical", "probability": 0 },
        { "value": "sales", "probability": 0 }
      ],
      "confidence": 1
    },
    {
      "type": "score",
      "name": "frustration",
      "score": 1.01,
      "probabilities": [
        { "value": 0, "label": "Calm", "probability": 0 },
        { "value": 1, "label": "Frustrated", "probability": 0.99 },
        { "value": 2, "label": "Very angry", "probability": 0.01 }
      ],
      "confidence": 0.99
    }
  ],
  "usage": {
    "input_tokens": 406,
    "input_tokens_details": { "cached_tokens": 0, "cache_write_tokens": 0 },
    "output_tokens": 0,
    "output_tokens_details": { "reasoning_tokens": 0 },
    "total_tokens": 406
  },
  "meta": {
    "model": "openai/gpt-6-luna",
    "provider": "openai-verified",
    "usage": { "credits_used": 106, "usd_spent": 0.000053 },
    "metrics": { "duration_ms": 198 }
  }
}
```

{% endcode %}

</details>

## Reading the answers

`answers` is an array in the order you asked, each item echoing the `name` you gave it — index into it by `name`, not by position, if you build the question list dynamically.

* **`predicate`** returns `probability`: how likely the condition is true, 0–1.
* **`choice`** returns the winning `value` in `choice`, a `confidence`, and `probabilities` as an array of `{value, probability}` that sums to 1.
* **`score`** returns `score`, the probability-weighted level index starting at 0 — `1.01` above means "Frustrated" with a trace of "Very angry" — plus `probabilities` as `{value, label, probability}` per level.

As with the other decision models `output_tokens` is `0`: it reaches the answer without emitting tokens, so the whole cost is the input. The call above billed **$0.000053** and came back in **198 ms**.

## Longer inputs and prompt caching

`input` also takes the Responses-style array of message objects, so you can pass a whole conversation instead of a string:

```json
{
  "model": "openai/gpt-6-luna",
  "input": [
    { "type": "message", "role": "user", "content": "My payments keep failing." },
    { "type": "message", "role": "user", "content": "Third day now, no reply from support." }
  ],
  "questions": [
    { "type": "predicate", "name": "is_urgent", "instructions": "Does this convey urgency?" }
  ]
}
```

When the same prefix is evaluated repeatedly — a long rubric, a fixed policy document — add **`prompt_cache_key`** (up to 64 characters) to partition cache reuse by a key of your choosing. `usage.input_tokens_details` then reports `cached_tokens` and `cache_write_tokens` so you can see whether it is working.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aimlapi.com/api-references/decision-models/openai/gpt-6-luna.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
