> For the complete documentation index, see [llms.txt](https://docs.yottalabs.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yottalabs.ai/api-and-sdk/api-reference-v2/serverless.md).

# Serverless

## Create Endpoint

> Create a new endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless":{"post":{"summary":"Create Endpoint","deprecated":false,"description":"Create a new endpoint","operationId":"createEndpoint","tags":["API v2","Serverless v2"],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ElasticV2CreateRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2Response"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Endpoint created successfully","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2Response"}}},"headers":{}},"10001":{"description":"Invalid request parameters","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ElasticV2CreateRequest":{"type":"object","description":"Elastic Endpoint Create Request v2","properties":{"name":{"type":"string","description":"Deployment name","minLength":1,"pattern":"^(?=[A-Za-z])[A-Za-z0-9@._-]{1,20}$"},"imageRegistry":{"type":"string","description":"Docker registry URL","maxLength":255,"minLength":0},"image":{"type":"string","description":"Docker image name","maxLength":255,"minLength":1},"resources":{"type":"array","description":"GPU resources","items":{"$ref":"#/components/schemas/OpenapiElasticResource"},"minItems":1},"minSingleCardVramInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card VRAM in GB","maximum":1536,"minimum":0},"minSingleCardVcpu":{"type":"integer","format":"int32","description":"Minimum GPU single card vCPU count"},"minSingleCardRamInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card RAM in GB","maximum":1536,"minimum":0},"workers":{"type":"integer","format":"int32","description":"Number of workers","minimum":1},"credentialId":{"type":"integer","format":"int64","description":"Credential ID"},"containerVolumeInGb":{"type":"integer","format":"int32","description":"Container volume in GB","minimum":20},"initializationCommand":{"type":"string","description":"Initialization command"},"envVars":{"type":"array","description":"Environment variables","items":{"$ref":"#/components/schemas/KeyValuePairDTO"}},"expose":{"$ref":"#/components/schemas/ElasticV2ExposePort","description":"Exposed port"},"serviceMode":{"type":"string","description":"Service mode: ALB, QUEUE, CUSTOM","minLength":1},"webhook":{"type":"string","description":"Webhook URL for receiving task results","maxLength":512,"minLength":0,"pattern":"^https?://.*"}},"required":["containerVolumeInGb","image","name","resources","serviceMode","workers"]},"OpenapiElasticResource":{"type":"object","properties":{"region":{"type":"string","description":"Region","minLength":1},"gpuType":{"type":"string","description":"GPU Type","minLength":1},"gpuCount":{"type":"integer","format":"int32","description":"GPU Count"}},"required":["gpuCount","gpuType","region"]},"KeyValuePairDTO":{"type":"object","description":"KeyValuePairDTO","properties":{"key":{"type":"string","description":"key","minLength":1},"value":{"type":"string","description":"value","minLength":1}},"required":["key","value"]},"ElasticV2ExposePort":{"type":"object","description":"Exposed port configuration v2","properties":{"port":{"type":"integer","format":"int32","description":"Container port number","maximum":65535,"minimum":1},"protocol":{"type":"string","description":"Protocol type"}},"required":["port","protocol"]},"ResultElasticV2Response":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"$ref":"#/components/schemas/ElasticV2Response","description":"data"}}},"ElasticV2Response":{"type":"object","description":"Elastic Endpoint Response v2","properties":{"id":{"type":"integer","format":"int64","description":"Deployment ID"},"name":{"type":"string","description":"Deployment name"},"creator":{"type":"string","description":"Creator email"},"domain":{"type":"string","description":"Custom domain"},"imageRegistry":{"type":"string","description":"Docker registry URL"},"image":{"type":"string","description":"Docker image name"},"resources":{"type":"array","description":"GPU resources","items":{"$ref":"#/components/schemas/OpenapiElasticResourceResponse"}},"minSingleCardVramInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card VRAM in GB"},"minSingleCardVcpu":{"type":"integer","format":"int32","description":"Minimum GPU single card vCPU count"},"minSingleCardRamInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card RAM in GB"},"credentialId":{"type":"integer","format":"int64","description":"Credential ID"},"containerVolumeInGb":{"type":"integer","format":"int32","description":"Container volume in GB"},"initializationCommand":{"type":"string","description":"Initialization command"},"environmentVars":{"type":"array","description":"Environment variables","items":{"$ref":"#/components/schemas/KeyValuePairDTO"}},"expose":{"$ref":"#/components/schemas/OpenapiExposePortResponse","description":"Exposed port"},"totalWorkers":{"type":"integer","format":"int32","description":"Total workers"},"runningWorkers":{"type":"integer","format":"int32","description":"Running workers"},"cost":{"type":"number","description":"Accumulated cost"},"perSecondPrice":{"type":"number","description":"Per-second price"},"perHourPrice":{"type":"number","description":"Per-hour price"},"serviceMode":{"type":"string","description":"Service mode","enum":["ALB","QUEUE","CUSTOM"]},"webhook":{"type":"string","description":"Webhook URL"},"status":{"type":"string","description":"Deployment status","enum":["INITIALIZING","RUNNING","STOPPING","STOPPED","FAILED"]}}},"OpenapiElasticResourceResponse":{"type":"object","description":"ElasticResource","properties":{"region":{"type":"string","description":"Region"},"regionDisplayName":{"type":"string","description":"Region Display Name"},"gpuType":{"type":"string","description":"GPU Type"},"gpuDisplayName":{"type":"string","description":"GPU DisplayName"},"gpuCount":{"type":"integer","format":"int32","description":"GPU Count"},"singleCardVramInGb":{"type":"integer","format":"int32","description":"GPU Single Card VRAM(GB)"},"singleCardVcpu":{"type":"integer","format":"int32","description":"GPU Single Card VCPU"},"singleCardRamInGb":{"type":"integer","format":"int32","description":"GPU Single Card RAM(GB)"}}},"OpenapiExposePortResponse":{"type":"object","description":"ElasticExpose","properties":{"port":{"type":"integer","format":"int32","description":"port"},"protocol":{"type":"string","description":"protocol"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Submit Task

> Submit a task to a QUEUE-mode endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}/tasks":{"post":{"summary":"Submit Task","deprecated":false,"description":"Submit a task to a QUEUE-mode endpoint","operationId":"submitTask","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ElasticV2SubmitTaskRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2SubmitTaskResponse"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Task submitted successfully","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2SubmitTaskResponse"}}},"headers":{}},"10001":{"description":"Invalid request or non-QUEUE endpoint","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"24000":{"description":"Serverless unavailable","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"24001":{"description":"Serverless does not exist","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ElasticV2SubmitTaskRequest":{"type":"object","description":"Elastic Endpoint Submit Task Request v2","properties":{"taskId":{"type":"string","description":"User-defined task ID. Auto-generated UUID if omitted","maxLength":255,"minLength":0,"pattern":"^[A-Za-z0-9_]*$"},"input":{"description":"Task input data"},"workerPort":{"type":"integer","format":"int32","description":"Worker port (1-65535)","maximum":65535,"minimum":1},"processUri":{"type":"string","description":"Process URI on the worker","maxLength":255,"minLength":0},"webhook":{"type":"string","description":"Webhook URL for result delivery","maxLength":512,"minLength":0,"pattern":"^https?://.*"},"webhookAuthKey":{"type":"string","description":"Webhook authentication key","maxLength":255,"minLength":0},"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"Headers to forward with the task request","properties":{}}},"required":["input","processUri","workerPort"]},"ResultElasticV2SubmitTaskResponse":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"$ref":"#/components/schemas/ElasticV2SubmitTaskResponse","description":"data"}}},"ElasticV2SubmitTaskResponse":{"type":"object","description":"Elastic Endpoint Submit Task Response v2","properties":{"taskId":{"type":"string","description":"Task identifier"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Start Endpoint

> Start or resume a stopped endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}/start":{"post":{"summary":"Start Endpoint","deprecated":false,"description":"Start or resume a stopped endpoint","operationId":"startEndpoint","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultVoid"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Endpoint started","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultVoid"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ResultVoid":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Stop Endpoint

> Stop a running endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}/stop":{"post":{"summary":"Stop Endpoint","deprecated":false,"description":"Stop a running endpoint","operationId":"stopEndpoint","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultVoid"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Endpoint stopped","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultVoid"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ResultVoid":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Delete Endpoint

> Delete an endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}":{"delete":{"summary":"Delete Endpoint","deprecated":false,"description":"Delete an endpoint","operationId":"deleteEndpoint","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultVoid"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Endpoint deleted","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultVoid"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ResultVoid":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Get Endpoint

> Get details of a specific endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}":{"get":{"summary":"Get Endpoint","deprecated":false,"description":"Get details of a specific endpoint","operationId":"getEndpoint","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2Response"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Endpoint found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2Response"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ResultElasticV2Response":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"$ref":"#/components/schemas/ElasticV2Response","description":"data"}}},"ElasticV2Response":{"type":"object","description":"Elastic Endpoint Response v2","properties":{"id":{"type":"integer","format":"int64","description":"Deployment ID"},"name":{"type":"string","description":"Deployment name"},"creator":{"type":"string","description":"Creator email"},"domain":{"type":"string","description":"Custom domain"},"imageRegistry":{"type":"string","description":"Docker registry URL"},"image":{"type":"string","description":"Docker image name"},"resources":{"type":"array","description":"GPU resources","items":{"$ref":"#/components/schemas/OpenapiElasticResourceResponse"}},"minSingleCardVramInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card VRAM in GB"},"minSingleCardVcpu":{"type":"integer","format":"int32","description":"Minimum GPU single card vCPU count"},"minSingleCardRamInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card RAM in GB"},"credentialId":{"type":"integer","format":"int64","description":"Credential ID"},"containerVolumeInGb":{"type":"integer","format":"int32","description":"Container volume in GB"},"initializationCommand":{"type":"string","description":"Initialization command"},"environmentVars":{"type":"array","description":"Environment variables","items":{"$ref":"#/components/schemas/KeyValuePairDTO"}},"expose":{"$ref":"#/components/schemas/OpenapiExposePortResponse","description":"Exposed port"},"totalWorkers":{"type":"integer","format":"int32","description":"Total workers"},"runningWorkers":{"type":"integer","format":"int32","description":"Running workers"},"cost":{"type":"number","description":"Accumulated cost"},"perSecondPrice":{"type":"number","description":"Per-second price"},"perHourPrice":{"type":"number","description":"Per-hour price"},"serviceMode":{"type":"string","description":"Service mode","enum":["ALB","QUEUE","CUSTOM"]},"webhook":{"type":"string","description":"Webhook URL"},"status":{"type":"string","description":"Deployment status","enum":["INITIALIZING","RUNNING","STOPPING","STOPPED","FAILED"]}}},"OpenapiElasticResourceResponse":{"type":"object","description":"ElasticResource","properties":{"region":{"type":"string","description":"Region"},"regionDisplayName":{"type":"string","description":"Region Display Name"},"gpuType":{"type":"string","description":"GPU Type"},"gpuDisplayName":{"type":"string","description":"GPU DisplayName"},"gpuCount":{"type":"integer","format":"int32","description":"GPU Count"},"singleCardVramInGb":{"type":"integer","format":"int32","description":"GPU Single Card VRAM(GB)"},"singleCardVcpu":{"type":"integer","format":"int32","description":"GPU Single Card VCPU"},"singleCardRamInGb":{"type":"integer","format":"int32","description":"GPU Single Card RAM(GB)"}}},"KeyValuePairDTO":{"type":"object","description":"KeyValuePairDTO","properties":{"key":{"type":"string","description":"key","minLength":1},"value":{"type":"string","description":"value","minLength":1}},"required":["key","value"]},"OpenapiExposePortResponse":{"type":"object","description":"ElasticExpose","properties":{"port":{"type":"integer","format":"int32","description":"port"},"protocol":{"type":"string","description":"protocol"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## List Tasks

> Get all tasks of a QUEUE-mode endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}/tasks":{"get":{"summary":"List Tasks","deprecated":false,"description":"Get all tasks of a QUEUE-mode endpoint","operationId":"listTasks","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}},{"name":"status","in":"query","description":"Filter by status: PROCESSING, DELIVERED, SUCCESS, FAILED","required":false,"schema":{"type":"string"}},{"name":"pageNumber","in":"query","description":"","required":false,"schema":{"type":"integer","format":"int32","default":1}},{"name":"pageSize","in":"query","description":"","required":false,"schema":{"type":"integer","format":"int32","default":10}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultV2PageResponseElasticV2TaskResponse"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Success","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultV2PageResponseElasticV2TaskResponse"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"24000":{"description":"Serverless unavailable","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"24001":{"description":"Serverless does not exist","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ResultV2PageResponseElasticV2TaskResponse":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"$ref":"#/components/schemas/V2PageResponseElasticV2TaskResponse","description":"data"}}},"V2PageResponseElasticV2TaskResponse":{"type":"object","description":"Paginated Response","properties":{"items":{"type":"array","description":"List of items in the current page","items":{"$ref":"#/components/schemas/ElasticV2TaskResponse"}},"page":{"type":"integer","format":"int64","description":"Current page number (1-based)"},"size":{"type":"integer","format":"int64","description":"Number of items per page"},"total":{"type":"integer","format":"int64","description":"Total number of items across all pages"},"pages":{"type":"integer","format":"int64","description":"Total number of pages"}}},"ElasticV2TaskResponse":{"type":"object","description":"Elastic Endpoint Task Response v2","properties":{"taskId":{"type":"string","description":"Unique task identifier"},"endpointId":{"type":"integer","format":"int64","description":"Parent endpoint ID"},"endpointName":{"type":"string","description":"Parent endpoint name"},"status":{"type":"string","description":"Task execution status: PROCESSING, DELIVERED, SUCCESS, FAILED"},"workerUrl":{"type":"string","description":"Worker URL processing this task"},"webhook":{"type":"string","description":"Webhook URL for result delivery"},"deliveryStatus":{"type":"string","description":"Webhook delivery status: INIT, SUCCESS, FAILED, MAX_RETRIES_EXCEEDED"},"deliveryAttempts":{"type":"integer","format":"int32","description":"Number of delivery attempts"},"error":{"type":"string","description":"Error message if failed"},"createdAt":{"type":"integer","format":"int64","description":"Task creation time (epoch milliseconds)"},"deliveredAt":{"type":"integer","format":"int64","description":"Webhook delivery time (epoch milliseconds)"},"updatedAt":{"type":"integer","format":"int64","description":"Last update time (epoch milliseconds)"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## List Endpoints

> Get all elastic endpoints

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless":{"get":{"summary":"List Endpoints","deprecated":false,"description":"Get all elastic endpoints","operationId":"listEndpoints","tags":["API v2","Serverless v2"],"parameters":[{"name":"statusList","in":"query","description":"","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"Success, returns list of endpoints","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultListElasticV2Response"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Success","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultListElasticV2Response"}}},"headers":{}}}}}},"components":{"schemas":{"ResultListElasticV2Response":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"type":"array","description":"data","items":{"$ref":"#/components/schemas/ElasticV2Response"}}}},"ElasticV2Response":{"type":"object","description":"Elastic Endpoint Response v2","properties":{"id":{"type":"integer","format":"int64","description":"Deployment ID"},"name":{"type":"string","description":"Deployment name"},"creator":{"type":"string","description":"Creator email"},"domain":{"type":"string","description":"Custom domain"},"imageRegistry":{"type":"string","description":"Docker registry URL"},"image":{"type":"string","description":"Docker image name"},"resources":{"type":"array","description":"GPU resources","items":{"$ref":"#/components/schemas/OpenapiElasticResourceResponse"}},"minSingleCardVramInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card VRAM in GB"},"minSingleCardVcpu":{"type":"integer","format":"int32","description":"Minimum GPU single card vCPU count"},"minSingleCardRamInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card RAM in GB"},"credentialId":{"type":"integer","format":"int64","description":"Credential ID"},"containerVolumeInGb":{"type":"integer","format":"int32","description":"Container volume in GB"},"initializationCommand":{"type":"string","description":"Initialization command"},"environmentVars":{"type":"array","description":"Environment variables","items":{"$ref":"#/components/schemas/KeyValuePairDTO"}},"expose":{"$ref":"#/components/schemas/OpenapiExposePortResponse","description":"Exposed port"},"totalWorkers":{"type":"integer","format":"int32","description":"Total workers"},"runningWorkers":{"type":"integer","format":"int32","description":"Running workers"},"cost":{"type":"number","description":"Accumulated cost"},"perSecondPrice":{"type":"number","description":"Per-second price"},"perHourPrice":{"type":"number","description":"Per-hour price"},"serviceMode":{"type":"string","description":"Service mode","enum":["ALB","QUEUE","CUSTOM"]},"webhook":{"type":"string","description":"Webhook URL"},"status":{"type":"string","description":"Deployment status","enum":["INITIALIZING","RUNNING","STOPPING","STOPPED","FAILED"]}}},"OpenapiElasticResourceResponse":{"type":"object","description":"ElasticResource","properties":{"region":{"type":"string","description":"Region"},"regionDisplayName":{"type":"string","description":"Region Display Name"},"gpuType":{"type":"string","description":"GPU Type"},"gpuDisplayName":{"type":"string","description":"GPU DisplayName"},"gpuCount":{"type":"integer","format":"int32","description":"GPU Count"},"singleCardVramInGb":{"type":"integer","format":"int32","description":"GPU Single Card VRAM(GB)"},"singleCardVcpu":{"type":"integer","format":"int32","description":"GPU Single Card VCPU"},"singleCardRamInGb":{"type":"integer","format":"int32","description":"GPU Single Card RAM(GB)"}}},"KeyValuePairDTO":{"type":"object","description":"KeyValuePairDTO","properties":{"key":{"type":"string","description":"key","minLength":1},"value":{"type":"string","description":"value","minLength":1}},"required":["key","value"]},"OpenapiExposePortResponse":{"type":"object","description":"ElasticExpose","properties":{"port":{"type":"integer","format":"int32","description":"port"},"protocol":{"type":"string","description":"protocol"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Scale Workers

> Scale the number of workers for an endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}/workers":{"put":{"summary":"Scale Workers","deprecated":false,"description":"Scale the number of workers for an endpoint","operationId":"scaleWorkers","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}},{"name":"count","in":"query","description":"","required":true,"schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultVoid"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Workers scaled","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultVoid"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ResultVoid":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Get Task

> Get details of a specific task

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}/tasks/{taskId}":{"get":{"summary":"Get Task","deprecated":false,"description":"Get details of a specific task","operationId":"getTask","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}},{"name":"taskId","in":"path","description":"","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2TaskDetailResponse"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Task found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2TaskDetailResponse"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"24000":{"description":"Serverless unavailable","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"24011":{"description":"Task does not exist","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ResultElasticV2TaskDetailResponse":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"$ref":"#/components/schemas/ElasticV2TaskDetailResponse","description":"data"}}},"ElasticV2TaskDetailResponse":{"type":"object","description":"Elastic Endpoint Task Detail Response v2","properties":{"taskId":{"type":"string","description":"Unique task identifier"},"endpointId":{"type":"integer","format":"int64","description":"Parent endpoint ID"},"endpointName":{"type":"string","description":"Parent endpoint name"},"status":{"type":"string","description":"Task execution status: PROCESSING, DELIVERED, SUCCESS, FAILED"},"workerUrl":{"type":"string","description":"Worker URL processing this task"},"webhook":{"type":"string","description":"Webhook URL for result delivery"},"deliveryStatus":{"type":"string","description":"Webhook delivery status: INIT, SUCCESS, FAILED, MAX_RETRIES_EXCEEDED"},"deliveryAttempts":{"type":"integer","format":"int32","description":"Number of delivery attempts"},"error":{"type":"string","description":"Error message if failed"},"input":{"description":"Task input data"},"output":{"description":"Task output/result data"},"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"Headers forwarded with the task request","properties":{}},"createdAt":{"type":"integer","format":"int64","description":"Task creation time (epoch milliseconds)"},"updatedAt":{"type":"integer","format":"int64","description":"Last update time (epoch milliseconds)"},"deliveredAt":{"type":"integer","format":"int64","description":"Webhook delivery time (epoch milliseconds)"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Update Endpoint

> Update a specific endpoint

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}":{"patch":{"summary":"Update Endpoint","deprecated":false,"description":"Update a specific endpoint","operationId":"updateEndpoint","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ElasticV2UpdateRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2Response"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Endpoint updated successfully","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2Response"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ElasticV2UpdateRequest":{"type":"object","description":"Elastic Endpoint Update Request v2","properties":{"name":{"type":"string","description":"Deployment name","minLength":1,"pattern":"^(?=[A-Za-z])[A-Za-z0-9@._-]{1,20}$"},"resources":{"type":"array","description":"GPU resources","items":{"$ref":"#/components/schemas/OpenapiElasticResource"},"minItems":1},"minSingleCardVramInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card VRAM in GB"},"minSingleCardVcpu":{"type":"integer","format":"int32","description":"Minimum GPU single card vCPU count"},"minSingleCardRamInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card RAM in GB"},"workers":{"type":"integer","format":"int32","description":"Number of workers","minimum":1},"credentialId":{"type":"integer","format":"int64","description":"Credential ID"},"containerVolumeInGb":{"type":"integer","format":"int32","description":"Container volume in GB","minimum":20},"initializationCommand":{"type":"string","description":"Initialization command"},"envVars":{"type":"array","description":"Environment variables","items":{"$ref":"#/components/schemas/KeyValuePairDTO"}},"expose":{"$ref":"#/components/schemas/ElasticV2ExposePort","description":"Exposed port"},"webhook":{"type":"string","description":"Webhook URL for receiving task results","maxLength":512,"minLength":0,"pattern":"^https?://.*"}},"required":["containerVolumeInGb","name","resources","workers"]},"OpenapiElasticResource":{"type":"object","properties":{"region":{"type":"string","description":"Region","minLength":1},"gpuType":{"type":"string","description":"GPU Type","minLength":1},"gpuCount":{"type":"integer","format":"int32","description":"GPU Count"}},"required":["gpuCount","gpuType","region"]},"KeyValuePairDTO":{"type":"object","description":"KeyValuePairDTO","properties":{"key":{"type":"string","description":"key","minLength":1},"value":{"type":"string","description":"value","minLength":1}},"required":["key","value"]},"ElasticV2ExposePort":{"type":"object","description":"Exposed port configuration v2","properties":{"port":{"type":"integer","format":"int32","description":"Container port number","maximum":65535,"minimum":1},"protocol":{"type":"string","description":"Protocol type"}},"required":["port","protocol"]},"ResultElasticV2Response":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"$ref":"#/components/schemas/ElasticV2Response","description":"data"}}},"ElasticV2Response":{"type":"object","description":"Elastic Endpoint Response v2","properties":{"id":{"type":"integer","format":"int64","description":"Deployment ID"},"name":{"type":"string","description":"Deployment name"},"creator":{"type":"string","description":"Creator email"},"domain":{"type":"string","description":"Custom domain"},"imageRegistry":{"type":"string","description":"Docker registry URL"},"image":{"type":"string","description":"Docker image name"},"resources":{"type":"array","description":"GPU resources","items":{"$ref":"#/components/schemas/OpenapiElasticResourceResponse"}},"minSingleCardVramInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card VRAM in GB"},"minSingleCardVcpu":{"type":"integer","format":"int32","description":"Minimum GPU single card vCPU count"},"minSingleCardRamInGb":{"type":"integer","format":"int32","description":"Minimum GPU single card RAM in GB"},"credentialId":{"type":"integer","format":"int64","description":"Credential ID"},"containerVolumeInGb":{"type":"integer","format":"int32","description":"Container volume in GB"},"initializationCommand":{"type":"string","description":"Initialization command"},"environmentVars":{"type":"array","description":"Environment variables","items":{"$ref":"#/components/schemas/KeyValuePairDTO"}},"expose":{"$ref":"#/components/schemas/OpenapiExposePortResponse","description":"Exposed port"},"totalWorkers":{"type":"integer","format":"int32","description":"Total workers"},"runningWorkers":{"type":"integer","format":"int32","description":"Running workers"},"cost":{"type":"number","description":"Accumulated cost"},"perSecondPrice":{"type":"number","description":"Per-second price"},"perHourPrice":{"type":"number","description":"Per-hour price"},"serviceMode":{"type":"string","description":"Service mode","enum":["ALB","QUEUE","CUSTOM"]},"webhook":{"type":"string","description":"Webhook URL"},"status":{"type":"string","description":"Deployment status","enum":["INITIALIZING","RUNNING","STOPPING","STOPPED","FAILED"]}}},"OpenapiElasticResourceResponse":{"type":"object","description":"ElasticResource","properties":{"region":{"type":"string","description":"Region"},"regionDisplayName":{"type":"string","description":"Region Display Name"},"gpuType":{"type":"string","description":"GPU Type"},"gpuDisplayName":{"type":"string","description":"GPU DisplayName"},"gpuCount":{"type":"integer","format":"int32","description":"GPU Count"},"singleCardVramInGb":{"type":"integer","format":"int32","description":"GPU Single Card VRAM(GB)"},"singleCardVcpu":{"type":"integer","format":"int32","description":"GPU Single Card VCPU"},"singleCardRamInGb":{"type":"integer","format":"int32","description":"GPU Single Card RAM(GB)"}}},"OpenapiExposePortResponse":{"type":"object","description":"ElasticExpose","properties":{"port":{"type":"integer","format":"int32","description":"port"},"protocol":{"type":"string","description":"protocol"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```

## Get Task Count

> Get task statistics grouped by status

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"API v2"},{"name":"Serverless v2"}],"security":[{}],"paths":{"/v2/serverless/{id}/tasks/count":{"get":{"summary":"Get Task Count","deprecated":false,"description":"Get task statistics grouped by status","operationId":"getTaskCount","tags":["API v2","Serverless v2"],"parameters":[{"name":"id","in":"path","description":"","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2TaskCountResponse"}}},"headers":{}},"400":{"description":"Bad Request","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"10000":{"description":"Success","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ResultElasticV2TaskCountResponse"}}},"headers":{}},"14000":{"description":"Endpoint not found","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"24000":{"description":"Serverless unavailable","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}},"24001":{"description":"Serverless does not exist","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}},"headers":{}}}}}},"components":{"schemas":{"ResultElasticV2TaskCountResponse":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"$ref":"#/components/schemas/ElasticV2TaskCountResponse","description":"data"}}},"ElasticV2TaskCountResponse":{"type":"object","description":"Elastic Endpoint Task Count Response v2","properties":{"processing":{"type":"integer","format":"int32","description":"Currently processing"}}},"Result":{"type":"object","properties":{"message":{"type":"string","description":"message"},"code":{"type":"integer","format":"int32","description":"code"},"data":{"description":"data"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.yottalabs.ai/api-and-sdk/api-reference-v2/serverless.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
