---
title: "curl 호출"
description: "어떤 SDK도 설치하지 않고 curl로 1折AI의 /v1/messages와 /v1/chat/completions를 호출하고, 모델 목록 조회, 캐시 테스트, 스트리밍 출력 확인하기."
headingIds: {"Anthropic 네이티브: /v1/messages":"section-1","OpenAI 호환: /v1/chat/completions":"section-2","모델 목록: /v1/models":"section-3","스트리밍 출력":"section-4","캐시 테스트":"section-5","문제 해결 시 -i 추가":"section-6"}
---

<aside className="docs-publication" data-pagefind-ignore>

[1ZheAI](https://1zheai.com/en/editorial/#publisher)가 관리하는 문서입니다. [출처 및 수정 사항](https://1zheai.com/en/editorial/).

오류를 발견하셨나요? 페이지 주소와 설명을 첨부하여 [고객 지원](mailto:support@1zheai.com)으로 문의해 주세요. API 키나 계정 정보는 보내지 마세요.

</aside>
curl은 "API 키(API key)와 주소가 실제로 통하는지" 확인하는 가장 빠른 방법입니다. 아래 각 명령어는 그대로 복사해서 사용할 수 있으며, 먼저 API 키를 환경 변수에 넣으세요:

```bash
export ONEZHE_API_KEY="sk-你的Key"
```

Windows 사용자는 WSL 또는 Git Bash에서 이 명령어들을 실행하는 것을 권장합니다. PowerShell 작성법은[빠른 시작](/ko/docs/quickstart/)을 참조하세요.

## Anthropic 네이티브: /v1/messages

```bash
curl https://1zheai.com/v1/messages \
  -H "x-api-key: $ONEZHE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 128,
    "messages": [{"role": "user", "content": "ping"}]
  }'
```

## OpenAI 호환: /v1/chat/completions

```bash
curl https://1zheai.com/v1/chat/completions \
  -H "Authorization: Bearer $ONEZHE_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "messages": [{"role": "user", "content": "ping"}]
  }'
```

## 모델 목록: /v1/models

```bash
curl https://1zheai.com/v1/models \
  -H "Authorization: Bearer $ONEZHE_API_KEY"
```

## 스트리밍 출력

`"stream": true`을 추가하고 `-N`으로 curl의 버퍼링을 끄면 청크별로 반환되는 내용을 볼 수 있습니다:

```bash
curl -N https://1zheai.com/v1/messages \
  -H "x-api-key: $ONEZHE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 128,
    "stream": true,
    "messages": [{"role": "user", "content": "从一数到五"}]
  }'
```

이벤트 형식은[스트리밍 출력](/ko/docs/streaming/)을 참조하세요.

## 캐시 테스트

같은 요청을 두 번 연속으로 보냈을 때 두 번째 응답의 `usage.cache_read_input_tokens`이 0보다 크면 캐시에 적중한 것입니다. `system`의 텍스트는 모델의 최소 캐시 가능 길이에 도달해야 합니다. 전체 스크립트는[모델 및 사용량 확인](/ko/docs/verify-model/), 원리는 [Prompt Caching](/ko/docs/prompt-caching/)을 참조하세요.

```bash
curl https://1zheai.com/v1/messages \
  -H "x-api-key: $ONEZHE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 32,
    "system": [{
      "type": "text",
      "text": "把一段至少 512 token、每次都一样的长文本放在这里",
      "cache_control": {"type": "ephemeral"}
    }],
    "messages": [{"role": "user", "content": "ping"}]
  }'
```

## 문제 해결 시 -i 추가

```bash
curl -i https://1zheai.com/v1/models -H "Authorization: Bearer $ONEZHE_API_KEY"
```

`-i`은 상태 코드와 응답 헤더를 출력합니다. 상태 코드 의미는[오류 코드 및 문제 해결](/ko/docs/troubleshooting/)을 참조하세요.
