メインコンテンツまでスキップ

LLMクイックスタート

この​ガイドでは、​Shisa LLMに​対して​最初の​チャット補完を​行います。​APIキーが​必要です — Shisaプラットフォームで​作成してください。​新規アカウントには10ドル分の​無料クレジットが​含まれます。

1. エンドポイントと​キーを​設定する

Shisa LLMは​OpenAI互換です。​任意の​OpenAIクライアントを​Shisaの​ベースURLに​向け、​ベアラートークンで​認証します。

Base URL: https://api.shisa.ai/openai/v1
Auth: Authorization: Bearer YOUR_API_KEY
Model: shisa-ai/shisa-v2.1-llama3.3-70b
ヒント

APIキーは​ソース管理に​含めないでください。​実際の​アプリケーションでは、​環境変数​(例えばSHISA_API_KEY)から​読み込んでください。

2. リクエストを​行う

curl
curl -XPOST https://api.shisa.ai/openai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "shisa-ai/shisa-v2.1-llama3.3-70b",
"stream": true,
"messages": [
{
"role": "system",
"content": "You are a helpful assistant fluent in Japanese and English."
},
{
"role": "user",
"content": "日本の四季について教えてください。"
}
],
"temperature": 0.7
}'
Python
from openai import OpenAI

# Initialize client with Shisa AI endpoint
client = OpenAI(
base_url="https://api.shisa.ai/openai/v1",
api_key="YOUR_API_KEY"
)

def chat_with_shisa(message, model="shisa-ai/shisa-v2.1-llama3.3-70b"):
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": message}
],
stream=True,
temperature=0.7
)

for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)

# Example usage
chat_with_shisa("東京でおすすめの観光スポットを教えてください。")
Node.js
import OpenAI from 'openai';

const client = new OpenAI({
baseURL: 'https://api.shisa.ai/openai/v1',
apiKey: 'YOUR_API_KEY',
});

async function chatWithShisa(message) {
const stream = await client.chat.completions.create({
model: 'shisa-ai/shisa-v2.1-llama3.3-70b',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: message }
],
stream: true,
temperature: 0.7,
});

for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content || '';
process.stdout.write(content);
}
}

// Example usage
await chatWithShisa('日本語で自己紹介をしてください。');

3. レスポンスを​読み取る

"stream": trueの​場合、​APIは​Server-Sent Eventsを​返します。​各イベントはchoices[0].delta.contentに​トークンを​含みます。"stream": falseを​設定すると、​完全な​メッセージがchoices[0].message.contentに​含まれる​単一の​JSONレスポンスを​受け取ります。​レスポンスの​形式は​OpenAI Chat Completions APIと​一致します — 完全な​スキーマに​ついてはチャット補完リファレンスを​参照してください。

次の​ステップ

  • モデルで​ワークロードに​適した​モデルを​選びましょう。
  • チャット補完リファレンスで​サポートされている​すべての​パラメータを​確認しましょう。
  • 認証で​サービス間の​認証ヘッダー規約を​学びましょう。