본문으로 건너뛰기
alpharouter

개발 문서

Messages API

Anthropic 네이티브 형식을 그대로 받는 경로입니다. Claude SDK를 쓰던 코드는 base_url만 바꾸면 됩니다.

요청 형식

system을 최상위 필드로 받고 max_tokens가 필수입니다. 이 두 가지가 Chat Completions와 다릅니다.

FieldTypeRequiredNote
modelstringYesModel ID or route path
messagesarrayYesuser, assistant
systemstringNoTop-level field
max_tokensintegerYesRequired on this path

라우팅 동작

이 경로에서도 라우팅 경로를 쓸 수 있지만, 후보는 Messages 형식을 지원하는 모델로 한정됩니다.

콘텐츠 블록

응답 content는 블록 배열입니다. text와 tool_use 블록이 순서대로 담깁니다.

usage와 캐시 쓰기

cache_control로 캐시를 쓴 요청은 usage.cache_creation에 TTL별 토큰 수(ephemeral_5m_input_tokens, ephemeral_1h_input_tokens)가 함께 옵니다. cache_creation_input_tokens는 두 값의 합계이고, 1시간 캐시 쓰기는 5분 캐시 쓰기와 다른 단가로 청구됩니다.

스트림 취소와 청구

스트리밍 도중 연결을 끊어도 업스트림 생성은 계속될 수 있습니다. 게이트웨이는 정해진 시간·출력 한도 안에서 응답을 끝까지 읽고, 업스트림이 보고한 최종 사용량으로 청구합니다. 한도에 걸리면 그때까지 생성된 분량을 추정해 청구합니다.