Anthropic SDK
Kiln은 Anthropic Messages API도 제공하므로 공식 Anthropic 클라이언트가 프록시나 라우터 없이 바로 연결됩니다. 설정에서 Kiln에만 해당하는 항목이 두 가지 있습니다.
설치
bash
pip install anthropicbash
npm install @anthropic-ai/sdk연결
python
import os
from anthropic import Anthropic
client = Anthropic(
# The API origin, without /v1 — the SDK appends /v1/messages itself.
base_url="https://api.bricksum.com",
api_key=os.environ["KILN_API_KEY"], # sk-bk-...
)
message = client.messages.create(
model="qwen3-32b",
max_tokens=800,
messages=[{"role": "user", "content": "Write a haiku about kilns."}],
)
# content[0] is the model's thinking block, and a reply that ends in a tool
# call has no text block at all, so walk the blocks instead of indexing.
for block in message.content:
if block.type == "text":
print(block.text)javascript
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
// The API origin, without /v1 — the SDK appends /v1/messages itself.
baseURL: "https://api.bricksum.com",
apiKey: process.env.KILN_API_KEY, // sk-bk-...
});
const message = await client.messages.create({
model: "qwen3-32b",
max_tokens: 800,
messages: [{ role: "user", content: "Write a haiku about kilns." }],
});
// content[0] is the model's thinking block, and a reply that ends in a tool
// call has no text block at all, so walk the blocks instead of indexing.
for (const block of message.content) {
if (block.type === "text") console.log(block.text);
}Kiln에서 다른 점
- base URL에는 /v1을 붙이지 않음 Anthropic 클라이언트는 전달한 base URL 뒤에 /v1/messages를 직접 붙입니다. 따라서 값은 https://api.bricksum.com/v1이 아니라 https://api.bricksum.com입니다. 다른 Kiln SDK는 모두 /v1까지 포함한 base URL을 받습니다.
- content[0]은 thinking 블록 모델은 답하기 전에 reasoning을 수행하며, Kiln은 그 내용을 text 블록보다 앞선 thinking 블록으로 돌려줍니다. 그래서 content[0].text를 읽으면 값이 없습니다. type이 text인 블록을 골라 쓰세요.
- usage에는 cost가 없음 Anthropic 클라이언트는 max_tokens를 필수 인자로 두며 reasoning 토큰도 여기에 포함되므로 여유를 두세요. 예제의 800은 이 모델에서 측정하지 않은 시작값이므로, 응답의 stop_reason이 "max_tokens"이고 text 블록이 없으면 늘리세요. 돌아오는 값은 input_tokens, output_tokens, cache_read_input_tokens이며, OpenAI 형식 엔드포인트와 달리 이 API에는 cost 필드가 없습니다.
base URL, 인증, 모든 엔드포인트가 공유하는 요청 파라미터, 응답 형식, 스트리밍, 에러 코드는 어떤 SDK를 쓰든 같습니다. 이 내용은 API 레퍼런스에 한 번만 정리돼 있습니다. 위 호출이 도달하는 엔드포인트는 Messages입니다. 모델 ID는 API가 지금 서빙 중인 것이어야 합니다. 목록을 조회하는 방법과 원하는 ID가 목록에 없을 때 할 일은 모델 페이지에 있습니다. SDK와 무관하게 이 모델이 지원하지 않는 기능은 OpenAI에서 옮겨오기 페이지에 정리돼 있습니다.
참고
이 페이지의 스니펫은 2026-09-21에 anthropic 1.7.0 (Python), @anthropic-ai/sdk 0.127.0 (Node) 환경에서 Kiln API로 직접 실행해 확인했습니다. 확인하지 않은 부분: 그 실행은 gpt-oss-120b에서 했습니다. 페이지는 이제 qwen3-32b을 사용하며, 이 모델로는 아직 다시 실행하지 않았습니다.