Intent Recognition API
Please refer to the Quick Start Guide to obtain your API key.
Replace $YOUR_API_KEY
with the actual API key you obtained.
This platform uses API keys for data isolation — even under the same user account, data accessed with different API keys (tokens) is kept separate and not shared.
API Overview
Method | Route | Description | API Endpoint |
---|---|---|---|
POST | /v1/intent/recog |
Recognize user intent | https://api-platform.ope.ai/v1/intent/recog |
POST | /v1/intent/update |
Batch update intents | https://api-platform.ope.ai/v1/intent/update |
DELETE | /v1/intent |
Batch delete intent nodes | https://api-platform.ope.ai/v1/intent |
Recognize User Intent
POST /v1/intent/recog
import requests
url = 'https://api-platform.ope.ai/v1/intent/recog'
headers = {
'Authorization': 'Bearer $YOUR_API_KEY',
'Content-Type': 'application/json',
}
payload = {
'model': 'opeai/JointId-v1',
'node_id': '1',
'intent_type': 'single',
'answer': 'I am a teacher',
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
Request Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
Authorization | header | string | Yes | API access key (use Bearer YOUR_API_KEY format) |
Content-Type | header | string | Yes | Must be application/json |
model | body | string | Yes | Model name, e.g. opeai/JointId-v1 |
node_id | body | string | Yes | Unique node ID identifying the context |
intent_id | body | string | No | Intent ID from the previous turn (for multi-turn intent recognition) |
intent_type | body | string | Yes | Either single or multi |
answer | body | string | Yes | User input text |
intent_id
is required whenintent_type
ismulti
.
Example Response
{
"code": 1,
"msg": "",
"data": {
"intent": "Duplicate",
"intent_id": "123123123"
},
"success": true,
"message": ""
}
Response Schema
Field | Type | Description |
---|---|---|
code | integer | 1 means success; otherwise error |
msg | string | Error message (if any) |
data | object | Contains intent and intent_id |
intent | string | Detected intent name (may be "" ) |
intent_id | string | Intent ID used or generated |
success | boolean | Ignored |
message | string | Ignored |
POST Batch Update (Add if not exists)
POST /v1/intent/update
Example Request Body
[
{
"node_id": "node_1000",
"question": "May I ask what your occupation is?",
"intent": [
{
"name": "Occupation Accepted",
"example": [
"student", "unemployed", "teacher", "office worker", "IT", "low-risk job"
],
"relation": 1
},
{
"name": "Occupation Not Accepted",
"example": [
"soldier", "high-risk job", "miner", "driver", "firefighter"
],
"relation": 1
},
{
"name": "AI Unable to Respond",
"example": [
"ai unable to respond"
]
}
]
}
]
To improve recognition accuracy, it is strongly recommended to include a fallback intent such as:
Request Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
Authorization | header | string | Yes | API access key |
Content-Type | header | string | Yes | Must be application/json |
body | body | array[object] | Yes | List of nodes and their intent mappings |
intent
Field Schema
Field | Type | Description |
---|---|---|
name | string | Intent name |
example | array[string] | Example phrases for this intent |
relation | integer | Optional relation grouping (usually 1 ) |
Example Response
Response Schema
Field | Type | Description |
---|---|---|
code | integer | 1 means success; otherwise error |
msg | string | Error message (if any) |
data | object | Usually an empty object {} |
success | boolean | Ignored |
message | string | Ignored |
DELETE Batch Delete Intents
DELETE /v1/intent
Example Request Body
Request Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
Authorization | header | string | Yes | API access key (Bearer YOUR_API_KEY ) |
Content-Type | header | string | Yes | Must be application/json |
body | body | object | Yes | Request body object |
node_ids | body | array[string] | Yes | Array of node IDs to be deleted, e.g., ["node_1000", "node_1001"] |
Example Response
Response Schema
Field | Type | Description |
---|---|---|
code | integer | 1 means success; otherwise error |
msg | string | Error message (if any) |
data | object | Usually an empty object {} |
success | boolean | Ignored |
message | string | Ignored |