HaiChat API v2.1の新機能
最新のAPIバージョンで追加された新機能と改善点について詳しく解説します。
続きを読む →Developer Resources
申し訳ありません、只今準備中です。
開発に必要なすべてのリソースを提供します。API、SDK、サンプルコード、ドキュメントで、効率的な開発をサポートします。
最新のAI技術で、まるで人間と話しているかのような自然な会話をお楽しみください。
主要プログラミング言語に対応したSDKを提供。簡単にHaiChatプラットフォームを統合できます。
本番環境に影響を与えることなく、APIをテストできる仮想環境を提供します。
お好みのプログラミング言語のSDKをインストールします。
npm install haichat-sdk
簡単なAPIリクエストを送信して動作を確認します。
const client = new HaiChatClient('your-api-key');
// HaiChat SDK for JavaScript
const HaiChat = require('haichat-sdk');
const client = new HaiChat.Client({
apiKey: 'your-api-key',
environment: 'sandbox'
});
// チャットボットとの会話
async function chatWithBot(message) {
try {
const response = await client.chat.send({
message: message,
userId: 'user123'
});
console.log(response.reply);
} catch (error) {
console.error('Error:', error.message);
}
}
chatWithBot('こんにちは!');
# HaiChat SDK for Python
from haichat import HaiChatClient
client = HaiChatClient(
api_key='your-api-key',
environment='sandbox'
)
# チャットボットとの会話
def chat_with_bot(message):
try:
response = client.chat.send(
message=message,
user_id='user123'
)
print(response.reply)
except Exception as e:
print(f'Error: {e}')
chat_with_bot('こんにちは!')
<?php
// HaiChat SDK for PHP
require_once 'vendor/autoload.php';
use HaiChat\HaiChatClient;
$client = new HaiChatClient([
'api_key' => 'your-api-key',
'environment' => 'sandbox'
]);
// チャットボットとの会話
function chatWithBot($message) {
global $client;
try {
$response = $client->chat->send([
'message' => $message,
'user_id' => 'user123'
]);
// XSS対策: 出力をエスケープ
echo htmlspecialchars($response->reply, ENT_QUOTES, 'UTF-8');
} catch (Exception $e) {
// XSS対策: エラーメッセージをエスケープ
echo 'Error: ' . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8');
}
}
chatWithBot('こんにちは!');
?>
// HaiChat SDK for Java
import com.haichat.HaiChatClient;
import com.haichat.models.ChatRequest;
import com.haichat.models.ChatResponse;
public class HaiChatExample {
public static void main(String[] args) {
HaiChatClient client = new HaiChatClient.Builder()
.apiKey("your-api-key")
.environment("sandbox")
.build();
// チャットボットとの会話
try {
ChatRequest request = new ChatRequest.Builder()
.message("こんにちは!")
.userId("user123")
.build();
ChatResponse response = client.chat().send(request);
System.out.println(response.getReply());
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
'your-api-key'は実際のAPIキーに置き換えてください。APIキーは環境変数や設定ファイルで管理し、ソースコードに直接記述しないでください。environment: 'sandbox'を使用し、テスト完了後に本番環境に切り替えてください。開発者アカウントを作成して、開発を始めましょう。