# יצירת הודעת Claude

**API:** Model API

**Endpoint:** `POST /api/v1/messages`

נקודת קצה תואמת Claude Messages API. הגדירו stream=true כדי לקבל אירועי זרם הודעות בסגנון Claude. שדות הבקשה, התגובה ושגיאות האימות עוקבים אחר פרוטוקול Claude Messages; ה-Router עשוי גם להחזיר מעטפת שגיאת gateway מסוננת עבור כשלי תשתית.

## Base URL

- `https://openapi.felo.ai` — פרודקשן

## Authentication

- `FeloBearerAuth` (http bearer) — מפתח API של Felo נשלח בכותרת `Authorization: Bearer <key>`.
- `FeloApiKey` (apiKey in header `X-API-Key`) — מפתח API של Felo נשלח בכותרת `X-API-Key: <key>`.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `X-Felo-Channel` | header | no | string, default: "default" | קודי ערוץ ציבורי מופרדים בפסיקים ובסדר מוגדר. השמיטו את הכותרת כדי להשתמש ב-default; אסור להשתמש ב-default יחד עם ערכים אחרים. במצב ארנק, default סורק את סדר הערוצים הציבוריים האפקטיבי של המודל מהסוף להתחלה, מדלג על ערוצים לא מפורסמים או לא זמינים, ובוחר את הספק של הערוץ הזמין הראשון. הוא כולל נקודות קצה זמינות מאותו ספק עם אותו מזהה מודל חיצוני ואותה דרגת שירות. ערוצים מפורשים מאומתים לפי הסדר שהלקוח ציין; רק קבוצת הספק של הערוץ הראשון נשלחת. אין נפילה אוטומטית לספקים אחרים. כותרות ספק מדור קודם אינן יכולות לעקוף את ניתוב הערוצים. |

## Request body

Required: **yes**

### application/json

Schema: `ClaudeMessagesRequest` (`#/components/schemas/ClaudeMessagesRequest`)

```json
{
  "type": "object",
  "required": [
    "model",
    "max_tokens",
    "messages"
  ],
  "properties": {
    "model": {
      "type": "string"
    },
    "max_tokens": {
      "type": "integer",
      "minimum": 1
    },
    "messages": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/components/schemas/ClaudeMessage"
      },
      "description": "Use a document block for a PDF or an image block for a picture. Set source to {type: 'file', file_id: 'felo_file_...'} for an uploaded Felo attachment, {type: 'url', url: 'https://...'} for an HTTPS URL, or provide type, media_type and data for a base64 source. PDF and image URL support are enabled per model."
    },
    "system": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      ]
    },
    "stream": {
      "type": "boolean",
      "default": false
    },
    "temperature": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "top_p": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "top_k": {
      "type": "integer",
      "minimum": 0
    },
    "stop_sequences": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "tools": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "tool_choice": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "additionalProperties": true
        }
      ]
    },
    "metadata": {
      "type": "object",
      "additionalProperties": true
    },
    "thinking": {
      "type": "object",
      "additionalProperties": true
    },
    "service_tier": {
      "type": [
        "string",
        "null"
      ],
      "default": "default",
      "description": "נכון לעכשיו נתמך רק default (סטנדרטי). ערך שהושמט, null, כינויים ומחרוזות לא נתמכות נופלים חזרה ל-default; סוגים אחרים מחזירים HTTP 400. הערוצים והמחירים המוגדרים נשארים ללא שינוי. ממשקי טקסט שולחים את הערך הסטנדרטי של הספק; ממשקי Decisions ויצירה משמיטים את השדה מהבקשה לספק."
    }
  },
  "additionalProperties": true
}
```

Example:

```json
{
  "model": "claude-sonnet-4-5",
  "max_tokens": 256,
  "messages": [
    {
      "role": "user",
      "content": "Write a one-sentence greeting."
    }
  ],
  "stream": false
}
```

## Responses

### 200 — הודעת Claude או תגובת סטרימינג

**application/json**

Schema: `ClaudeMessageResponse` (`#/components/schemas/ClaudeMessageResponse`)

**text/event-stream**

Schema: string

```json
{
  "type": "string",
  "description": "אירועי SSE של Claude Messages."
}
```

### 400 — שגיאת invalid_request_error של Claude או שגיאת אימות בקשה של ה-Router

**application/json**

Schema: `ClaudeErrorResponse` (`#/components/schemas/ClaudeErrorResponse`)

### 401 — מפתח API של Felo לא חוקי או חסר

**application/json**

Schema: `ClaudeErrorResponse` (`#/components/schemas/ClaudeErrorResponse`)

### 402 — יתרה לא מספקת

**application/json**

Schema: `ClaudeErrorResponse` (`#/components/schemas/ClaudeErrorResponse`)

### 403 — החשבון אינו מורשה להשתמש במודל. מודלים מושבתים נדחים גם הם לפני קריאות לספק החיצוני. בקשות ומשימות שכבר התקבלו ממשיכות.

**application/json**

Schema: `ClaudeErrorResponse` (`#/components/schemas/ClaudeErrorResponse`)

### 429 — הגעתם למגבלת הוצאות או בקשות

**application/json**

Schema: `ClaudeErrorResponse` (`#/components/schemas/ClaudeErrorResponse`)

### 502 — בקשת הספק החיצוני נכשלה

**application/json**

Schema: `ClaudeErrorResponse` (`#/components/schemas/ClaudeErrorResponse`)

### 503 — הספק או שירות החיוב אינם זמינים

**application/json**

Schema: `ClaudeErrorResponse` (`#/components/schemas/ClaudeErrorResponse`)

## Schema definitions

### ClaudeContentBlock

`#/components/schemas/ClaudeContentBlock`

```json
{
  "type": "object",
  "required": [
    "type"
  ],
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "text",
        "image",
        "document",
        "tool_use",
        "tool_result",
        "thinking"
      ]
    },
    "text": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "input": {
      "type": "object",
      "additionalProperties": true
    },
    "content": {
      "type": [
        "string",
        "array"
      ]
    },
    "source": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
```

### ClaudeErrorResponse

`#/components/schemas/ClaudeErrorResponse`

```json
{
  "type": "object",
  "description": "מעטפת שגיאה תואמת Claude Errors API עבור בקשות Messages.",
  "required": [
    "type",
    "error"
  ],
  "properties": {
    "type": {
      "type": "string",
      "const": "error"
    },
    "error": {
      "type": "object",
      "required": [
        "type",
        "message"
      ],
      "properties": {
        "type": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "request_id": {
      "type": "string"
    }
  },
  "additionalProperties": true
}
```

### ClaudeMessage

`#/components/schemas/ClaudeMessage`

```json
{
  "type": "object",
  "required": [
    "role",
    "content"
  ],
  "properties": {
    "role": {
      "type": "string",
      "enum": [
        "user",
        "assistant"
      ]
    },
    "content": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/ClaudeContentBlock"
          }
        }
      ]
    }
  },
  "additionalProperties": true
}
```

### ClaudeMessageResponse

`#/components/schemas/ClaudeMessageResponse`

```json
{
  "type": "object",
  "required": [
    "id",
    "type",
    "role",
    "content",
    "model",
    "stop_reason"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "const": "message"
    },
    "role": {
      "type": "string",
      "const": "assistant"
    },
    "content": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/ClaudeContentBlock"
      }
    },
    "model": {
      "type": "string"
    },
    "stop_reason": {
      "type": [
        "string",
        "null"
      ]
    },
    "stop_sequence": {
      "type": [
        "string",
        "null"
      ]
    },
    "usage": {
      "$ref": "#/components/schemas/Usage"
    }
  },
  "additionalProperties": true
}
```

### Usage

`#/components/schemas/Usage`

```json
{
  "type": "object",
  "description": "אובייקט שימוש של הספק. השדות משתנים לפי נקודת הקצה והספק.",
  "additionalProperties": true
}
```
