Claude api code: quickstart guide
base URLを1つ変更するだけで、Claude APIコード統合をOpenAI互換クライアントに組み込めます。この無制限LLMプロキシは、制限のないコード生成と大量の使用に最適化された専用モデルにリクエストをルーティングします。
ベースURLと認証
クライアント設定を更新し、ホストエンドポイントへ向けることから始めます。 base_url HTTPS://api.claudeapicode.com/v1 キーを Authorization ヘッダー。このプロキシは標準的なOpenAI SDKと互換性があり、カスタムドライバの必要はありません。ダッシュボードでGoogleまたはメールアドレスを使用して即座にキーを生成でき、電話番号は不要です。
curl https://api.claudeapicode.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Set up a PostgreSQL connection pool with ten connections"}]
}'
チャット完了エンドポイント
にリクエストを送信します /v1/chat/completions モデルID uncensored. このエンドポイントは標準的なチャットメッセージを受け取り、テキスト応答を返します。公式プラットフォームの制限なしに、コードセッションのトークン処理をすべて処理します。利用可能なモデルは、 /v1/models 接続を確認するために使用します。
from openai import OpenAI
client = OpenAI(base_url="https://api.claudeapicode.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.claudeapicode.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);ストリーミング
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)