Create a custom API key.
Operation description
Supported engines
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
rdsai:CreateApiKey |
get |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| InstanceId |
string |
No |
The instance ID. |
rds_copilot***_public_cn-*********6 |
| Quantity |
integer |
No |
The number of API keys to create. The default value is 1. |
1 |
| KeyName |
string |
No |
The name of the API key. |
api-***** |
| LimitType |
string |
No |
The limit type. Valid values:
Valid values:
|
fixed |
| LimitRate |
number |
No |
The limit ratio. |
0.2 |
| TokenQuota |
integer |
No |
The token quota for the API key. |
100000 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response body. |
||
| RequestId |
string |
The request ID. |
FE9C65D7-930F-57A5-A207-8C396329**** |
| Success |
boolean |
Indicates whether the request was successful. |
true |
| Message |
string |
The response message. |
success |
| Data |
object |
The response data. |
|
| CustomKeyList |
array<object> |
The custom API key list. |
|
|
object |
|||
| ApiKey |
string |
The API key. |
sk-rds-***** |
| KeyName |
string |
The API key name. |
api-***** |
| TokenQuota |
integer |
The token quota for the key. |
100000 |
| LimitType |
string |
The limit type. Valid values:
|
fixed |
| LimitRate |
number |
The limit ratio. |
0.2 |
| BaseUrl |
string |
The model invocation URL. |
http://xxx.yy/v1 |
| SystemApiKey |
string |
The system API key. |
sk-rds-xxx |
Examples
Success response
JSON format
{
"RequestId": "FE9C65D7-930F-57A5-A207-8C396329****",
"Success": true,
"Message": "success",
"Data": {
"CustomKeyList": [
{
"ApiKey": "sk-rds-*****",
"KeyName": "api-*****",
"TokenQuota": 100000,
"LimitType": "fixed",
"LimitRate": 0.2
}
],
"BaseUrl": "http://xxx.yy/v1",
"SystemApiKey": "sk-rds-xxx"
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidIpWhitelistError | Invalid IP address or CIDR in whitelist. | |
| 400 | DomainNotReadyError | Domain is not ready yet, please try again later. | |
| 400 | InstanceQuotaExceededError | Instance quota exceeded, cannot create new API key. | |
| 400 | CustomKeyLimitExceededError | Custom key limit exceeded. | |
| 400 | InstanceNotFoundError | No active instance found. | |
| 400 | InvalidQuotaValueError | LimitType must be fixed or ratio. TokenQuota must be a positive integer and limitRate must be between 0.0 and 1.0. | |
| 400 | QuotaSumExceededError | Sum of custom key quotas exceeds instance total quota. | |
| 400 | MoPostpayRatioNotAllowedError | Ratio mode is not supported for POSTPAY instances. Use 'fixed' mode instead. | |
| 403 | InvalidUserOrder | There is no valid order for this UID. | There is no valid order for this UID |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.