# Claude پیغام بنائیں

**API:** Model API

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

Claude Messages API سے مطابقت رکھنے والا endpoint۔ Claude طرز کے پیغام اسٹریم ایونٹس وصول کرنے کے لیے stream=true سیٹ کریں۔ درخواست، جواب اور تصدیقی خرابی کے فیلڈز Claude Messages پروٹوکول کی پیروی کرتے ہیں؛ Router انفراسٹرکچر کی ناکامیوں پر صاف شدہ گیٹ وے خرابی کا لفافہ بھی واپس کر سکتا ہے۔

## Base URL

- `https://openapi.felo.ai` — پروڈکشن

## Authentication

- `FeloBearerAuth` (http bearer) — Felo API کلید جو `Authorization: Bearer <key>` کے طور پر بھیجی جاتی ہے۔
- `FeloApiKey` (apiKey in header `X-API-Key`) — Felo API کلید جو `X-API-Key: <key>` کے طور پر بھیجی جاتی ہے۔

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `X-Felo-Channel` | header | no | string, default: "default" | ترتیب شدہ، کوما سے الگ کیے گئے پبلک چینل کوڈز۔ default استعمال کرنے کے لیے یہ ہیڈر چھوڑ دیں؛ default کو تنہا ہی استعمال کرنا ہوگا۔ wallet موڈ میں default ماڈل کے مؤثر پبلک چینل کی ترتیب کو الٹی سمت میں اسکین کرتا ہے، غیر شائع شدہ یا غیر دستیاب چینلز کو نظر انداز کرتا ہے، اور پہلے دستیاب چینل کے پرووائیڈر کا انتخاب کرتا ہے۔ اس میں اسی اپ اسٹریم ماڈل ID اور سروس ٹیئر والے اس پرووائیڈر کے دستیاب endpoints شامل کیے جاتے ہیں۔ واضح چینلز کی توثیق کلائنٹ کی بتائی ہوئی ترتیب میں ہوتی ہے؛ صرف پہلے چینل کا پرووائیڈر گروپ جمع کیا جاتا ہے۔ دیگر پرووائیڈرز کی طرف کوئی خودکار fallback نہیں ہے۔ پرانے پرووائیڈر ہیڈرز چینل روٹنگ کو اوور رائیڈ نہیں کر سکتے۔ |

## 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 (standard) معاون ہے۔ چھوڑا گیا، null، عرفی نام اور غیر معاون اسٹرنگز default پر fallback کرتے ہیں؛ دیگر اقسام HTTP 400 واپس کرتی ہیں۔ ترتیب شدہ چینلز اور قیمتیں تبدیل نہیں ہوتیں۔ Text APIs پرووائیڈر کی standard قدر بھیجتے ہیں؛ Decisions اور generation APIs اپ اسٹریم فیلڈ شامل نہیں کرتے۔"
    }
  },
  "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": "Claude Messages کے SSE ایونٹس۔"
}
```

### 400 — Claude کا invalid_request_error یا Router کی درخواست کی تصدیق کی خرابی

**application/json**

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

### 401 — غلط یا غیر موجود Felo API کلید

**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": "Messages درخواستوں کے لیے Claude Errors API سے مطابقت رکھنے والا خرابی کا لفافہ۔",
  "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": "پرووائیڈر کا استعمال آبجیکٹ۔ فیلڈز endpoint اور پرووائیڈر کے لحاظ سے مختلف ہوتے ہیں۔",
  "additionalProperties": true
}
```
