> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# اتخاذ قرار

> قيّم أسئلة ذات أنواع محددة بناءً على حالة التطبيق باستخدام نماذج القرار المدعومة.

استخدم `POST /v1/decisions` عندما يحتاج تطبيقك إلى إجابات منظّمة يمكن للكود استهلاكها مباشرةً. تشمل النماذج المدعومة TypeSafe Jev 1.13 (`typesafe/jev-1.13.0`) وTogether Tev1 4B Experimental (`together/tev1-4b-experimental`) وRespan Span-01 (`respan/span-01:free` و`respan/span-01`).

يتضمن الطلب:

* `state`: سلسلة أو كائن أو مصفوفة تحتوي على المعلومات المطلوب تقييمها.
* `questions`: خريطة للأسئلة المسماة. يضبط كل سؤال `type` على `noul` أو `choice` أو `score` ويتضمن `instructions`؛ وتعتمد الأنواع المدعومة على النموذج المحدد.
* `model`: معرّف نموذج Phaseo. استخدم `typesafe/jev-1.13.0` لـ Jev 1.13، أو `typesafe/jev-latest` لمتابعة أحدث إصدار من Jev.

يدعم Liquid D1 (`liquid-ai/d1:free`، والمتاح أيضًا باسم `liquid-ai/d1`) وPerplexity Decider 27B (`perplexity/decider-27b`) أنواع الأسئلة الثلاثة. D1 مجاني خلال الوصول المبكر التجريبي. تبلغ تكلفة Decider ‏0.04 دولار لكل مليون رمز إدخال، بما فيها رموز الصور؛ ورموز الإخراج مجانية. أضف بيانات اعتماد لمزود Perplexity في Phaseo لاستخدام Decider. تستخدم حالته المصورة عناوين URL لبيانات base64 بصيغ PNG أو JPEG أو WebP؛ ولا يدعم عناوين الصور البعيدة. يقبل كل سؤال اختيار ما يصل إلى 255 خيارًا، وكل سؤال تقييم ما يصل إلى 10 مستويات. تحقّق من توفر النموذج قبل استدعاء أي منهما.

في Respan Span-01، يجب أن تكون `state` مقطع محادثة يتضمن مصفوفة `input` للرسائل السابقة ورسالة مساعد `output`. يدعم Span-01 أسئلة `noul` فقط. إجابة `noul` هي احتمال وجود السلوك؛ وتتضمن `probabilities` أيضًا احتمالات غيابه وتعذّر ملاحظته.

```json theme={null}
{
  "model": "respan/span-01:free",
  "state": {
    "input": [{ "role": "user", "content": "Please connect me to a person." }],
    "output": { "role": "assistant", "content": "I will connect you to support." }
  },
  "questions": {
    "escalation": {
      "type": "noul",
      "instructions": "Does the assistant offer a human handoff?"
    }
  }
}
```

`respan/span-01:free` هو نموذج Lite المجاني ذو الحد اليومي؛ ويطابقه Phaseo مع معرّف نموذج API الخاص بـ Respan وهو `span-01-free`. يطابق `respan/span-01` المعرّف `span-01-pro`، وتفرض Respan عليه 0.02 دولار لكل مليون رمز إدخال؛ ورموز الإخراج مجانية. Span-01 في مرحلة الوصول المبكر، لذا يجب أن تفعّل Respan الوصول لمؤسستك. أضف مفتاح API الخاص بك لدى Respan كبيانات اعتماد لمزود Respan في Phaseo قبل استدعاء هذه النماذج.

تستخدم الإجابات المفاتيح نفسها الموجودة في `questions`. تتضمن إجابات `choice` الخيار المحدد والاحتمالات والثقة؛ وتتضمن إجابات `noul` احتمالًا من 0 إلى 1؛ وتتضمن إجابات `score` درجة مرجّحة بالاحتمالات ودليلًا توضيحيًا والاحتمالات والثقة.

في مثال Respan، تبدو الاستجابة كما يلي:

```json theme={null}
{
  "answers": {
    "escalation": {
      "type": "noul",
      "noul": 0.73,
      "probabilities": {
        "true": 0.73,
        "false": 0.25,
        "not_observable": 0.02
      }
    }
  }
}
```

يدعم Jev الجمع بين أنواع الأسئلة الثلاثة في طلب واحد؛ ويدعم Span-01 أسئلة `noul` فقط. راجع [البدء السريع](../../quickstart) لأمثلة جاهزة للنسخ في cURL وJavaScript وSDK TypeScript وSDK Python. تبلغ تكلفة Jev 1.13 ‏0.042 دولار لكل مليون رمز إدخال؛ ورموز الإخراج مجانية.

لمعرفة دلالات الأسئلة لدى المزود الأصلي، راجع [مرجع API](https://docs.typesafe.ai/api) الخاص بـ TypeSafe.

### قرارات الصور باستخدام Clef

يدعم `cloudflare/clef` و`cloudflare/clef-flash` أنواع الأسئلة الثلاثة والصور المضمّنة عبر Cloudflare Workers AI. لكل منهما نافذة سياق من 65,536 رمزًا. تبلغ تكلفة الإدخال 0.24 دولار أمريكي لكل مليون رمز في Clef و0.09 دولار أمريكي في Clef Flash.

```json theme={null}
{
  "model": "cloudflare/clef-flash",
  "state": "Inspect the attached product photo.",
  "images": [{ "content_type": "image/png", "base64": "<base64 image bytes>" }],
  "questions": {
    "damaged": { "type": "noul", "instructions": "Is the product visibly damaged?" }
  }
}
```

يمكنك أيضًا توفير سلسلة `data:image/png;base64,...` في `images`. يقبل Clef حتى أربع صور PNG أو JPEG أو WebP، على ألا تتجاوز كل صورة 4 MiB و16 ميغابكسل، وألا يتجاوز إجمالي بيانات الصور بعد فك الترميز 8 MiB وحجم جسم الطلب 13 MiB. الروابط البعيدة غير مدعومة. يتحقق Cloudflare من صيغ الصور وأبعادها. ترفض النماذج التي لا تدعم الصور طلبات الصور.

يقبل Clef ما يصل إلى 64 سؤالًا، بمعرّفات تضم حتى 100 حرف أو رقم أو شرطة سفلية أو نقطة أو شرطة. تتطلب أسئلة الاختيار 2–255 خيارًا، وأسئلة الدرجة 2–10 مستويات. راجع [وثائق Clef](https://developers.cloudflare.com/workers-ai/models/clef/) من Cloudflare.


## OpenAPI

````yaml ar/openapi/v1/openapi.localized.yaml POST /decisions
openapi: 3.0.3
info:
  title: Phaseo Gateway API
  description: >-
    واجهة API للبوابة تتيح الوصول إلى نماذج ذكاء اصطناعي متنوعة عبر نقاط نهاية
    متوافقة مع OpenAI.
  version: 1.0.0
  contact:
    name: Phaseo
    url: https://phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
    description: التوجيه العالمي
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core Phaseo Gateway operations.
paths:
  /decisions:
    post:
      tags:
        - Gateway
      summary: اتخاذ قرارات منظّمة
      description: >-
        يقيّم أسئلة Noul وChoice وScore ذات الأنواع المحددة بناءً على حالة
        منظّمة باستخدام نموذج قرار مثل TypeSafe Jev.
      operationId: makeDecision
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DecisionsRequest'
      responses:
        '200':
          description: استجابة القرارات المنظّمة
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecisionsResponse'
components:
  schemas:
    DecisionsRequest:
      type: object
      required:
        - model
        - state
        - questions
      properties:
        model:
          type: string
          description: معرّف نموذج Phaseo الأساسي أو الاسم المستعار لنموذج المزود.
          default: typesafe/jev-1.13.0
        state:
          description: حالة منظّمة يقيّمها النموذج.
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
            - type: array
              items: {}
        questions:
          type: object
          minProperties: 1
          maxProperties: 128
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/DecisionNoulQuestion'
              - $ref: '#/components/schemas/DecisionChoiceQuestion'
              - $ref: '#/components/schemas/DecisionScoreQuestion'
        images:
          type: array
          maxItems: 4
          description: >-
            صور مضمّنة لنماذج القرار التي تدعم الرؤية. يقبل Clef صيغ PNG أو JPEG
            أو WebP؛ الروابط البعيدة غير مدعومة. الحد الأقصى 4 MiB و16 ميغابكسل
            لكل صورة، و8 MiB لإجمالي البيانات بعد فك الترميز، و13 MiB لكل جسم
            طلب.
          items:
            oneOf:
              - type: string
                pattern: >-
                  ^[Dd][Aa][Tt][Aa]:image/(png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$
              - $ref: '#/components/schemas/DecisionImage'
        meta:
          type: boolean
          default: false
        echo_upstream_request:
          type: boolean
        debug:
          $ref: '#/components/schemas/DebugOptions'
        provider:
          $ref: '#/components/schemas/ProviderRoutingOptions'
        routing:
          $ref: '#/components/schemas/ProviderRoutingOptions'
        metadata:
          type: object
          additionalProperties: true
    DecisionsResponse:
      type: object
      properties:
        model:
          type: string
        answers:
          type: object
          additionalProperties: true
        usage:
          $ref: '#/components/schemas/DecisionsUsage'
        request_id:
          type: string
          nullable: true
        meta:
          type: object
          additionalProperties: true
    DecisionNoulQuestion:
      type: object
      required:
        - type
        - instructions
      properties:
        type:
          type: string
          enum:
            - noul
        instructions:
          $ref: '#/components/schemas/DecisionInstructions'
        criteria:
          type: object
          properties:
            'true':
              type: string
            'false':
              type: string
          additionalProperties: true
    DecisionChoiceQuestion:
      type: object
      required:
        - type
        - instructions
        - criteria
      properties:
        type:
          type: string
          enum:
            - choice
        instructions:
          $ref: '#/components/schemas/DecisionInstructions'
        criteria:
          type: object
          minProperties: 1
          additionalProperties:
            type: string
            nullable: true
    DecisionScoreQuestion:
      type: object
      required:
        - type
        - instructions
        - criteria
      properties:
        type:
          type: string
          enum:
            - score
        instructions:
          $ref: '#/components/schemas/DecisionInstructions'
        criteria:
          type: array
          minItems: 2
          items:
            type: string
    DecisionImage:
      type: object
      required:
        - content_type
        - base64
      properties:
        content_type:
          type: string
          enum:
            - image/png
            - image/jpeg
            - image/webp
        base64:
          type: string
          pattern: ^[A-Za-z0-9+/]+={0,2}$
    DebugOptions:
      type: object
      description: >-
        عناصر تحكم تصحيح أخطاء البوابة. لا تُمرر هذه العلامات إلى المزوّد
        مطلقًا.
      properties:
        enabled:
          type: boolean
        return_upstream_request:
          type: boolean
        return_upstream_response:
          type: boolean
        trace:
          type: boolean
        trace_level:
          type: string
          enum:
            - summary
            - full
    ProviderRoutingOptions:
      type: object
      description: تفضيلات توجيه المزوّد لاختياره عبر البوابة.
      properties:
        order:
          type: array
          items:
            type: string
        only:
          type: array
          items:
            type: string
        ignore:
          type: array
          items:
            type: string
        include_alpha:
          type: boolean
          description: تضمين مزوّدي alpha في التوجيه (معطّل افتراضيًا).
        allow_fallbacks:
          type: boolean
          nullable: true
          description: السماح بالتحويل إلى مزوّد مؤهل آخر بعد الفشل.
        require_parameters:
          type: boolean
          nullable: true
          description: اشتراط دعم المزوّد للمعلمات المطلوبة قبل التوجيه.
        required_execution_region:
          type: string
          nullable: true
          description: قصر التوجيه على المزوّدين الذين لديهم منطقة التنفيذ المطلوبة.
        required_data_region:
          type: string
          nullable: true
          description: قصر التوجيه على المزوّدين الذين لديهم منطقة البيانات المطلوبة.
        require_zero_data_retention:
          type: boolean
          nullable: true
          description: >-
            قصر التوجيه على المزوّدين الذين يدعمون الاحتفاظ بالبيانات لمدة
            صفرية.
        data_collection:
          type: string
          nullable: true
          enum:
            - allow
            - deny
        zdr:
          type: boolean
          nullable: true
        enforce_distillable_text:
          type: boolean
          nullable: true
        quantizations:
          type: array
          nullable: true
          items:
            type: string
        sort:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
          description: >-
            رتّب المزوّدين لهذا الطلب، مثلاً حسب السعر أو زمن الاستجابة أو معدل
            النقل.
        max_price:
          type: object
          properties:
            prompt:
              oneOf:
                - type: number
                - type: string
            completion:
              oneOf:
                - type: number
                - type: string
            image:
              oneOf:
                - type: number
                - type: string
            audio:
              oneOf:
                - type: number
                - type: string
            request:
              oneOf:
                - type: number
                - type: string
        preferred_min_throughput:
          oneOf:
            - type: number
            - type: object
              additionalProperties:
                type: number
        preferred_max_latency:
          oneOf:
            - type: number
            - type: object
              additionalProperties:
                type: number
    DecisionsUsage:
      type: object
      properties:
        input_tokens:
          type: integer
          minimum: 0
        output_tokens:
          type: integer
          minimum: 0
        total_tokens:
          type: integer
          minimum: 0
    DecisionInstructions:
      oneOf:
        - type: string
        - type: object
          additionalProperties: true
        - type: array
          items: {}
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: المصادقة باستخدام رمز Bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.