# Anthropic SDK > Python と TypeScript の公式 Anthropic クライアントから Kiln を呼び出す方法です。/v1 を含まない base URL、content[0] が thinking ブロックである理由、usage オブジェクトに入る値と入らない値を説明します。 Source: https://kiln.bricksum.com/docs/ja/sdks/anthropic Kiln は Anthropic Messages API も提供しているため、公式の Anthropic クライアントはプロキシもルーターも挟まずに接続できます。設定のうち 2 点が Kiln に固有です。 ## インストール **Python** ```bash pip install anthropic ``` **TypeScript** ```bash npm install @anthropic-ai/sdk ``` ## 接続 **Python** ```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) ``` **TypeScript** ```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 リファレンス](https://kiln.bricksum.com/docs/ja/api-reference)に一度だけまとめています。 上の呼び出しが到達するエンドポイントは [Messages](https://kiln.bricksum.com/docs/ja/api-reference/messages)です。 モデル ID は API が現在提供しているものである必要があります。一覧の取得方法と、目的の ID が一覧にない場合の対処は [モデル](https://kiln.bricksum.com/docs/ja/models) のページにあります。 SDK に関係なくこのモデルが対応していない機能は [OpenAI からの移行](https://kiln.bricksum.com/docs/ja/migrating-from-openai) のページにまとめています。 メモ このページのスニペットは 2026-09-21 に anthropic 1.7.0 (Python), @anthropic-ai/sdk 0.127.0 (Node) の環境で Kiln API に対して実行し、動作を確認しています。 未確認の項目: その実行は gpt-oss-120b で行いました。ページは現在 qwen3-32b を使っており、このモデルではまだ再実行していません。