### Start Instances Source: https://docs.console.zenlayer.com/api-reference/compute/zec/instance/startinstances This example demonstrates how to start one or more instances using the StartInstances API. Ensure instances are in a 'STOPPED' state and not in the recycle bin. The API is asynchronous; use DescribeInstancesStatus to monitor the actual start completion. ```http POST /api/v2/zec HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: StartInstances Request: { "instanceIds": [ "instanceId1", "instanceId2" ] } Response: { "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453", "response": { "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453", "instanceIds": ["xxx","xxx"] } } ``` -------------------------------- ### Install Go SDK Source: https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk/go Use the `go get` command to install the Zenlayer Cloud SDK for Go. ```APIDOC ## Install SDK for Go Use `go get` to install SDK: ```shell $ go get -u github.com/zenlayer/zenlayercloud-sdk-go ``` ``` -------------------------------- ### Start VM Instances API Endpoint Source: https://docs.console.zenlayer.com/api-reference/compute/vm/virtual-machine-instance/startinstances This is the HTTP GET request to start virtual machine instances. Replace `` with your specific query. ```bash GET https://docs.console.zenlayer.com/api-reference/compute/vm/virtual-machine-instance/startinstances.md?ask= ``` -------------------------------- ### Example iPXE Script for Ubuntu Deployment Source: https://docs.console.zenlayer.com/welcome/bare-metal/get-started/create-a-bare-metal-instance/deploy-a-custom-image-using-ipxe This iPXE script demonstrates downloading and booting a Ubuntu 20.04 ISO image, and then launching the Ubuntu setup with preseed configuration. ```ipxe #!ipxe # Download Ubuntu 20.04 ISO image kernel http://path/to/ubuntu-20.04-netboot/vmlinuz initrd http://path/to/ubuntu-20.04-netboot/initrd boot :install set base-url http://path/to/ubuntu-20.04-netboot/ # Launch Ubuntu setup kernel ${base-url}linux auto=true hostname=${hostname} domain=${domain} url=${preseed/url} locale=${locale} console-setup/layoutcode=us keyboard-configuration/layoutcode=us file=/cdrom/preseed/ubuntu-server.seed initrd=initrd.gz quiet --- initrd ${base-url}initrd.gz boot ``` -------------------------------- ### Query Documentation Example Source: https://docs.console.zenlayer.com/zenlayer-cli/install This example shows how to query the Zenlayer documentation dynamically using an HTTP GET request with the 'ask' query parameter. ```http GET https://docs.console.zenlayer.com/zenlayer-cli/install.md?ask= ``` -------------------------------- ### Install Go SDK Source: https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk/go Use 'go get' to install the Zenlayer Cloud SDK for Go. Ensure you are using Go 1.9.x or later. ```shell $ go get -u github.com/zenlayer/zenlayercloud-sdk-go ``` -------------------------------- ### Query Documentation Example Source: https://docs.console.zenlayer.com/api-reference/compute/zec/disk-snapshot/createsnapshot Perform an HTTP GET request to query the documentation. Replace `` with your specific question. ```bash GET https://docs.console.zenlayer.com/api-reference/compute/zec/disk-snapshot/createsnapshot.md?ask= ``` -------------------------------- ### Start QEMU Guest Agent Service Source: https://docs.console.zenlayer.com/welcome/elastic-compute/get-started/create-an-instance/install-qemu-guest-agent Execute this command to start the QEMU Guest Agent service. The output confirms the agent has started successfully. ```sh sudo service qemu-guest-agent start Starting qemu_guest_agent. 1715676493.359902: debug: Guest agent version 8.2.2 started ``` -------------------------------- ### Query Documentation Example Source: https://docs.console.zenlayer.com/api-reference/compute/traffic/bandwidth-cluster/updatebandwidthclustercommitbandwidth Demonstrates how to query the documentation dynamically using an HTTP GET request with the 'ask' query parameter. This is useful for retrieving specific information not explicitly present on the page. ```bash GET https://docs.console.zenlayer.com/api-reference/compute/traffic/bandwidth-cluster/updatebandwidthclustercommitbandwidth.md?ask= ``` -------------------------------- ### Start Instance Source: https://docs.console.zenlayer.com/api-reference/compute/bmc/bare-metal-instance Starts one or more Bare Metal Instances. ```APIDOC ## POST /pages/oVRQPpUQSkRDY4G4oVSO ### Description Starts one or more instances. ### Endpoint /pages/oVRQPpUQSkRDY4G4oVSO ``` -------------------------------- ### Reset Instance (Reinstall OS) Source: https://docs.console.zenlayer.com/api-reference/compute/zec/instance/resetinstance Use this example to reinstall the operating system on a ZEC instance. Ensure you provide the correct instance ID, image ID, and password. The `enableAgent` flag can be set to `true` to install the agent. ```http POST /api/v2/zec HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: ResetInstance Request: { "instanceId": "", "imageId": "ubuntu2022", "password": "Example+123", "enableAgent": true } Response: { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3" } } ``` -------------------------------- ### Querying Documentation Example Source: https://docs.console.zenlayer.com/api-reference/compute/mcpg/web-search/exa Perform an HTTP GET request to query the documentation dynamically. Replace '' with your specific question. ```http GET https://docs.console.zenlayer.com/api-reference/compute/mcpg/web-search/exa.md?ask= ``` -------------------------------- ### Start Virtual Machine Instance Source: https://docs.console.zenlayer.com/test/compute/zec/instance Starts a stopped virtual machine instance. ```APIDOC ## POST /pages/bhaKNImul0B0FfRWBka7 ### Description Starts a virtual machine instance that is currently in a stopped state. ### Endpoint /pages/bhaKNImul0B0FfRWBka7 ``` -------------------------------- ### Create Instances Source: https://docs.console.zenlayer.com/api-reference/compute/vm/virtual-machine-instance/createinstances This example demonstrates how to create a pay-as-you-go virtual machine instance with specified parameters like zone, instance type, image, and network billing method. ```APIDOC ## POST /api/v2/vm ### Description Creates one or more virtual machine instances based on the provided configuration. ### Method POST ### Endpoint /api/v2/vm ### Parameters #### Request Body - **zoneId** (string) - Required - The ID of the zone where the instance will be created. - **instanceType** (string) - Required - The type of the instance (e.g., "c.1c2g"). - **imageId** (string) - Required - The ID of the image to be installed on the instance. - **instanceChargeType** (string) - Required - The billing method for the instance (e.g., "POSTPAID"). - **internetChargeType** (string) - Required - The billing method for network traffic (e.g., "ByBandwidth"). ### Request Example ```json { "zoneId":"SEL-A", "instanceType":"c.1c2g", "imageId":"img-yKK4q6XybymPgfx7ynUUqC3N8", "instanceChargeType":"POSTPAID", "internetChargeType":"ByBandwidth" } ``` ### Response #### Success Response (200) - **requestId** (string) - The unique ID of the request. - **orderNumber** (string) - The ID of the order. - **instanceIdSet** (Array of String) - A list of instance IDs that have been created or are being created. - **instances** (Array of DiskWithInstance) - A set of data disk IDs created along with the instances. #### Response Example ```json { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "instanceIdSet": ["instanceId1"], "orderNumber" : "the id of order number", "instances":[{"instanceId":"instanceId1","diskIdSet":[]}] } } ``` ``` -------------------------------- ### Create Pay-as-you-go Instance Source: https://docs.console.zenlayer.com/api-reference/compute/vm/virtual-machine-instance/createinstances This example demonstrates how to create a pay-as-you-go virtual machine instance with basic parameters. It includes the request body and the expected response structure. ```json POST /api/v2/vm HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: CreateInstances Request: { "zoneId":"SEL-A", "instanceType":"c.1c2g", "imageId":"img-yKK4q6XybymPgfx7ynUUqC3N8", "instanceChargeType":"POSTPAID", "internetChargeType":"ByBandwidth" } Response: { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "instanceIdSet": ["instanceId1"], "orderNumber" : "the id of order number", "instances":[{"instanceId":"instanceId1","diskIdSet":[]}] } } ``` -------------------------------- ### StartInstances Source: https://docs.console.zenlayer.com/api-reference/compute/zec Starts instances. ```APIDOC ## StartInstances ### Description Starts instances. ### Method POST ### Endpoint /compute/zec/instance/startinstances ``` -------------------------------- ### Install and Enable DHCPCD (Alpine Linux) Source: https://docs.console.zenlayer.com/welcome/elastic-compute/get-started/manage-instances/configure-an-ipv6-address Install the dhcpcd package on Alpine Linux to manage DHCPv6 client configurations. Ensure it starts on boot and is running. ```sh apk add dhcpcd ``` ```sh rc-update add dhcpcd default rc-service dhcpcd start ``` ```sh sudo reboot ``` -------------------------------- ### Start OpenCode Application Source: https://docs.console.zenlayer.com/welcome/ai-gateway/ai-gateway-integration/opencode Launch the OpenCode application from your terminal after installation and configuration. ```bash opencode ``` -------------------------------- ### Describe Instances Example Source: https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk/go This example demonstrates how to create a client and call the `DescribeInstances` API using the Go SDK. ```APIDOC ## Quick Examples Take DescribeInstances as an example. ```go package main import ( "fmt" bmc "github.com/zenlayer/zenlayercloud-sdk-go/zenlayercloud/bmc20221120" "github.com/zenlayer/zenlayercloud-sdk-go/zenlayercloud/common" "os" ) func main() { client, _ := bmc.NewClientWithSecretKey(os.Getenv("ZENLAYERCLOUD_SECRET_KEY_ID"), os.Getenv("ZENLAYERCLOUD_SECRET_KEY_PASSWORD")) request := bmc.NewDescribeInstancesRequest() request.PageSize = 1 request.PageNum = 100 response, err := client.DescribeInstances(request) if _, ok := err.(*common.ZenlayerCloudSdkError); ok { fmt.Printf("An API error has returned: %s", err) return } fmt.Printf("%v\n", response) } ``` ``` -------------------------------- ### Create a pay-as-you-go instance Source: https://docs.console.zenlayer.com/api-reference/compute/bmc/bare-metal-instance/createinstances This example demonstrates how to create a pay-as-you-go bare metal instance with minimal parameters. It specifies the instance charge type, instance type, internet charge type, and zone ID. ```APIDOC ## POST /api/v2/bmc ### Description Creates a bare metal instance with specified configurations. ### Method POST ### Endpoint /api/v2/bmc ### Request Body - **instanceChargeType** (string) - Required - The charging method for the instance (e.g., "POSTPAID"). - **instanceTypeId** (string) - Required - The type of instance to create (e.g., "M6C"). - **internetChargeType** (string) - Required - The billing method for internet usage (e.g., "ByBandwidth"). - **zoneId** (string) - Required - The ID of the zone where the instance will be created (e.g., "SEL-A"). ### Request Example ```json { "instanceChargeType": "POSTPAID", "instanceTypeId": "M6C", "internetChargeType": "ByBandwidth", "zoneId": "SEL-A" } ``` ### Response #### Success Response (200) - **requestId** (string) - The unique ID of the request. - **instanceIdSet** (Array of String) - A list of instance IDs created. Note that the creation is not complete until the status changes from PENDING or CREATING to Running. - **orderNumber** (string) - The order number for the instance creation. #### Response Example ```json { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "instanceIdSet": ["instanceId1"], "orderNumber" : "orderNumber1" } } ``` ``` -------------------------------- ### Jina Web Search API Request Example Source: https://docs.console.zenlayer.com/api-reference/compute/mcpg/web-search/jina Example of how to make a GET request to the Jina search endpoint. Ensure you include your API key in the Authorization header. ```curl curl --location 'https://api.ecn.ai/jina/search' \ --header 'Authorization: Bearer {{YOUR_API_KEY}}' \ --header 'Content-Type: application/json' \ --data ' { "q": "what is an agent sandbox" } ' ``` -------------------------------- ### StartInstances Source: https://docs.console.zenlayer.com/api-reference/compute/vm/virtual-machine-instance/startinstances Starts one or more virtual machine instances. The instances must be in a 'STOPPED' state. The API is asynchronous, and the instance status will change to 'BOOTING' upon successful request, eventually becoming 'RUNNING'. Batch operations are supported with a maximum of 100 instances per request. ```APIDOC ## POST /api/v2/vm ### Description Starts one or more virtual machine instances. The instances must be in a 'STOPPED' state. The API is asynchronous, and the instance status will change to 'BOOTING' upon successful request, eventually becoming 'RUNNING'. Batch operations are supported with a maximum of 100 instances per request. ### Method POST ### Endpoint /api/v2/vm ### Parameters #### Request Body - **instanceIds** (Array of String) - Required - Instance ID(s). The maximum number of instances in each request is 100. ### Request Example { "instanceIds": [ "instanceId1", "instanceId2" ] } ### Response #### Success Response (200) - **requestId** (String) - The unique request ID, which is returned for each request. #### Response Example { "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453", "response": { "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453" } } ### Error Codes - **INVALID_INSTANCE_NOT_FOUND** (404) - Instance does not exist. - **OPERATION_DENIED_INSTANCE_NOT_STOPPED** (403) - Operations on unstopped instances not supported. ``` -------------------------------- ### Example API Query with 'ask' Parameter Source: https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/authorization/sign To get more information not directly present on the page, perform an HTTP GET request with the 'ask' query parameter. The question should be specific and self-contained. ```http GET https://docs.console.zenlayer.com/api-reference/api-introduction/authorization/sign.md?ask= ``` -------------------------------- ### Web Search API Request Example Source: https://docs.console.zenlayer.com/api-reference/compute/mcpg/web-search/exa Use this example to send a POST request to the Web Search API to get an answer to a query. Replace 'YOUR_API_KEY' with your actual API key. ```bash curl --location --request POST 'https://api.ecn.ai/exaai/answer' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer {{YOUR_API_KEY}}' \ --data-raw '{ "query": "What is the latest valuation of SpaceX?", "text": false }' ``` -------------------------------- ### Start and Configure QEMU Guest Agent (Alpine Linux) Source: https://docs.console.zenlayer.com/welcome/elastic-compute/get-started/create-an-instance/install-qemu-guest-agent Steps to start, check status, and configure the QEMU guest agent on Alpine Linux by modifying its init script for verbose logging. This ensures the agent is running and logging correctly. ```bash sudo rc-service qemu-guest-agent start ``` ```bash sudo rc-service qemu-guest-agent status ``` ```bash sudo vi /etc/init.d/qemu-guest-agent ``` ```sh command_args="--verbose -m ${GA_METHOD:-virtio-serial} -p ${GA_PATH:-/dev/virtio-ports/org.qemu.guest_agent.0} -l /var/log/qemu-ga.log -d" ``` ```bash sudo rc-service qemu-guest-agent restart ``` -------------------------------- ### Example of making an API request to ask a question Source: https://docs.console.zenlayer.com/welcome/global-accelerator/faq To get more information not directly on the page, make an HTTP GET request to the page URL with an 'ask' query parameter containing your question. ```http GET https://docs.console.zenlayer.com/welcome/global-accelerator/faq.md?ask= ``` -------------------------------- ### Enable and Configure QEMU Guest Agent (FreeBSD) Source: https://docs.console.zenlayer.com/welcome/elastic-compute/get-started/create-an-instance/install-qemu-guest-agent Configure the QEMU guest agent on FreeBSD by editing /etc/rc.conf to enable the service and set logging flags. Then, start the service and verify its status. ```bash sudo vi /etc/rc.conf ``` ```sh qemu_guest_agent_enable="YES" qemu_guest_agent_flags="-d -v -l /var/log/qemu-ga.log" ``` ```bash sudo service qemu-guest-agent start ``` ```bash sudo service qemu-guest-agent status ``` -------------------------------- ### Query Documentation Example Source: https://docs.console.zenlayer.com/welcome/ip-transit/create-ip-transit/configure-public-interconnect-ip To get additional information not directly present on the page, you can query the documentation dynamically. This involves making an HTTP GET request to the page URL with an 'ask' query parameter. ```bash GET https://docs.console.zenlayer.com/welcome/ip-transit/create-ip-transit/configure-public-interconnect-ip.md?ask= ``` -------------------------------- ### Start an AI Gateway Source: https://docs.console.zenlayer.com/api-reference/compute/aig/ai-gateway/startaigateway This example shows how to start an AI gateway using an HTTP POST request. Ensure you include the correct Host, Content-Type, and X-ZC-Action headers, along with the gatewayUuid in the request body. ```json POST / HTTP/1.1 Host: console.zenlayer.com/api/v2/aigw Content-Type: application/json X-ZC-Action: StartAiGateway Request: { "gatewayUuid": "1568676002379339603" } Response: { "requestId": "TCD1C4FC9-CF4B-4E48-AA9B-63FB4D7DC191", "response": { "requestId": "TCD1C4FC9-CF4B-4E48-AA9B-63FB4D7DC191" } } ``` -------------------------------- ### Create Bandwidth Cluster Example Source: https://docs.console.zenlayer.com/api-reference/compute/traffic/bandwidth-cluster/createbandwidthcluster Demonstrates how to create a bandwidth cluster with specific network and bandwidth configurations. This example shows the POST request structure and the expected JSON response. ```json POST /api/v2/traffic HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: CreateBandwidthCluster Request: { "areaCode" : "SHA", "chargeType" : "POSTPAID", "commitBandwidthMbps" : 1000, "networkType" : "CMI", "internetChargeType" : "MonthlyPercent95Bandwidth", "name" : "sample" } Response: { "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F", "response": { "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F", "orderNumber": "123232", "bandwidthClusterId": "" } } ``` -------------------------------- ### Get Instance ID Source: https://docs.console.zenlayer.com/welcome/elastic-compute/get-started/manage-instances/get-instance-metadata Retrieve the instance ID during startup for initialization scripts. This example uses curl to query the metadata service. ```bash INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) ``` -------------------------------- ### Help Output: GLOBAL OPTIONS Section Example Source: https://docs.console.zenlayer.com/zenlayer-cli/usage/help Lists common global options applicable to all Zenlayer CLI commands. ```text GLOBAL OPTIONS --access-key-id (string) access key ID (overrides config) --access-key-secret (string) access key secret (overrides config) --cli-dry-run (bool) preview the API request without sending it --debug (bool) enable debug mode --endpoint (string) API domain/endpoint (overrides default) --help (bool) help for this command --output (string) output format: json, table (default: from config) --profile (string) profile name to use (default: from config) --query (string) JMESPath query to filter response (e.g. dataSet[*].instanceId) ``` -------------------------------- ### DescribePolicyRegions API Call Source: https://docs.console.zenlayer.com/api-reference/compute/zec/ddos-protection/describepolicyregions Use this example to get a list of regions available for Geo-Blocking configuration. It shows the request structure and a sample response. ```http POST /api/v2/zec HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: DescribePolicyRegions Request: { } Response: { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "regions": [ { "regionId": "AFG", "regionName": "Afghanistan", "areaName": "Asia" } ] } } ``` -------------------------------- ### Go Client for Chat Completion Source: https://docs.console.zenlayer.com/api-reference/compute/aig/chat-completion/xai-chat-completion Example of using the Go SDK to interact with the chat completions API. Ensure you have the openai-go library installed. ```go package main import ( "context" "fmt" "github.com/openai/openai-go" "github.com/openai/openai-go/option" ) func main() { apiKey := "sk-123456789012345678901234567890123456789012345678" client := openai.NewClient( option.WithAPIKey(apiKey), option.WithBaseURL("https://gateway.theturbo.ai/v1"), ) resp, err := client.Chat.Completions.New( context.Background(), openai.ChatCompletionNewParams{ Model: "grok-4", Messages: []openai.ChatCompletionMessageParamUnion{ openai.UserMessage("Hello, can you explain quantum mechanics to me?"), }, }, ) if err != nil { fmt.Println("error:", err) return } fmt.Println(resp.Choices[0].Message.Content) } ``` -------------------------------- ### Querying Documentation API Example Source: https://docs.console.zenlayer.com/welcome/content-delivery-network/domain-management/cdn-settings/origin-path-rewrite Shows how to dynamically query the documentation for additional information using an HTTP GET request with the 'ask' query parameter. ```http GET https://docs.console.zenlayer.com/welcome/content-delivery-network/domain-management/cdn-settings/origin-path-rewrite.md?ask= ``` -------------------------------- ### StartInstances Source: https://docs.console.zenlayer.com/api-reference/compute/vm Starts one or more stopped virtual machine instances. ```APIDOC ## POST /start_instances ### Description Initiates the startup process for one or more virtual machine instances that are currently in a stopped state. ### Method POST ### Endpoint /start_instances ### Parameters #### Request Body - **instance_ids** (array) - Required - A list of instance IDs to start. ``` -------------------------------- ### Obtain Security Groups for Instance Source: https://docs.console.zenlayer.com/api-reference/compute/vm/security-group/describeinstanceavailablesecuritygroupresources Use this example to get a list of security groups that can be applied to a specific instance. It requires the instance ID as input. ```json POST /api/v2/vm HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: DescribeInstanceAvailableSecurityGroupResources Request: { "instanceId": "your-instance-id" } Response: { "requestId": "T728669AE-9EC6-463E-8728-F49DE5C2BC67", "response": { "requestId": "T728669AE-9EC6-463E-8728-F49DE5C2BC67", "instanceAvailableSecurityGroups": [ { "securityGroupId": "your-seucurity-id-1", "securityGroupName": "redis-security", "isDefault": true }, { "securityGroupId": "your-seucurity-id-2", "securityGroupName": "default-web-80-security", "isDefault": false }, { "securityGroupId": "your-seucurity-id-3", "securityGroupName": "cluster-nginx-security", "isDefault": true } ] } } ``` -------------------------------- ### Help Output: OPTIONS Section Example Source: https://docs.console.zenlayer.com/zenlayer-cli/usage/help Lists supported options for a command, detailing their names, types, and descriptions. ```text OPTIONS --instance-ids (list) Instance IDs. You can query up to 100 instances in each request. --zone-id (string) Zone ID to which the instances belong. --image-id (string) Image ID. --ipv4-address (string) IPv4 addresses. --ipv6-address (string) IPv6 addresses. --status (string) Instance status. Possible values: o DEPLOYING - Creating. o REBUILDING - Rebuilding. o REBOOT - Rebooting. o RUNNING - Running. o STOPPED - Powered off. o BOOTING - Powered on. o RELEASING - Releasing. o STOPPING - Powering off. ``` -------------------------------- ### Python Client for Chat Completion Source: https://docs.console.zenlayer.com/api-reference/compute/aig/chat-completion/xai-chat-completion Example of using the Python SDK to interact with the chat completions API. Ensure you have the openai Python library installed. ```python #!/usr/bin/env python3 from openai import OpenAI def main(): api_key = "sk-123456789012345678901234567890123456789012345678" client = OpenAI( api_key=api_key, base_url="https://gateway.theturbo.ai/v1" ) response = client.chat.completions.create( model="grok-4", messages=[ {"role": "user", "content": "Hello, can you explain quantum mechanics to me?"} ] ) print(response.choices[0].message.content) if __name__ == "__main__": main() ``` -------------------------------- ### Query Disk Creation Price Source: https://docs.console.zenlayer.com/api-reference/compute/vm/disk/inquirypricecreatedisks Use this example to query the price of creating a disk. It demonstrates setting parameters for prepaid disks, including the subscription period and unit. ```http POST /api/v2/vm HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: InquiryPriceCreateDisks Request: { "zoneId": "HKG-A", "diskSize": 2000, "chargeType": "PREPAID", "chargePrepaid": { "period": 1, "periodUnit": "Month" } } Response: { "requestId": "TF84F83D3-8F9B-4F49-952E-A7278F7C1183", "response": { "dataDiskPrice": { "discount": 100.0, "discountPrice": 2000.0, "originalPrice": 2000.0, "unitPrice": null, "discountUnitPrice": null, "chargeUnit": null, "stepPrices": null }, "requestId": "TF84F83D3-8F9B-4F49-952E-A7278F7C1183" } } ``` -------------------------------- ### Brave Image Search Request Source: https://docs.console.zenlayer.com/api-reference/compute/mcpg/web-search/brave Example of a GET request to search for images using the Brave API. Demonstrates query parameters for search terms and result count. ```bash curl --location --request GET 'https://api.ecn.ai/brave/res/v1/images/search?q=mountain+landscape&count=10' \ --header 'Authorization: Bearer {{YOUR_API_KEY}}' ``` -------------------------------- ### Query Instance Price (PathBasedBandwidthIP, Billed by Bandwidth) Source: https://docs.console.zenlayer.com/api-reference/compute/zec/instance/inquirypricecreateinstance This example shows how to query instance creation prices for a PathBasedBandwidthIP network, billed by bandwidth. Note that `ipv4BandwidthPrice` may be null, and bandwidth details are in `ipv4BandwidthPrices`. ```json POST /api/v2/zec HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: InquiryPriceCreateInstance Request:{"zoneId":"SEA-A","instanceType":"c.1c2g","networkLineType":"PathBasedBandwidthIP","internetChargeType":"ByBandwidth","bandwidth":1,"instanceCount":1,"systemDisk":{"diskSize":10}} Response: { "response":{ "specPrice": {"discount": 95.0,"discountPrice": 1444.0,"originalPrice": 1520.0,"unitPrice": null,"discountUnitPrice": null,"chargeUnit": null,"stepPrices": null}, "gpuPrice": null, "ipv4Price": {"discount": 100,"discountPrice": null,"originalPrice": null,"unitPrice": 0.076389,"discountUnitPrice": 0.076389,"chargeUnit": "HOUR","stepPrices": null}, "ipv4BandwidthPrice": null, "ipv4BandwidthPrices": [ {"trafficType":"LOCAL","price":{"discount":100,"discountPrice":null,"originalPrice":null,"unitPrice":0.042000,"discountUnitPrice":0.042000,"chargeUnit":"HOUR","stepPrices":null}}, {"trafficType":"INTERNATIONAL","price":{"discount":100,"discountPrice":null,"originalPrice":null,"unitPrice":0.088000,"discountUnitPrice":0.088000,"chargeUnit":"HOUR","stepPrices":null}} ], "ipv6Price": null,"ipv6BandwidthPrice": null, "systemDiskPrice": {"discount": 95.0,"discountPrice": 1444.0,"originalPrice": 1520.0,"unitPrice": null,"discountUnitPrice": null,"chargeUnit": null,"stepPrices": null}, "dataDiskPrice": null } } ``` -------------------------------- ### DescribeVmInventoryCapacity API Request and Response Source: https://docs.console.zenlayer.com/api-reference/compute/vm/virtual-machine-instance/describevminventorycapacity This example demonstrates how to call the DescribeVmInventoryCapacity API to get the inventory of available zones. It includes the request payload and the expected JSON response structure. ```http POST /api/v2/vm HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: DescribeVmInventoryCapacity Request: { "zoneId": "" } Response: { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "dataSet": [ { "zoneId": "LAX-Z", "capacity": "STANDARD" } ] } } ``` -------------------------------- ### Get Default UDP Reflection Source Ports Source: https://docs.console.zenlayer.com/api-reference/compute/zec/ddos-protection/describereflectudpportoptions Use this example to query the default UDP source ports blocked by the DDoS protection policy. This is useful for configuring the `reflectUdpPort` parameter. ```http POST /api/v2/zec HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: DescribeReflectUdpPortOptions Request: { } Response: { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "reflectUdpPorts": [ { "name": "QOTD", "port": 17 } ] } } ``` -------------------------------- ### View Global Help Source: https://docs.console.zenlayer.com/zenlayer-cli/usage/help Get a comprehensive list of all available commands and global options for the Zenlayer CLI. ```bash zeno --help ``` ```bash zeno -h ``` -------------------------------- ### StartDomain Source: https://docs.console.zenlayer.com/api-reference/networking/cdn/domain Enable an accelerated domain. ```APIDOC ## POST /domains/{domain_id}/start ### Description Enable an accelerated domain. ### Method POST ### Endpoint /domains/{domain_id}/start ### Parameters #### Path Parameters - **domain_id** (string) - Required - The ID of the domain to enable. ``` -------------------------------- ### Get Protection Strategy Details Source: https://docs.console.zenlayer.com/api-reference/compute/zec/ddos-protection/describepolicydetail Use this example to retrieve the detailed configuration of a specific DDoS protection policy by its ID. Ensure you include all common request parameters and the policyId in the request body. ```json POST /api/v2/zec HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: DescribePolicyDetail Request: { "policyId": "" } Response: { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "policy": "policyId", "policyName": "xxx", "attachmentIps": ["10.0.0.1","10.0.0.2"], "createTime": "2025-07-16T01:26:39Z", "blackIps": ["10.0.0.1"], "whiteIps": ["10.0.0.1"], "blackIpListExpireAt": 10, "blockProtocols": ["TCP","UDP"], "ports": [ { "protocol": "TCP", "srcPortStart": 1, "srcPortEnd": 100, "dstPortStart": 1, "dstPortEnd": 100, "action": "Accept" } ], "blockRegions": ["AFG"], "reflectUdpPort": [ { "port": 10 } ], "trafficControl": { "bpsEnabled": false, "bps": null, "ppsEnabled": false, "pps": null, "synBPSEnabled": false, "synBPS": null, "synPPSEnabled": false, "synPPS": null }, "fingerPrintRules": [ { "protocol": "TCP", "srcPortStart": 1, "srcPortEnd": 100, "dstPortStart": 1, "dstPortEnd": 100, "minPktLength": 1, "maxPktLength": 100, "offset": 1, "matchBytes": "xxx", "action": "Accept" } ] } } ``` -------------------------------- ### StartInstances Source: https://docs.console.zenlayer.com/api-reference/compute/bmc/bare-metal-instance/startinstances Starts one or more bare metal instances. The instances must be in a 'STOPPED' state and not in the recycle bin. The API is asynchronous, and the instance status will change to 'BOOTING' upon successful request, eventually becoming 'RUNNING'. Batch operations are supported with a maximum of 100 instances per request. ```APIDOC ## POST /api/v2/bmc ### Description Starts one or more bare metal instances. The instances must be in a 'STOPPED' state and not in the recycle bin. The API is asynchronous, and the instance status will change to 'BOOTING' upon successful request, eventually becoming 'RUNNING'. Batch operations are supported with a maximum of 100 instances per request. ### Method POST ### Endpoint /api/v2/bmc ### Parameters #### Request Body - **instanceIds** (Array of String) - Required - Instance ID(s). The maximum number of instances in each request is 100. ### Request Example ```json { "instanceIds": [ "instanceId1", "instanceId2" ] } ``` ### Response #### Success Response (200) - **requestId** (String) - The unique request ID, which is returned for each request. RequestId is required for locating a problem. #### Response Example ```json { "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453", "response": { "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453" } } ``` ``` -------------------------------- ### Get a list of DDoS attack events Source: https://docs.console.zenlayer.com/api-reference/compute/zec/ddos-protection/describeddosalleventlist Use this snippet to retrieve a list of DDoS attack events. It includes example request parameters for status and IP address, and the expected response structure. ```json POST /api/v2/zec HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: DescribeDDosAllEventList Request: { "status": "status", "ipAddress": "10.0.0.2" } Response: { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "response": { "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3", "totalCount": 1, "dataSet": [ { "eventId": "", "status": "ATTACKING", "ipAddress": "10.0.0.2", "protecting": true, "startTime": "2025-05-01T01:01:01Z", "endTime": "2025-05-01T01:01:01Z", "endBlackholeTime": "2025-05-01T01:01:01Z", "attackBandwidthMax": "2", "attackPackageMax": "2", "regionId": "asia-east-1a" } ] } } ``` -------------------------------- ### Get All Backend Servers by Listener ID Source: https://docs.console.zenlayer.com/api-reference/compute/bmc/load-balancing/describebackends Use this example to retrieve a list of all backend servers associated with a specific listener ID. Ensure the correct 'X-ZC-Action' header and request body are included. ```json POST /api/v2/bmc HTTP/1.1 Host: console.zenlayer.com Content-Type: application/json X-ZC-Action: DescribeBackends Request: { "listenerId": "xxxx" } Response: { "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F", "response": { "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F", "totalCount": 10, "dataSet": [ { "listenerId": "xxx", "backendId": "xxx", "backendName": "xxxx", "status": "Available", "port": "80", "weight": 100, "instanceId": "xxxx", "instanceName": "xxxx", "createTime": "2022-08-31 11:13:17" } ] } } ```