{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/antfly/json-schema/antfly-decision-request-schema.json",
  "title": "DecisionRequest",
  "description": "A trained decider request or a constrained generator request.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/antfly-inference-api-openapi.yml#/components/schemas/DecisionRequest",
  "oneOf": [
    {
      "$ref": "#/$defs/InferenceDecideRequest"
    },
    {
      "$ref": "#/$defs/GeneratedDecideRequest"
    }
  ],
  "$defs": {
    "AntflyGeneratorConfig": {
      "type": "object",
      "description": "Configuration for the Antfly inference generative AI provider.\n",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "antfly"
          ]
        },
        "model": {
          "type": "string",
          "description": "The name of the generator model."
        },
        "api_url": {
          "type": "string",
          "format": "uri",
          "description": "The URL of the Inference API endpoint. Can also be set via ANTFLY_INFERENCE_URL environment variable."
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "description": "Controls randomness in generation (0.0-2.0).",
          "minimum": 0.0,
          "maximum": 2.0
        },
        "max_tokens": {
          "type": "integer",
          "description": "Maximum number of tokens to generate."
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "description": "Nucleus sampling parameter.",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "top_k": {
          "type": "integer",
          "description": "Top-k sampling parameter."
        },
        "timeout": {
          "type": "integer",
          "description": "HTTP response timeout in seconds for Inference API calls.",
          "minimum": 1
        }
      },
      "required": [
        "provider",
        "model"
      ]
    },
    "AnthropicGeneratorConfig": {
      "type": "object",
      "description": "Configuration for the Anthropic generative AI provider.\n",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "anthropic"
          ]
        },
        "workspace_id": {
          "type": "string",
          "description": "Anthropic workspace for keys not scoped to a workspace. Defaults to ANTHROPIC_WORKSPACE_ID."
        },
        "model": {
          "type": "string",
          "description": "The full model ID of the Anthropic model to use.",
          "default": "claude-sonnet-4-5-20250929"
        },
        "api_key": {
          "type": "string",
          "writeOnly": true,
          "description": "Anthropic API key or secret reference. Defaults to ANTHROPIC_API_KEY."
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Messages API base URL. Defaults to https://api.anthropic.com/v1."
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "description": "Controls randomness in generation (0.0-1.0).",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "max_tokens": {
          "type": "integer",
          "description": "Maximum number of tokens to generate in the response."
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "description": "Nucleus sampling parameter (0.0-1.0).",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "top_k": {
          "type": "integer",
          "description": "Top-k sampling parameter."
        }
      },
      "required": [
        "provider",
        "model"
      ]
    },
    "AppleGeneratorConfig": {
      "type": "object",
      "description": "On-device Apple Foundation Models generation. Requires a macOS Apple provider build, Apple Intelligence enabled, and its system model ready. Supports text conversations; tool calling and media attachments are not supported.",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "apple"
          ]
        },
        "max_tokens": {
          "type": "integer",
          "minimum": 1,
          "default": 256
        },
        "temperature": {
          "type": "number",
          "minimum": 0,
          "maximum": 2
        }
      }
    },
    "BedrockGeneratorConfig": {
      "type": "object",
      "description": "AWS Bedrock Converse generation, including image inputs and tools for\nmodels that support them. Uses the AWS default credential chain unless\nan explicit Bedrock API key is configured. Image capability is declared\nper target through inference_capabilities; model IDs are not allowlisted.\n",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "bedrock"
          ]
        },
        "url": {
          "type": "string",
          "description": "Optional Bedrock Runtime endpoint override. Defaults to the regional AWS endpoint."
        },
        "api_key": {
          "type": "string",
          "description": "Optional Bedrock bearer API key or secret reference. Omit to use signed AWS requests and the default credential chain."
        },
        "model": {
          "type": "string",
          "description": "The Bedrock model ID to use."
        },
        "region": {
          "type": "string",
          "description": "AWS region. Defaults to AWS_REGION, then AWS_DEFAULT_REGION, then us-east-1."
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "description": "Controls randomness in generation (0.0-1.0).",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "max_tokens": {
          "type": "integer",
          "description": "Maximum number of tokens to generate."
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "description": "Nucleus sampling parameter.",
          "minimum": 0.0,
          "maximum": 1.0
        }
      },
      "required": [
        "provider",
        "model"
      ]
    },
    "ChatGPTGeneratorConfig": {
      "type": "object",
      "description": "Personal ChatGPT plan for interactive generation. Credentials stay in the local runtime.",
      "required": [
        "provider",
        "model",
        "connection_id"
      ],
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "chatgpt"
          ]
        },
        "reasoning_effort": {
          "$ref": "#/$defs/OpenAIReasoningEffort"
        },
        "model": {
          "type": "string"
        },
        "connection_id": {
          "type": "string",
          "description": "Opaque personal registration owned by the authenticated caller."
        }
      }
    },
    "ChoiceDecisionQuestion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name",
        "instructions",
        "choices"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "choice"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "string",
          "minLength": 1
        },
        "choices": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionChoice"
          },
          "minItems": 2,
          "maxItems": 64
        },
        "embedding_options": {
          "$ref": "#/$defs/EmbeddingDecisionAcceptance"
        }
      }
    },
    "CloudflareGeneratorConfig": {
      "type": "object",
      "description": "Cloudflare Workers AI generation. Uses CLOUDFLARE_API_TOKEN or an Antfly secret reference.",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "cloudflare"
          ]
        },
        "account_id": {
          "type": "string",
          "minLength": 1
        },
        "gateway_id": {
          "type": "string",
          "minLength": 1,
          "description": "Optional AI Gateway ID, sent through cf-aig-gateway-id."
        },
        "model": {
          "type": "string",
          "default": "@cf/meta/llama-3.3-70b-instruct-fp8-fast"
        },
        "api_key": {
          "type": "string",
          "writeOnly": true
        },
        "url": {
          "type": "string",
          "description": "Optional deployment-owned endpoint override."
        },
        "max_tokens": {
          "type": "integer",
          "minimum": 1
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "minimum": 0,
          "maximum": 2
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "minimum": 0,
          "maximum": 1
        },
        "frequency_penalty": {
          "type": "number",
          "format": "float",
          "minimum": -2,
          "maximum": 2
        },
        "presence_penalty": {
          "type": "number",
          "format": "float",
          "minimum": -2,
          "maximum": 2
        }
      },
      "required": [
        "provider",
        "account_id",
        "model"
      ]
    },
    "ConstrainedGenerationBatch": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "max_items_per_call": {
          "type": "integer",
          "minimum": 1,
          "maximum": 256,
          "default": 8
        },
        "max_input_bytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4194304,
          "default": 65536
        }
      }
    },
    "ConstrainedOutput": {
      "type": "string",
      "enum": [
        "auto",
        "tool_call",
        "json_schema",
        "grammar"
      ],
      "default": "auto",
      "description": "Provider and model admission selects a supported constrained mechanism. Auto prefers forced tools, then provider JSON schema, then native grammar. Free-text parsing is not a mode."
    },
    "ConstrainedProbabilities": {
      "type": "string",
      "enum": [
        "token_logprobs",
        "verdict_only"
      ],
      "default": "token_logprobs",
      "description": "Token probabilities require complete decoder evidence for the allowed values. Verdict-only is explicit opt-in; model-reported confidence is never used."
    },
    "DecisionChoice": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "value"
      ],
      "properties": {
        "value": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        }
      },
      "description": "Local decision models use string choice identifiers. Embedding category examples replace the description with their normalized centroid; trained models reject examples."
    },
    "DecisionEvidence": {
      "description": "Text or ordered user messages containing text and images. Named OpenAI and Jev deciders and constrained generators accept messages. Generated image decisions require a model that supports both images and constrained output; native, Gemini, and Vertex generators require inline images and automatic detail. Native trained and embedding deciders require text. At most 128 images and 1 MiB of serialized evidence per call. Jev requires inline PNG/JPEG data URLs and detail auto; OpenAI also accepts public HTTP(S) image URLs and WebP/GIF. Audio, files, tools, and non-user roles are unsupported.",
      "oneOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 1048576
        },
        {
          "type": "array",
          "minItems": 1,
          "maxItems": 128,
          "items": {
            "$ref": "#/$defs/DecisionEvidenceMessage"
          }
        }
      ]
    },
    "DecisionEvidenceImage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "image_url"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "input_image"
          ]
        },
        "image_url": {
          "type": "string",
          "minLength": 1,
          "description": "Base64 data URL (image/png, image/jpeg, image/webp, image/gif), or a public HTTP(S) URL for OpenAI. Antfly never fetches image URLs for decision adapters."
        },
        "detail": {
          "type": "string",
          "enum": [
            "auto",
            "low",
            "high"
          ],
          "default": "auto"
        }
      }
    },
    "DecisionEvidenceMessage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "role",
        "content"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "message"
          ]
        },
        "role": {
          "type": "string",
          "enum": [
            "user"
          ]
        },
        "content": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "array",
              "minItems": 1,
              "maxItems": 256,
              "items": {
                "oneOf": [
                  {
                    "$ref": "#/$defs/DecisionEvidenceText"
                  },
                  {
                    "$ref": "#/$defs/DecisionEvidenceImage"
                  },
                  {
                    "$ref": "#/$defs/DecisionEvidenceTableImage"
                  }
                ]
              }
            }
          ]
        }
      }
    },
    "DecisionEvidenceTableImage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "source"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "input_image"
          ]
        },
        "source": {
          "$ref": "#/$defs/DecisionTableSource"
        },
        "detail": {
          "type": "string",
          "enum": [
            "auto",
            "low",
            "high"
          ],
          "default": "auto"
        }
      }
    },
    "DecisionEvidenceText": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "text"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "input_text"
          ]
        },
        "text": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "DecisionInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "input"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "input": {
          "$ref": "#/$defs/DecisionEvidence"
        },
        "context_index": {
          "x-go-type-skip-optional-pointer": false,
          "type": "integer",
          "minimum": 0,
          "description": "Index into request contexts. Requires context_version 1. Text expands to context, newline, then input. Message evidence gets a leading user message containing the context. The 1 MiB per-item and 16 MiB aggregate evidence limits apply after expansion. Native trained and embedding deciders require text. Generated deciders accept image evidence when the selected generator supports images and constrained output."
        }
      }
    },
    "DecisionLevel": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        }
      },
      "description": "Ordered score level, from lowest to highest. Results assign zero-based numeric values to these levels."
    },
    "DecisionTableSource": {
      "type": "object",
      "additionalProperties": false,
      "description": "Antfly gateway-only, request-local table image reference. The gateway uses the ingress identity through the ordinary query path, checks the current revision, optional source identity, digest, MIME, byte length and pixel bound, then materializes provider-compatible image evidence. It never forwards this locator or a credential upstream. The digest is not an access grant. Direct inference servers without table access reject this form.",
      "required": [
        "table",
        "document_id",
        "field",
        "revision_field",
        "revision",
        "sha256",
        "mime_type",
        "byte_length"
      ],
      "properties": {
        "table": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        "document_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "field": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        "revision_field": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        "revision": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "identity": {
          "type": "string",
          "pattern": "^sv1-[0-9a-f]{64}$"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "mime_type": {
          "type": "string",
          "enum": [
            "image/png",
            "image/jpeg",
            "image/webp",
            "image/gif"
          ]
        },
        "byte_length": {
          "type": "integer",
          "minimum": 1,
          "maximum": 16777216
        },
        "max_pixels": {
          "type": "integer",
          "minimum": 1,
          "maximum": 67108864,
          "default": 67108864
        },
        "filter_query": {
          "type": "object",
          "additionalProperties": true,
          "description": "Additional caller selection, conjoined with the gateway's live row policy; never an authorization override."
        },
        "permissions_field": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        "principals": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096
          },
          "description": "Optional narrowing check against permissions_field.public/readers; it cannot grant table or row access."
        }
      }
    },
    "EmbeddingDecisionAcceptance": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "calibration_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,64}$",
          "description": "Public API identifier for a server-side fitted threshold artifact at model/calibrations/{id}.json. The server verifies qualification and the exact asset identity, prompt profile, dimensions, renderer and this question's label/prototype set. Mutually exclusive with manual thresholds; never produces probabilities."
        },
        "min_similarity": {
          "type": "number",
          "minimum": -1,
          "maximum": 1,
          "description": "For a single choice, abstain when the highest cosine similarity is below this value. It is a similarity threshold, not an accuracy or probability estimate."
        },
        "min_margin": {
          "type": "number",
          "minimum": 0,
          "maximum": 2,
          "description": "For a single choice, require this gap between the highest and second-highest cosine similarities. For multi_choice, require every score to be at least this distance from its own selection threshold; otherwise abstain."
        }
      },
      "description": "Question-specific acceptance policy for embedding similarity. Trained decision models reject it."
    },
    "EmbeddingDecisionOptions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "task_type": {
          "type": "string",
          "enum": [
            "CLUSTERING",
            "CLASSIFICATION"
          ],
          "default": "CLUSTERING",
          "description": "Prompt profile for the decision input and category prototypes. The embedding endpoint also accepts task_type; decision routing restricts it to these two profiles."
        },
        "dimensions": {
          "type": "integer",
          "enum": [
            768,
            512,
            256,
            128
          ],
          "default": 768,
          "description": "Truncate and renormalize embeddings to this dimension before cosine scoring."
        }
      },
      "description": "Request-wide embedding geometry defaults. Acceptance thresholds and calibration belong to individual questions."
    },
    "GeneratedChoiceDecisionQuestion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name",
        "choices"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "choice"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "string",
          "minLength": 1,
          "description": "May inherit nonempty generated decider instructions."
        },
        "choices": {
          "type": "array",
          "minItems": 2,
          "maxItems": 64,
          "items": {
            "$ref": "#/$defs/DecisionChoice"
          }
        }
      }
    },
    "GeneratedDecideQuestion": {
      "oneOf": [
        {
          "$ref": "#/$defs/GeneratedChoiceDecisionQuestion"
        },
        {
          "$ref": "#/$defs/GeneratedMultiChoiceDecisionQuestion"
        },
        {
          "$ref": "#/$defs/GeneratedPredicateDecisionQuestion"
        },
        {
          "$ref": "#/$defs/GeneratedScoreDecisionQuestion"
        }
      ]
    },
    "GeneratedDecideRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "decision_method",
        "generator",
        "questions"
      ],
      "description": "Supply exactly one of input or inputs. Each question requires instructions unless nonempty decider instructions are supplied. Inference nodes admit registered native generators; hosted execution uses configured producer and SQL runtimes.",
      "properties": {
        "decision_method": {
          "type": "string",
          "enum": [
            "generated"
          ]
        },
        "generator": {
          "$ref": "#/$defs/GeneratorConfig"
        },
        "input": {
          "$ref": "#/$defs/DecisionEvidence"
        },
        "inputs": {
          "type": "array",
          "minItems": 1,
          "maxItems": 128,
          "items": {
            "$ref": "#/$defs/DecisionInput"
          }
        },
        "questions": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "$ref": "#/$defs/GeneratedDecideQuestion"
          }
        },
        "instructions": {
          "type": "string",
          "maxLength": 65536
        },
        "output": {
          "$ref": "#/$defs/ConstrainedOutput"
        },
        "probabilities": {
          "$ref": "#/$defs/ConstrainedProbabilities"
        },
        "batch": {
          "$ref": "#/$defs/ConstrainedGenerationBatch"
        }
      }
    },
    "GeneratedMultiChoiceDecisionQuestion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name",
        "choices"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "multi_choice"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "string",
          "minLength": 1,
          "description": "May inherit nonempty generated decider instructions."
        },
        "choices": {
          "type": "array",
          "minItems": 2,
          "maxItems": 64,
          "items": {
            "$ref": "#/$defs/DecisionChoice"
          }
        }
      }
    },
    "GeneratedPredicateDecisionQuestion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "predicate"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "string",
          "minLength": 1,
          "description": "May inherit nonempty generated decider instructions."
        }
      }
    },
    "GeneratedScoreDecisionQuestion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "score"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "string",
          "minLength": 1,
          "description": "May inherit nonempty generated decider instructions."
        }
      }
    },
    "GeneratorConfig": {
      "description": "A unified configuration for a generative AI provider.\n",
      "allOf": [
        {
          "oneOf": [
            {
              "$ref": "#/$defs/CloudflareGeneratorConfig"
            },
            {
              "$ref": "#/$defs/GoogleGeneratorConfig"
            },
            {
              "$ref": "#/$defs/VertexGeneratorConfig"
            },
            {
              "$ref": "#/$defs/BedrockGeneratorConfig"
            },
            {
              "$ref": "#/$defs/AnthropicGeneratorConfig"
            },
            {
              "$ref": "#/$defs/OllamaGeneratorConfig"
            },
            {
              "$ref": "#/$defs/AntflyGeneratorConfig"
            },
            {
              "$ref": "#/$defs/ChatGPTGeneratorConfig"
            },
            {
              "$ref": "#/$defs/OpenAIGeneratorConfig"
            },
            {
              "$ref": "#/$defs/OpenRouterGeneratorConfig"
            },
            {
              "$ref": "#/$defs/AppleGeneratorConfig"
            }
          ]
        },
        {
          "properties": {
            "max_image_input_tokens": {
              "x-go-type-skip-optional-pointer": false,
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "description": "Conservative input-token ceiling per image. Required for image calls when tokens_per_minute is configured; choose a bound valid for the model and image policy."
            },
            "rate_limit": {
              "x-go-type-skip-optional-pointer": false,
              "$ref": "#/$defs/RateLimitConfig"
            },
            "provider": {
              "$ref": "#/$defs/GeneratorProvider"
            }
          },
          "required": [
            "provider"
          ]
        }
      ]
    },
    "GeneratorProvider": {
      "type": "string",
      "enum": [
        "cloudflare",
        "gemini",
        "vertex",
        "bedrock",
        "anthropic",
        "ollama",
        "openai",
        "chatgpt",
        "openrouter",
        "antfly",
        "apple"
      ],
      "description": "Generator providers implemented by Antfly's generation runtime."
    },
    "GoogleGeneratorConfig": {
      "type": "object",
      "description": "Configuration for the Google generative AI provider (Gemini).\n",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "gemini"
          ]
        },
        "project_id": {
          "type": "string",
          "description": "The Google Cloud project ID."
        },
        "location": {
          "type": "string",
          "description": "The Google Cloud location (e.g., 'us-central1')."
        },
        "model": {
          "type": "string",
          "description": "The name of the generative model to use.",
          "default": "gemini-2.5-flash"
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "description": "Controls randomness in generation (0.0-2.0).",
          "minimum": 0.0,
          "maximum": 2.0
        },
        "max_tokens": {
          "type": "integer",
          "description": "Maximum number of tokens to generate."
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "description": "Nucleus sampling parameter.",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "top_k": {
          "type": "integer",
          "description": "Top-k sampling parameter."
        },
        "api_key": {
          "type": "string",
          "writeOnly": true,
          "description": "The Google API key."
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "The URL of the Google API endpoint."
        }
      },
      "required": [
        "provider",
        "model"
      ]
    },
    "InferenceDecideLongDocument": {
      "type": "object",
      "additionalProperties": false,
      "description": "Explicit windowing for qualified boundary decision models. Span and embedding decision models reject window mode. Omission preserves rejection of over-limit text.",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "reject",
            "window"
          ],
          "default": "reject",
          "x-go-type-skip-optional-pointer": false
        },
        "window_words": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4096,
          "default": 1024,
          "x-go-type-skip-optional-pointer": false
        },
        "overlap_words": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4095,
          "default": 32,
          "x-go-type-skip-optional-pointer": false,
          "description": "Must be smaller than window_words. Only valid in window mode."
        },
        "max_windows": {
          "type": "integer",
          "minimum": 1,
          "maximum": 128,
          "default": 128,
          "x-go-type-skip-optional-pointer": false
        }
      }
    },
    "InferenceDecideQuestion": {
      "oneOf": [
        {
          "$ref": "#/$defs/ChoiceDecisionQuestion"
        },
        {
          "$ref": "#/$defs/MultiChoiceDecisionQuestion"
        },
        {
          "$ref": "#/$defs/ScoreDecisionQuestion"
        },
        {
          "$ref": "#/$defs/PredicateDecisionQuestion"
        }
      ]
    },
    "InferenceDecideRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "model",
        "questions"
      ],
      "properties": {
        "context_version": {
          "type": "integer",
          "enum": [
            1
          ],
          "description": "Explicit shared-context transport version. Requires batched inputs and contexts; unknown versions are rejected."
        },
        "contexts": {
          "type": "array",
          "maxItems": 128,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1048576
          },
          "description": "Shared immutable context strings referenced by context_index. Requires context_version 1. Total expanded input bytes are limited to 16 MiB."
        },
        "model": {
          "type": "string",
          "minLength": 1
        },
        "model_identity": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Pin the exact EmbeddingGemma 2 assets and embedding recipe."
        },
        "input": {
          "$ref": "#/$defs/DecisionEvidence"
        },
        "inputs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionInput"
          },
          "minItems": 1,
          "maxItems": 128
        },
        "long_document": {
          "$ref": "#/$defs/InferenceDecideLongDocument"
        },
        "questions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/InferenceDecideQuestion"
          },
          "minItems": 1,
          "maxItems": 64
        },
        "embedding_options": {
          "$ref": "#/$defs/EmbeddingDecisionOptions"
        }
      },
      "description": "Supply exactly one of input (single evidence item) or inputs (ordered Antfly batch extension; hosted typed deciders also accept multimodal evidence per item). Question names must be unique. Single text and named question arrays follow OpenAI Decisions conventions; local models support text input and string choice values. Request bodies are bounded at 16 MiB."
    },
    "MultiChoiceDecisionQuestion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name",
        "instructions",
        "choices"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "multi_choice"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "string",
          "minLength": 1
        },
        "choices": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionChoice"
          },
          "minItems": 2,
          "maxItems": 64
        },
        "embedding_options": {
          "$ref": "#/$defs/EmbeddingDecisionAcceptance"
        },
        "similarity_thresholds": {
          "description": "Required raw cosine cutoff for every choice, either one common cutoff or a complete choice-to-cutoff map. Alternatively supply a qualified question-specific calibration_id. Mutually exclusive with calibration_id. Scores equal to their cutoff are selected.",
          "oneOf": [
            {
              "type": "number",
              "minimum": -1,
              "maximum": 1
            },
            {
              "type": "object",
              "additionalProperties": {
                "type": "number",
                "minimum": -1,
                "maximum": 1
              }
            }
          ]
        }
      },
      "description": "Antfly multi-label extension for embedding similarity; selected, empty and abstained are distinct results."
    },
    "OllamaGeneratorConfig": {
      "type": "object",
      "description": "Configuration for the Ollama generative AI provider.\n",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "ollama"
          ]
        },
        "model": {
          "type": "string",
          "description": "The name of the Ollama model to use."
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "The URL of the Ollama API endpoint."
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "description": "Controls randomness in generation (0.0-2.0).",
          "minimum": 0.0,
          "maximum": 2.0
        },
        "max_tokens": {
          "type": "integer",
          "description": "Maximum number of tokens to generate."
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "description": "Nucleus sampling parameter.",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "top_k": {
          "type": "integer",
          "description": "Top-k sampling parameter."
        },
        "timeout": {
          "type": "integer",
          "description": "HTTP response timeout in seconds for Ollama API calls.",
          "minimum": 1
        }
      },
      "required": [
        "provider",
        "model"
      ]
    },
    "OpenAIGeneratorConfig": {
      "type": "object",
      "description": "Configuration for the OpenAI generative AI provider.\n",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "openai"
          ]
        },
        "model": {
          "type": "string",
          "description": "The name of the OpenAI model to use.",
          "default": "gpt-4.1"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "The URL of the OpenAI API endpoint."
        },
        "api_key": {
          "type": "string",
          "writeOnly": true,
          "description": "The OpenAI API key."
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "description": "Controls randomness in generation (0.0-2.0).",
          "minimum": 0.0,
          "maximum": 2.0
        },
        "max_tokens": {
          "type": "integer",
          "description": "Maximum number of tokens to generate."
        },
        "max_completion_tokens": {
          "type": "integer",
          "minimum": 1,
          "description": "OpenAI completion budget, including visible output and reasoning tokens.\nUse for reasoning models instead of max_tokens; the two are mutually exclusive.\n"
        },
        "reasoning_effort": {
          "$ref": "#/$defs/OpenAIReasoningEffort",
          "description": "Optional reasoning effort. Supported values depend on the selected OpenAI model."
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "description": "Nucleus sampling parameter.",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "frequency_penalty": {
          "type": "number",
          "format": "float",
          "description": "Penalty for token frequency (-2.0 to 2.0).",
          "minimum": -2.0,
          "maximum": 2.0
        },
        "presence_penalty": {
          "type": "number",
          "format": "float",
          "description": "Penalty for token presence (-2.0 to 2.0).",
          "minimum": -2.0,
          "maximum": 2.0
        }
      },
      "required": [
        "provider",
        "model"
      ]
    },
    "OpenAIReasoningEffort": {
      "type": "string",
      "enum": [
        "none",
        "minimal",
        "low",
        "medium",
        "high",
        "xhigh",
        "max"
      ],
      "description": "OpenAI reasoning effort; model support varies. Omit to use the model default."
    },
    "OpenRouterGeneratorConfig": {
      "type": "object",
      "description": "Configuration for the OpenRouter generative AI provider.\n",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "openrouter"
          ]
        },
        "model": {
          "type": "string",
          "description": "The OpenRouter model identifier to use."
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "The URL of the OpenRouter API endpoint.",
          "default": "https://openrouter.ai/api/v1"
        },
        "api_key": {
          "type": "string",
          "writeOnly": true,
          "description": "The OpenRouter API key."
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "description": "Controls randomness in generation (0.0-2.0).",
          "minimum": 0.0,
          "maximum": 2.0
        },
        "max_tokens": {
          "type": "integer",
          "description": "Maximum number of tokens to generate in the response."
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "description": "Nucleus sampling parameter (0.0-1.0).",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "frequency_penalty": {
          "type": "number",
          "format": "float",
          "description": "Penalty for token frequency (-2.0 to 2.0).",
          "minimum": -2.0,
          "maximum": 2.0
        },
        "presence_penalty": {
          "type": "number",
          "format": "float",
          "description": "Penalty for token presence (-2.0 to 2.0).",
          "minimum": -2.0,
          "maximum": 2.0
        }
      },
      "required": [
        "provider",
        "model"
      ]
    },
    "PredicateDecisionQuestion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name",
        "instructions"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "predicate"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "string",
          "minLength": 1
        }
      },
      "description": "Estimate whether the condition in instructions holds for the input. The trained answer reports probability in [0,1]."
    },
    "RateLimitConfig": {
      "type": "object",
      "x-go-type-skip-optional-pointer": false,
      "additionalProperties": false,
      "description": "Outbound provider limits shared within one Antfly process by effective\nendpoint, operation, model, credential source, project and region/location.\nConflicting policies for an active scope are rejected. These limits do\nnot coordinate across replicas or infer the provider's account quota.\n",
      "properties": {
        "pacing": {
          "$ref": "#/$defs/RequestPacing",
          "description": "Request pacing mode. Defaults to token_bucket. Legacy flat embedder RPM with burst=1 uses completion pacing."
        },
        "requests_per_minute": {
          "type": "integer",
          "format": "int64",
          "minimum": 1,
          "maximum": 4294967295
        },
        "burst": {
          "type": "integer",
          "format": "int64",
          "minimum": 1,
          "maximum": 4294967295,
          "default": 1
        },
        "tokens_per_minute": {
          "type": "integer",
          "format": "int64",
          "minimum": 1,
          "description": "Conservative text budget: each HTTP attempt reserves its serialized\nUTF-8 body byte count plus the configured generation output cap.\nReservations are not refunded. A request larger than this budget\nis rejected. This is not provider billing token accounting; media\nrequests are not supported with this limit.\n"
        },
        "max_concurrency": {
          "type": "integer",
          "format": "int64",
          "minimum": 1,
          "maximum": 4294967295,
          "description": "Maximum in-flight HTTP attempts, held through response completion."
        }
      }
    },
    "RequestPacing": {
      "type": "string",
      "enum": [
        "token_bucket",
        "completion"
      ],
      "description": "token_bucket limits admission rate while allowing overlapping attempts.\ncompletion serializes attempts and waits one RPM interval after each\nattempt finishes, including streamed writes and transport failures.\nThis prevents delayed connection setup from compressing successful\nrequest spacing, at the cost of response latency plus one interval per\nrequest. Requires requests_per_minute and burst=1. Neither mode can\nguarantee zero upstream 429s or coordinate other processes.\n"
    },
    "ScoreDecisionQuestion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name",
        "instructions",
        "levels"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "score"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "string",
          "minLength": 1
        },
        "levels": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionLevel"
          },
          "minItems": 2,
          "maxItems": 64
        }
      }
    },
    "VertexGeneratorConfig": {
      "type": "object",
      "description": "Configuration for Google Cloud Vertex AI generative models.\n",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "vertex"
          ]
        },
        "model": {
          "type": "string",
          "description": "The name of the Vertex AI model to use.",
          "default": "gemini-2.5-flash"
        },
        "project_id": {
          "type": "string",
          "description": "Google Cloud project ID."
        },
        "location": {
          "type": "string",
          "description": "Google Cloud region for Vertex AI API.",
          "default": "us-central1"
        },
        "credentials_path": {
          "type": "string",
          "writeOnly": true,
          "description": "Path to service account JSON key file."
        },
        "temperature": {
          "type": "number",
          "format": "float",
          "description": "Controls randomness in generation (0.0-2.0).",
          "minimum": 0.0,
          "maximum": 2.0
        },
        "max_tokens": {
          "type": "integer",
          "description": "Maximum number of tokens to generate in the response."
        },
        "top_p": {
          "type": "number",
          "format": "float",
          "description": "Nucleus sampling parameter (0.0-1.0).",
          "minimum": 0.0,
          "maximum": 1.0
        },
        "top_k": {
          "type": "integer",
          "description": "Top-k sampling parameter."
        }
      },
      "required": [
        "provider",
        "model"
      ]
    }
  }
}