BazaarLinkBazaarLink
로그인
문서API 레퍼런스SDK 레퍼런스에이전트 사용법AI 스킬
Messages (Anthropic)

메시지 생성

Anthropic 네이티브 /v1/messages 형식으로 모델 응답을 요청합니다. BazaarLink는 Anthropic 자체 모델뿐 아니라 지원되는 모든 모델로 라우팅합니다. 공식 Anthropic SDK의 base_url을 BazaarLink로 지정하면 기존 코드가 변경 없이 그대로 동작합니다. Authorization: Bearer 또는 Anthropic SDK 관례인 x-api-key 헤더 모두 인증에 사용할 수 있습니다. 해석된 모델이 네이티브 Anthropic이 아니면 BazaarLink가 요청/응답을 투명하게 변환하며, 가능한 한 tool_use 블록과 stop_reason 의미를 유지합니다.

POST/api/v1/messages

인증

Authorization필수
string · header

Authorization 헤더에 Bearer 토큰으로 API 키를 전달합니다.

Body

model필수
string

사용할 모델. 공급자 접두사 형식, 예: "anthropic/claude-sonnet-4.6".

minLength: 1
Example: "anthropic/claude-sonnet-4.6"
messages필수
Message[]

대화 메시지 배열, 최소 하나. 각 메시지는 role(user/assistant)과 content(문자열 또는 text/image/tool_use/tool_result 같은 콘텐츠 블록 배열)를 가집니다.

minLength: 1
max_tokens필수
integer

응답이 생성할 수 있는 최대 토큰 수. OpenAI 호환 엔드포인트와 달리 Anthropic 형식에서는 이 필드가 필수입니다.

positive integer
Example: 1024
system
string | ContentBlock[]

시스템 프롬프트 — messages 배열 안의 메시지가 아니라 별도의 최상위 필드입니다(OpenAI 형식과의 주요 차이점 중 하나).

stream
boolean

true이면 SSE로 응답을 스트리밍합니다(message_start / content_block_delta / message_delta / message_stop 이벤트). 생략하거나 false이면 단일 JSON 응답을 반환합니다.

temperature
number

샘플링 온도 — 높을수록 무작위성이 커지고 낮을수록 결정적입니다. BazaarLink가 검증하지 않으며 업스트림으로 그대로 전달됩니다. 해석된 모델이 네이티브 Anthropic이 아니면 이 필드 처리 방식은 BazaarLink의 변환 레이어에 따라 달라집니다.

0–1
top_p
number

핵 샘플링(nucleus sampling) 임계값. BazaarLink가 검증하지 않으며 업스트림으로 그대로 전달됩니다. 해석된 모델이 네이티브 Anthropic이 아니면 이 필드 처리 방식은 BazaarLink의 변환 레이어에 따라 달라집니다.

0–1
top_k
integer

샘플링을 확률이 가장 높은 K개의 토큰으로 제한합니다. BazaarLink가 검증하지 않으며 업스트림으로 그대로 전달됩니다. 해석된 모델이 네이티브 Anthropic이 아니면 이 필드 처리 방식은 BazaarLink의 변환 레이어에 따라 달라집니다.

stop_sequences
string[]

생성이 중단되는 문자열 배열. BazaarLink가 검증하지 않으며 업스트림으로 그대로 전달됩니다. 해석된 모델이 네이티브 Anthropic이 아니면 이 필드 처리 방식은 BazaarLink의 변환 레이어에 따라 달라집니다.

tools
Tool[]

모델이 호출할 수 있는 도구 정의 목록, Anthropic 형식(name, description, input_schema). BazaarLink가 검증하지 않으며 업스트림으로 그대로 전달됩니다. 해석된 모델이 네이티브 Anthropic이 아니면 이 필드 처리 방식은 BazaarLink의 변환 레이어에 따라 달라집니다.

tool_choice
object

모델이 도구 호출을 강제받는지/어떻게 강제받는지 제어합니다. 예: {type:"auto"}, {type:"any"}, {type:"tool", name:"..."}. BazaarLink가 검증하지 않으며 업스트림으로 그대로 전달됩니다. 해석된 모델이 네이티브 Anthropic이 아니면 이 필드 처리 방식은 BazaarLink의 변환 레이어에 따라 달라집니다.

thinking
object

확장 사고 제어 객체, 예: {type:"enabled", budget_tokens:2048}. 추론 모델에서만 의미가 있습니다. BazaarLink가 검증하지 않으며 업스트림으로 그대로 전달됩니다. 해석된 모델이 네이티브 Anthropic이 아니면 이 필드 처리 방식은 BazaarLink의 변환 레이어에 따라 달라집니다.

metadata
object

요청 메타데이터, 예: {user_id:"..."}. 모니터링 및 남용 감지에 사용되며 과금에는 영향이 없습니다. BazaarLink가 검증하지 않으며 업스트림으로 그대로 전달됩니다. 해석된 모델이 네이티브 Anthropic이 아니면 이 필드 처리 방식은 BazaarLink의 변환 레이어에 따라 달라집니다.

POST /api/v1/messages
curl https://bazaarlink.ai/api/v1/messages \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4.6",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
응답 예시

성공. 기본값(또는 stream: false)은 아래의 Anthropic 네이티브 Message 객체를, stream: true면 SSE 이벤트 스트림(message_start / content_block_delta / message_delta / message_stop — 프로토콜은 심층 가이드 참조)을 반환합니다. model은 항상 요청한 이름을 그대로 반환합니다(실제로 해석된 업스트림 모델이 아님). usage는 Anthropic 네이티브 필드(input_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens)를 유지하며 cost/bz_cost(BazaarLink 자체 정산 금액)가 추가됩니다 — 업스트림에서 전달된 원가가 아닙니다.

{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-sonnet-4.6",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you today?"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 10,
    "output_tokens": 12,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cost": 0.000186,
    "bz_cost": 0.000186
  }
}
Support
Support
Hi! How can we help you?
Send a message and we'll get back to you soon.
메시지 생성 — BazaarLink API