Overview
The Decision Service uses AI to analyze a decision scenario with multiple options and returns the best choice along with reasoning. It’s ideal for:- Condition assessment (Excellent, Good, Fair, Poor)
- Category classification
- Policy decisions
- Any scenario requiring selection from predefined options
Simple & Fast
Single-purpose service with quick responses.
Context-Aware
Uses item context and business context for informed decisions.
Structured Output
Returns selected option and reasoning explanation.
No Conversation
Direct decision without conversational flow.
How It Works
- Receives prompt, options, and context
- Analyzes the scenario using AI
- Selects one option from the provided list
- Returns decision with reasoning
API Endpoint
POST/loopos_ai_decision
Request Example
Response Example
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
language | string | No | Language code (default: “PT-PT”) |
prompt | string | Yes | The question/decision prompt |
options | array or string | Yes | List of options (can be comma-separated string) |
item_context | string | Yes | Context about the item |
context | string | No | Additional business/user context |
loopos_core_context | string | No | Business context for the AI agent |
session_extra_data | object | No | Additional session metadata |
Response Fields
| Field | Type | Description |
|---|---|---|
decision | string | The selected option (guaranteed to be one of the provided options) |
reasoning | string | Explanation of why this decision was made |
Use Cases
Condition Assessment
Category Classification
Policy Decisions
Best Practices
Options Format
Options can be provided as: Array format (recommended):Error Handling
The service returns standard HTTP status codes:- 200 OK: Decision made successfully
- 422 Validation Error: Missing required fields or invalid input
- 500 Internal Server Error: Server-side error
Performance
The Decision Service is optimized for speed:- Average latency: ~2-3 seconds
- Model: Uses fast models (e.g., Gemini 2.0 Flash, gpt-4o-mini)
- Cost: Low cost per request (~$0.00003-0.0001)
Related Documentation
- Services Overview - Service patterns
- API Reference: Decision - Detailed API documentation
- Quickstart - Getting started guide