ctexthuang/aip_sdk

baidu sdk for php

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ctexthuang/aip_sdk

v1.0.0 2026-01-30 06:15 UTC

This package is auto-updated.

Last update: 2026-01-30 06:19:10 UTC


README

This is a PHP SDK for Baidu AI Platform (Baidu AIP).

Installation

You can install the package via composer:

composer require ctexthuang/aip_sdk

Usage

Initialization

All AI services use the same initialization method. You need to obtain the App ID, API Key, and Secret Key from the Baidu AI Console.

use ctexthuang\aip_sdk\AipFace;
// or other services like:
// use ctexthuang\aip_sdk\AipOcr;
// use ctexthuang\aip_sdk\AipNlp;

$appId = 'YOUR_APP_ID';
$apiKey = 'YOUR_API_KEY';
$secretKey = 'YOUR_SECRET_KEY';

$client = new AipFace($appId, $apiKey, $secretKey);

Available Services

The SDK supports the following services. Replace AipFace with the corresponding class name to use other services.

  • Face Recognition: ctexthuang\aip_sdk\AipFace
  • OCR (Optical Character Recognition): ctexthuang\aip_sdk\AipOcr
  • NLP (Natural Language Processing): ctexthuang\aip_sdk\AipNlp
  • Image Content Censor: ctexthuang\aip_sdk\AipImageCensor
  • Text Content Censor: ctexthuang\aip_sdk\AipContentCensor
  • Image Classification: ctexthuang\aip_sdk\AipImageClassify
  • Image Search: ctexthuang\aip_sdk\AipImageSearch
  • Image Processing: ctexthuang\aip_sdk\AipImageProcess
  • Speech Recognition: ctexthuang\aip_sdk\AipSpeech
  • Body Analysis: ctexthuang\aip_sdk\AipBodyAnalysis
  • Knowledge Graph: ctexthuang\aip_sdk\AipKg

Example: Face Detection

$image = file_get_contents('path/to/image.jpg');
$imageType = 'BASE64';
$image = base64_encode($image);

// Detect face
$result = $client->detect($image, $imageType);
print_r($result);

Example: OCR General Basic

use ctexthuang\aip_sdk\AipOcr;

$client = new AipOcr($appId, $apiKey, $secretKey);

$image = file_get_contents('path/to/image.jpg');
$result = $client->basicGeneral($image);
print_r($result);

License

MIT