CreateHttpApi - 创建HTTP API
创建一个HTTP类型的API。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
apig:CreateHttpApi |
create |
*HttpApi
|
无 | 无 |
请求语法
POST /v1/http-apis HTTP/1.1
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| body |
object |
否 |
请求 Body。 |
{'key': 'value'} |
| name |
string |
是 |
HTTP API 的名称,用于标识当前 API 资源,例如 test-api。 |
test-api |
| description |
string |
否 |
API 描述。 |
Test API for integration |
| protocols |
array |
否 |
API 访问协议列表。 |
|
|
string |
否 |
API 访问协议。 枚举值:
|
HTTP |
|
| basePath |
string |
否 |
API 基础路径。必须以正斜线(/)开头,长度不超过 256 字节,且不能包含空格。当 type=Rest 时必填;当 type=LLM、Ai 或 Agent 时可不传,默认值为 / |
/v1 |
| versionConfig | HttpApiVersionConfig |
否 |
API 版本化配置。 |
|
| type |
string |
是 |
HTTP API 类型。取值:Http(普通 HTTP API)、Rest(RESTful API)、WebSocket(WebSocket API)、HttpIngress(通过 Ingress 接入的 HTTP API)、LLM(大语言模型 API)、Agent(Agent 代理 API)。 枚举值:
|
Http |
| ingressConfig |
object |
否 |
HTTP Ingress API 配置信息。当 type 为 HttpIngress 时必填,不能为 nil,其余 type 无需传入此字段。 |
|
| environmentId |
string |
否 |
环境 ID。 |
env-cq146allhtgk*** |
sourceId
deprecated
|
string |
否 |
来源 ID。 |
src-crdddallhtgtr*** |
| ingressClass |
string |
否 |
监听的 Ingress Class。 |
mse |
| watchNamespace |
string |
否 |
监听的命名空间。 |
default |
| overrideIngressIp |
boolean |
否 |
是否更新 Ingress Status 里的地址。 |
false |
| clusterId |
string |
否 |
集群 ID。 |
k7v5eobfzttudni2pw*** |
| resourceGroupId |
string |
否 |
资源组 ID。 |
rg-xxx |
| aiProtocols |
array |
否 |
AI API 协议列表。当 type 为 LLM 时必填且只能传入 1 个协议;当 type 为 Ai 时必填且可传入多个;其他类型无需传入。协议项示例:OpenAI/v1。 |
|
|
string |
否 |
AI API 协议。 |
OpenAI/v1 |
|
| agentProtocols |
array |
否 |
代理支持的协议列表。当 type 为 Agent 时必填,其余 type 无需传入此字段。 |
|
|
string |
否 |
代理支持的协议列表。当 type 为 Agent 时必填,其余 type 无需传入此字段。 |
http/https |
|
| deployConfigs |
array |
否 |
HTTP API 的部署配置列表。当 type 为 LLM 或 Ai 时必填且只能传入 1 个部署配置;其他类型无需在请求层校验。 |
|
| HttpApiDeployConfig |
否 |
API 部署配置。 |
||
| enableAuth |
boolean |
否 |
是否开启权限认证。当 type 为 LLM、Ai 或 Agent 时会被校验,当 type 为 Rest 时请求层不校验此字段。 |
true |
| authConfig | AuthConfig |
否 |
权限认证配置。当 enableAuth=true 时必填。 |
|
| modelCategory |
string |
否 |
AI 模型类别。当 type 为 LLM 或 Ai 时可选,其他类型无需传入。取值:Text(文本生成)、Image(图像生成)、Audio(音频处理)、Video(视频生成)、MultiModal(多模态)、Embedding(向量嵌入)、Rerank(重排序)、Others(其他)。 枚举值:
|
Text |
| removeBasePathOnForward |
boolean |
否 |
转发请求时是否移除基础路径 |
true |
| firstByteTimeout |
integer |
否 |
等待后端返回首个字节的超时时间 |
30 |
| belongGatewayId |
string |
否 |
所属网关 ID |
gw-abc123xyz789 |
dryRun
deprecated
|
boolean |
否 |
是否仅预览不执行 |
true |
| strategy |
string |
否 |
导入的冲突合并策略 |
ExistFirst |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
响应体。 |
||
| requestId |
string |
请求 ID。 |
A1994B10-C6A8-58FA-8347-6A08B0D4EFDE |
| code |
string |
状态码。 |
Ok |
| message |
string |
响应消息。 |
success |
| data |
object |
API 信息。 |
|
| httpApiId |
string |
HTTP API ID。 |
api-xxx |
| name |
string |
API 名称。 |
test-api |
示例
正常返回示例
JSON格式
{
"requestId": "A1994B10-C6A8-58FA-8347-6A08B0D4EFDE",
"code": "Ok",
"message": "success",
"data": {
"httpApiId": "api-xxx",
"name": "test-api"
}
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。