Hikvision AI Open Platform API: model, engine, task, event
Four layers have to exist in order, and three of the identifiers are chosen by your platform rather than the device.
A companion guide maps what is in the SDK archive and counts the endpoints, which is what the package actually contains. This one follows the calls in the order a working integration has to make them, because the failure mode here is not a missing function. It is a layer that was skipped. A task can be created and never applied. A model can be stored and never bound. A channel can be armed after the model is up, and deliver nothing, because the rule layer was never configured.
Nothing below was run against a recorder. Every statement comes from the 243 page AI Open Platform developer guide, the headers in the same archive, or the capability and message definitions inside that guide.
The four layers
| Layer | Identifier | Who assigns it | Scope |
|---|---|---|---|
| Model package | MPID, a 64 byte string | Your platform, the device only echoes it | Stored on the device, can be loaded by one or more engines |
| Engine | Integer, from 1 upward | The device | One compute unit; the AI capacity the datasheet counts |
| Task | taskID, at most 64 bytes | Your platform, passed through untouched by the device | Binds channels, an engine, a frame rate and a schedule |
| Event | Command number, 0x4021 to 0x4025 and 0x4993 | The device | Arrives only through the alarm channel you armed |
The guide is explicit that MPID, taskID and the reference picture ID are all managed by the platform. That is unusual enough to matter: the device does not generate identifiers, it stores whatever you send, which means duplicate IDs are your bug and an ID that changes between create and apply silently creates a second object.
Two reads before anything is configured
The first call is the one that returns the engine IDs, and it is described in the table as a request for computing power.
GET /ISAPI/Intelligent/AIOpenPlatform?format=json
The response is JSON_AIOpenPlatformInfo, and it carries more than a number.
| Field | Example | What it tells you |
|---|---|---|
| algorithmVersion | AV1.5.0 | Version of the algorithm runtime, not the firmware |
| firmware | FW006 | Firmware the device reports to this interface |
| engine | 1, 2, 3, 4 | The engine IDs; the guide's example ties one entry to each chip |
| platform | 1 | 1 is TX1, 2 is P4, 3 is 3559, 4 is 3519, 5 is 3516 |
| platformName | K81 | A custom platform name, a free string |
The remark on the engine reset endpoint says the engine ID is returned by calling this URI, so this is where the guide sends you to discover the engine list. The engines status endpoint does expose the same IDs, because each entry in its list is keyed by engine, but the root call is the one the documentation names for the purpose.
The second read is the capability document, and it has 27 flags.
GET /ISAPI/Intelligent/AIOpenPlatform/capabilities?format=json
JSON_AIOpenPlatformCapOfDevice is worth reading field by field, because it gates the whole project plan.
| Group | Flags | Decision it gates |
|---|---|---|
| Task families | isSupportVideoTask, isSupportVideoPollingAnalysisTask, isSupportPictureTask, isSupportPicturePollingAnalysisTask, isSupportHistoryVideoTask | Which of the five task families you can build at all |
| Model handling | isSupportUploadModelwithURL, isSupportUploadModelwithPushBinaryData, isSupportAuthorizationModel, isSupportModelSchedule, isSupportResetEngine | Whether the recorder can fetch a model itself, and whether models are licensed |
| Rules | isSupportAIRuleConfig, isSupportPresetAIRuleConfig, isSupportEventTrigger, isSupportAIRuleTrigger, isSupportAIRuleCapabilities, isSupportAIRuleCount, isSupportAIRuleCountManualReset, isSupportConfidenceConfig | Whether the rule layer exists, and whether rules can differ per PTZ preset |
| Pictures and search | isSupportAITargetBP, isSupportAIPictureUpLoad, isSupportAIIntelligentSearch | Reference picture comparison, and whether pictures can be pushed as binary |
| Overlay | isSupportAIRuleOverlay, isSupportAITargetOverlay, isSupportOSDConfig | Whether detections can be drawn into the preview |
| Model types | isSupportOCRDetection, isSupportContrast, isSupportBehavior | Which model families the unit will import |
Every one of the 27 is marked optional. isSupportConfidenceConfig is marked dependent as well: it is only meaningful when isSupportAIRuleConfig is true.
This endpoint answers a different question from the general device capability document. That one, on a System capabilities request, says whether the box has the platform at all; this one says which parts of it this firmware implements. A project needs both, and a false or absent answer on either is a redesign rather than a configuration change.
A model package is yours to name and install
There are three ways to get a package onto the device, and they are not equivalent.
| Route | Call | What it carries |
|---|---|---|
| Preset from a URL | POST to the algorithmModel endpoint | MPID, a URL of up to 256 bytes, a name of up to 128, an appID of up to 64, a licence key URL of up to 256, and an authorised flag |
| Preset as packets | POST to the binary packets endpoint | The same metadata, with the package itself in the request |
| SDK upload | NET_DVR_UploadFile_V40 with upload type 52 | NET_DVR_AI_ALGORITHM_MODEL, holding a description buffer and a licence key buffer |
The URL route moves the transfer to the device. The guide states the condition plainly: the platform has to guarantee the URL is available, and authentication is carried inside the URL rather than in a header. A recorder behind a restricted egress will fail this route for reasons that never appear in the API response, and the progress endpoint exists for exactly that case. It returns JSON_ModelPacketDownloadProgress, and its description says it is mainly for packages sent in URL format.
The install body has one field that collapses two steps.
| Field | Behaviour when sent |
|---|---|
| engine, an array of engine IDs | Omitted, the model is stored and left unbound. Present, it is bound to those engines in the same call |
So installing and binding is either one call or two, and the field is optional in both the URL message and the binary message. A package that is installed but unbound shows up in the storage list and does nothing.
Storage is readable and finite.
GET /ISAPI/Intelligent/AIOpenPlatform/algorithmModel/management?format=json
GET /ISAPI/Intelligent/AIOpenPlatform/algorithmModel/management/space?format=json
DELETE /ISAPI/Intelligent/AIOpenPlatform/algorithmModel/management/space/{MPID}?format=json
The management list returns each package with a status of 0 for not loaded, 1 for loaded, or 2 for decryption failed. The space document returns total and remaining capacity in MB plus the number of packages supported. One line in the package list is worth more than the rest of the section: the engine field is an array, and the comment says one model package can be loaded by multiple engines. A model does not have to be uploaded once per engine, and capacity can be raised by pointing a second engine at a package that is already there.
Deleting a package is a different operation from unbinding it. The delete sits under management and space, the unbind sits under unloading, and one removes the file while the other only releases the engine.
Bind, then read the engine back
| Call | Effect |
|---|---|
| PUT on the loading endpoint with an engine ID | Binds a package to that engine |
| DELETE on the unloading endpoint with an engine ID | Releases the engine, keeping the package |
| PUT on the engine reset endpoint | Restarts the engine |
The reset description is restart, not reset to defaults. It does not clear the binding.
After a bind, the engine states are the ones to poll.
| Status | Meaning |
|---|---|
| 0 | No package loaded |
| 1 | Loaded and operating |
| 2 | Loaded but operating abnormally |
| 10 | Engine initialising |
| 11 | Engine abnormal |
| 12 | Engine is used for a facial application and cannot run AI Open Platform |
Status 12 is the important one. It is the device stating, at the interface level, that an engine has been claimed by another application and is closed to the platform. On a unit whose capacity the datasheet divides between facial work and AI analysis, this is where the division becomes visible: the engine is in the list, it answers, and it is unavailable. A platform that converts the datasheet compute count straight into a job count will overcommit on exactly these models, and nothing in the response will look like an error.
The presence of status 10 means a successful bind is not the same as a model that is ready. The load call returns, the engine initialises, and detection output starts only after status reaches 1.
Create a task, then apply it
Five task families share a shape but not their verbs.
| Family | Collection | Item | How a task is created |
|---|---|---|---|
| videoTask | GET and POST | PUT to create, DELETE to remove | PUT on the item, with your taskID in the path |
| videoPollingAnalysisTask | GET and POST | PUT to edit, DELETE to remove | POST on the collection |
| pictureTask | GET and POST | POST, PUT, DELETE | POST on the collection |
| picturePollingAnalysisTask | GET and POST | PUT and DELETE | POST on the collection |
| historyVideoTask | GET and POST | PUT to edit, DELETE to remove | POST on the collection |
Only videoTask lets the platform choose the ID at creation. The other four are sent to the collection, and the device assigns. That inconsistency is the first thing to encode in a client library, because a generic wrapper that creates everything with PUT will work on one family and fail on four.
For videoTask the create call and the apply call do not carry the same fields.
| Call | Body | Carries |
|---|---|---|
| PUT with a taskID | JSON_VideoTaskManagement | Channel list, frame rate, alert interval, weekly time range, target overlay, event trigger |
| POST on the collection | JSON_ApplyVideoTask | taskID, the engine, the channel list, and the same analysis parameters |
The engine appears only in the apply body. That is the detail that makes the split worthwhile: a task definition is engine independent, and pointing it at a different engine is an apply, not a new task. It also means a created task is inert until it is applied, and a platform that only calls the create endpoint will have a full task list and no detections.
Three parameter conventions are easy to get wrong.
| Parameter | Encoding | Example |
|---|---|---|
| frameRate | Frame rate multiplied by 100 | 2500 is 25 frames per second |
| alertInterval | Alerts per second as a decimal | 1 is one per second, 0.5 is two per second |
| TimeRange | Weekday 1 to 7 with ISO 8601 times, 8 periods per day by default | Weekday 1, 00:00 to 24:00 |
The apply response is where a project finds out whether it actually worked. It returns a status document plus an optional array named channelID, described as the channels the task failed to be applied on. A success code is therefore a success for the request, not for every channel, and the array is the only per channel answer the interface gives.
Linkage follows the same pattern of subtle defaults. In the task body, leaving the EventTrigger field out means no linkage is performed, and sending it as null deletes the linkage that exists. The apply message lists 16 notification methods: email, IM, IO, syslog, HTTP, FTP, buzzer, PTZ, record, monitor alarm, sending to a centre, light and audio alarm, focus, trace, white light and audio. The capability document lists 17 for the same field, adding cloud and SMS and dropping audio, so the two lists are not the same set and a client should not validate against either one.
Rules are a separate layer
A task says where to look. The rule layer says what counts as an event.
| Call | Purpose |
|---|---|
| GET on the rule configuration capability | Which rule parameters the channel supports |
| GET and PUT on the task and channel path | Read or write the rule set for that task on that channel |
| GET on the status path | Whether the rule configuration took effect |
| GET and PUT on the preset path | The same, per PTZ preset |
| GET and PUT on the trigger path | Rule linkage |
| PUT on the trigger delete path | Remove the linkage |
The rule payload itself is not a fixed schema. The guide marks the configuration block as provided by the algorithm and for reference only, which means a client cannot be written against the sample and expect it to hold across model packages. The supported parameters come from the capability call, and the values come from the device.
The event type is a number rather than a name.
| Value | Rule type |
|---|---|
| 1073758209 | Region target exception status detection |
| 1073758210 | Region exception status detection |
| 1073758211 | Line crossing target detection |
| 1073758212 | Line crossing target counting |
| 1073758213 | Region target number counting |
| 1073774593 | Target trigger analysis, the full AI Open Platform analysis |
Two smaller traps sit in this layer. Deleting a linkage is a PUT to the trigger delete path, not a DELETE on the trigger path. And the preset variant is the reason a PTZ channel can hold different rules at different positions, which is not expressible in the task body.
Reference pictures for target comparison are a third sub layer, with six endpoints covering capture from a channel, upload as JSON, download as binary image data, rename, batch delete and list by channel. The batch delete is again a PUT, not a DELETE. The upload path is named binary and takes a JSON message, while the actual binary route is the SDK upload type 55, so the naming inverts what a reader expects.
Nothing is delivered until the channel is armed
| Event | Command | Payload |
|---|---|---|
| Video analysis detection | 0x4021 | NET_AIOP_VIDEO_HEAD |
| Picture analysis detection | 0x4022 | NET_AIOP_PICTURE_HEAD |
| Captured picture polling detection | 0x4023 | NET_AIOP_POLLING_SNAP_HEAD |
| Video polling detection | 0x4024 | NET_AIOP_POLLING_VIDEO_HEAD |
| History video detection | 0x4025 | NET_AIOP_HISTORY_VIDEO_HEAD |
| Model package updating | 0x4993 | JSON_EventNotificationAlert_MPUpdate |
Arming is a three call sequence: set the message callback, open the alarm channel, and close it when done. For an integration that reaches the device through the text protocol rather than the SDK, the callback command is COMM_ISAPI_ALARM, 0x6009, and the payload pointer is NET_DVR_ALARM_ISAPI_INFO. The alarm channel also accepts a subscription document with event mode all, which is what the sample passes.
The model update event is the one that is easy to leave out of a design. A deployment, a licence change or a failed package all become visible as 0x4993 rather than as detections that quietly change character.
Seven defects that will cost you a day
These are in the document we read, and each one breaks something concrete.
| Defect | Consequence |
|---|---|
| The reference picture section tells you to cast the upload buffer to NET_DVR_AI_BASE_PICTUR_UPLOAD | That name appears zero times in the four headers in the archive. The declared structure is NET_DVR_AI_PICTUR_UPLOAD, holding a 64 byte task ID and a 64 byte picture ID |
| The arming sample declares LlHandle with a capital L on one branch | The sample does not compile as printed |
| The capability flag isSupportAIRuleCountManualReset cites a manualReset URI | That URI is not among the 42 in Appendix D, so the flag points outside the published interface |
| The preset rule URI is printed with an extra slash before the query | A client that builds paths from the table and a client that builds them from the section heading send two different requests |
| The DELETE row for video polling tasks drops the task ID and the query string | The section heading has both, the table row has neither |
| The rule status URI is annotated as a channel ID | The path is a task followed by status, and the only ID in it is the task |
| The task ID length is described as at most 64 bytes in prose, and printed as a minimum of 64 and a maximum of 64 in two capability samples | A client that validates against the capability sample rejects every shorter ID |
None of these change what the interface does. All of them change how long it takes to reach a first detection, which is why they are listed rather than smoothed over.
What this guide cannot tell you
We did not run any of this against a device, and the archive contains no AI Open Platform sample code to compare against. The four properties that matter most in planning are therefore still open.
Whether the engine array length equals the chip count on a given AF model. The guide's example ties one engine ID to one chip, but it never names the chip family, and the relation between an engine and a KT5 has to be read from the unit rather than from the datasheet.
What the per unit limits are. The capability documents carry the counts and the allowed values, from concurrent task numbers to the frame rates and channels a unit accepts, and they differ by firmware. They are the answer, not the tables above.
Whether every one of the 42 URIs is implemented on a given build. The optional flags exist because the vendor expects variance.
Which endpoints the other analytics lines use. Face comparison, perimeter protection, structuralisation and AcuSearch are documented under a licence agreement we have not signed, so they are absent from this site rather than guessed at.
An applied task still has to deliver its events. The alarm channel that carries them, and the two protocols the SDK can log in with, are covered in the HCNetSDK connection guide.