# Claude 메시지 생성

**API:** Model API

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

Claude Messages API 호환 엔드포인트입니다. stream=true로 설정하면 Claude 스타일 메시지 스트림 이벤트를 받습니다. 요청, 응답, 검증 오류 필드는 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는 단독으로만 사용해야 합니다. 지갑 모드에서 default는 모델의 유효 공개 채널 순서를 역순으로 스캔하고, 게시되지 않았거나 사용할 수 없는 채널을 건너뛰며, 사용 가능한 첫 번째 채널의 공급자를 선택합니다. 동일한 업스트림 모델 ID와 서비스 티어를 가진 해당 공급자의 사용 가능한 엔드포인트도 포함합니다. 명시적 채널은 클라이언트가 지정한 순서로 검증되며, 첫 번째 채널의 공급자 그룹만 제출됩니다. 다른 공급자로의 자동 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(표준)만 지원합니다. 생략, null, 별칭 및 지원되지 않는 문자열은 default로 대체되며, 다른 유형은 HTTP 400을 반환합니다. 구성된 채널과 가격은 변경되지 않습니다. 텍스트 API는 공급자의 표준 값을 전송하고, Decisions 및 생성 API는 업스트림 필드를 생략합니다."
    }
  },
  "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": "공급자 사용량 객체입니다. 필드는 엔드포인트와 공급자에 따라 다릅니다.",
  "additionalProperties": true
}
```
