Generates a chat completion.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
aicontent:ModelRouterChatCompletions |
create |
*All Resource
|
None | None |
Request syntax
POST /api/v1/modelRouter/open/chat/completions HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| body |
any |
No |
The request body, which must be a JSON object. |
{ "stream": true, "messages": [ { "role": "user", "content": "1+1" } ], "model_id": 15, "stream_options": { "include_usage": true } } |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The root object of the response. |
{ "success": true, "data": {"id": "chatcmpl-xxx", "choices": [{"message": {"role": "assistant", "content": "你好!"}}]}, "requestId": "592A27EF-26D3-1434-98C1-97AD63337852" } |
|
| requestId |
string |
A unique request identifier for troubleshooting. |
xxxx-xxxx-xxxx-xxxxxxxx |
| success |
boolean |
Indicates whether the API call was successful. |
true |
| errCode |
string |
The error code returned when a request fails. |
UNKNOWN_ERROR |
| errMessage |
string |
The error message. |
未知错误 |
| httpStatusCode |
integer |
The HTTP status code. |
200 |
| data |
any |
Contains the core response data. |
[] |
Examples
Success response
JSON format
{
"requestId": "xxxx-xxxx-xxxx-xxxxxxxx",
"success": true,
"errCode": "UNKNOWN_ERROR",
"errMessage": "未知错误",
"httpStatusCode": 200,
"data": "[]"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 500 | Server.Internal.UnknownError | The request processing has failed due to some unknown error. | |
| 403 | B.Permission.DeniedException | 鉴权失败或权限不足 |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.