OpenAI互換APIドキュメント
標準的なOpenAI互換クライアントを使用して数分で無修正LLM APIを始めます。このクイックスタートでは、認証、最初のリクエスト、ストリーミング設定についてガイドします。
認証 & ベースURL
ダッシュボードからキーを生成することから始めましょう。ベースURLとしてHTTPS://api.keyapiseekdeep.com/v1を使用し、キーをAuthorizationヘッダーに渡してください。この設定は標準のSDKと互換性があります。
curl https://api.keyapiseekdeep.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "What is my API key expiration date"}]
}'あなたのキーはアカウントごとに一意であり、以前のキーはすぐに置き換えられます。
Pythonを使用した最初のリクエスト
公式のPython SDKを使用してテキスト完了を送信します。ベースURLをエンドポイントに設定し、モデルID "uncensored" を使用します。
from openai import OpenAI
client = OpenAI(base_url="https://api.keyapiseekdeep.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.keyapiseekdeep.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)