> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.xapi.to/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.xapi.to/_mcp/server.

# 列出预置环境

GET https://sandbox.xapi.to/v1/environments

汇总当前可用 Offering 明确声明的稳定运行时环境，用于 requirements.environmentId。
空数组表示当前没有可售 Offering 发布环境预置，不是服务异常。此时报价/创建应省略
environmentId，改用 capabilities、资源与区域约束。


Reference: https://docs.xapi.to/sandbox/api-reference/discovery/list-environments

## Servers

- `https://sandbox.xapi.to` (Production, default)
- `https://sandbox.test.xapi.to` (Test)

## Response

### 200

环境列表

- `list of Environment`

## Types

### Environment

可在 requirements.environmentId 中引用的标准运行环境。

- `id` (string, required) — 稳定的环境标识，创建/报价时传给 requirements.environmentId。
- `name` (string, required) — 面向用户展示的环境名称。
- `offeringCount` (integer, required) — 当前能够提供此环境的活动 offering 数量；为 0 时无法按该环境创建。
- `description` (string, optional) — 环境用途和已包含工具的说明。
- `image` (string, optional) — 环境对应的镜像或模板标识；仅用于说明，不保证调用方可直接拉取。
- `os` (string, optional) — 操作系统名称，例如 linux。
- `architecture` (string, optional) — CPU 架构，例如 amd64 或 arm64。
- `language` (string, optional) — 预装的主要编程语言，例如 python 或 node。
- `languageVersion` (string, optional) — 主要编程语言版本。
- `cuda` (string, optional) — CUDA 版本；仅 GPU 环境可能返回。
- `framework` (string, optional) — 预装的主要计算/机器学习框架名称。
- `frameworkVersion` (string, optional) — 主要框架版本。

## Examples

### 当前没有环境预置

**Response**

```json
[]
```

**SDK Code**

```python 当前没有环境预置
import requests

url = "https://sandbox.xapi.to/v1/environments"

response = requests.get(url)

print(response.json())
```

```javascript 当前没有环境预置
const url = 'https://sandbox.xapi.to/v1/environments';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go 当前没有环境预置
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://sandbox.xapi.to/v1/environments"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby 当前没有环境预置
require 'uri'
require 'net/http'

url = URI("https://sandbox.xapi.to/v1/environments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java 当前没有环境预置
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://sandbox.xapi.to/v1/environments")
  .asString();
```

```php 当前没有环境预置
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://sandbox.xapi.to/v1/environments');

echo $response->getBody();
```

```csharp 当前没有环境预置
using RestSharp;

var client = new RestClient("https://sandbox.xapi.to/v1/environments");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift 当前没有环境预置
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox.xapi.to/v1/environments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### 服务商发布 Python 环境后

**Response**

```json
[
  {
    "id": "python-3.12",
    "name": "Python 3.12",
    "offeringCount": 3,
    "description": "Python environment for isolated workloads",
    "image": "python:3.12",
    "os": "linux",
    "architecture": "amd64",
    "language": "python",
    "languageVersion": "3.12"
  }
]
```

**SDK Code**

```python 服务商发布 Python 环境后
import requests

url = "https://sandbox.xapi.to/v1/environments"

response = requests.get(url)

print(response.json())
```

```javascript 服务商发布 Python 环境后
const url = 'https://sandbox.xapi.to/v1/environments';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go 服务商发布 Python 环境后
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://sandbox.xapi.to/v1/environments"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby 服务商发布 Python 环境后
require 'uri'
require 'net/http'

url = URI("https://sandbox.xapi.to/v1/environments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java 服务商发布 Python 环境后
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://sandbox.xapi.to/v1/environments")
  .asString();
```

```php 服务商发布 Python 环境后
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://sandbox.xapi.to/v1/environments');

echo $response->getBody();
```

```csharp 服务商发布 Python 环境后
using RestSharp;

var client = new RestClient("https://sandbox.xapi.to/v1/environments");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift 服务商发布 Python 环境后
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox.xapi.to/v1/environments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```