# DeepSeek V4.1 Flash — /chat/completions

DeepSeek의 현재 Flash 모델인 DeepSeek V4.1 Flash를 기반으로 한 OpenAI 호환 채팅 완성 API입니다. 사고 모드가 기본으로 켜져 있으며 추론 과정은 message.reasoning_content로 반환되고, thinking={"type":"disabled"}를 보내면 끌 수 있습니다. 추론 토큰은 usage.completion_tokens 안에서 출력 단가로 과금됩니다. 도구 호출과 스트리밍을 지원합니다. model을 deepseek-v4.1-flash로 지정하세요. /v1/chat/completions에서만 제공됩니다.

**엔드포인트:** `POST https://nezhagate.com/v1/chat/completions`

## 인증
```
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

## 요청 본문
| 파라미터 | 타입 | 필수 | 설명 |
| --- | --- | --- | --- |
| `model` | string | 예 | 모델 ID. 여기서는 deepseek-v4.1-flash입니다. |
| `messages` | array | 예 | 메시지 배열. 각 항목은 role(system/user/assistant)과 content를 가집니다. content는 문자열이거나, 이미지 이해(멀티모달 / 비전)를 위한 {type:text}와 {type:image_url} 조각들의 배열일 수 있습니다. |
| `stream` | boolean | 아니오 | SSE로 스트리밍할지 여부. 기본값 false. |
| `temperature` | number | 아니오 | 샘플링 온도, 0–2. |
| `max_tokens` | integer | 아니오 | 생성할 최대 토큰 수. |
| `web_search` | boolean | 아니오 | true로 두면 웹 검색이 켜집니다. 게이트웨이가 모델이 답하기 전에 실시간 검색 결과로 프롬프트를 보강하고 출처를 함께 제시합니다. tools 항목 {"type":"web_search"}로도 켤 수 있습니다. |
| `thinking` | object | 아니오 | 사고 모드 스위치: {"type": "disabled"}를 보내면 사고를 끄고 더 빠르게, 더 적은 출력 토큰으로 바로 답합니다. 생략하면 사고 모드가 켜져 있고 추론 과정은 message.reasoning_content로 반환됩니다. |

## 요청 예시
```bash
curl https://nezhagate.com/v1/chat/completions -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "deepseek-v4.1-flash", "messages": [{"role": "user", "content": "Hello"}], "stream": false}'
```

## 응답
```json
{
  "id": "chatcmpl_xxx",
  "object": "chat.completion",
  "model": "deepseek-v4.1-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "reasoning_content": "The user is greeting me, so a short friendly reply fits...",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 42,
    "total_tokens": 51,
    "completion_tokens_details": {"reasoning_tokens": 31}
  }
}
```

## 이미지 입력 (Vision)
메시지 content 배열에 이미지를 넣으면 모델이 이를 분석합니다(시각적 질의응답, 텍스트 판독 / OCR 등). image_url에는 공개 이미지 링크 또는 인라인 base64 data URL(data:image/png;base64,...)을 넣을 수 있습니다. 멀티모달 모델(gpt-5.5, gemini 계열 등)에서 사용할 수 있습니다.

```bash
curl https://nezhagate.com/v1/chat/completions -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "deepseek-v4.1-flash", "messages": [{"role": "user", "content": [{"type": "text", "text": "What is in this image?"}, {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}]}]}'
```