Source: https://aiprimetech.io/ja/docs/guides/migration-from-anthropic/ [ホーム](/ja/) / [ドキュメント](/ja/docs/) / Anthropic APIからの移行 # Anthropic APIからの移行 設定値を変更して、既存のAnthropic SDKベースのコードベースを移行します。 ページをコピー [ Markdownで表示](/ja/docs/guides/migration-from-anthropic.md) [ ChatGPTに質問](https://chatgpt.com/?q=Read%20https%3A//aiprimetech.io/docs/guides/migration-from-anthropic.md%20and%20answer%20questions%20about%20it.%20Start%20with%20a%20short%20summary.) [ Claudeで質問](https://claude.ai/new?q=Read%20https%3A//aiprimetech.io/docs/guides/migration-from-anthropic.md%20and%20answer%20questions%20about%20it.%20Start%20with%20a%20short%20summary.) ゲートウェイはMessages形式に対応しているため、移行は設定の変更だけで済みます。リクエストボディ、レスポンスの解析、ストリーミングハンドラー、ツール定義はすべてそのまま使えます。 ## Python ``` Copyfrom anthropic import Anthropic client = Anthropic( api_key=class="s">"sk-your-gateway-key", class=class="s">"c"># was your Anthropic key base_url=class="s">"https://aiprimetech.io", class=class="s">"c"># new line ) class=class="s">"c"># everything below is unchanged ``` ## TypeScript ``` Copyimport Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic({ apiKey: process.env.CLAUDEAPIKEY, baseURL: "https:">//aiprimetech.io", }); ``` ## 環境変数だけで移行 ``` Copyexport ANTHROPIC_BASE_URL="https://aiprimetech.io" export ANTHROPIC_API_KEY="sk-your-gateway-key" ``` ## 移行チェックリスト - ベースURLとキーを変更してください。Anthropicクライアントでは /v1 サフィックスは不要です。 - モデルIDを対応付けてください。参照先: [モデル](/ja/docs/getting-started/models/)。IDは固定されているため、 claude-3-5-sonnet-20241022 形式の名前を使う古い連携では、現在のIDへの更新が必要です。 - テストスイートを再実行してください。レスポンスの構造は同一なので、問題が発生した場合はモデルIDまたはベースURLが原因です。 - ストリーミングを使っている場合は確認してください。イベントの構造は変わりませんが、プロキシや許可リストにハードコードされたホスト名は更新が必要です。 - まずはサービスをひとつ移行し、出力を比較してから全体を切り替えてください。 ## 引き継がれないもの - Anthropic Consoleの機能であるワークベンチ、組織の請求管理、ワークスペースごとの制限はAnthropicの製品であり、ここには同等の機能はありません。 - Batch APIと、このゲートウェイで公開されていないベータ機能。確認先: [概要](/ja/docs/api-reference/overview/) 。現在のエンドポイント一覧を確認してください。 - 契約条件。Anthropicが署名したDPAやSLAが必要な場合は、公式APIを引き続き利用してください。 [ベースURLサフィックスのルール](/ja/docs/getting-started/base-urls/)[モデルIDの対応付け](/ja/docs/getting-started/models/)[Python SDK完全な例](/ja/docs/sdks/python/) [前へコンテキスト管理](/ja/docs/guides/context-management/)[次へOpenAI APIからの移行](/ja/docs/guides/migration-from-openai/)