> ## AI Agent Context > Get the complete documentation index at: https://aistudio.google.com/llms.txt > Use this file to discover all available pages. > For the full documentation in a single file, fetch: https://aistudio.google.com/llms-full.txt # Listing environments {% callout type="note" %} This API is in Beta. Endpoints are under `/v1beta/`. {% /callout %} {% mark class="http-get" %}{% icon name="south_west" /%}`GET`{% /mark %} `https://generativelanguage.googleapis.com/v1beta/environments` Lists environments. {% two-column-layout %} {% left-column %} ## Parameters {% class="hide-from-toc" id="parameters" %} {% section class="api-ref-property-list" %} {% details %} {% summary %} **mode**: `string enum` Optional. Filter environments by compute lifecycle mode. {% /summary %} Possible values: - `on_demand` - `self_hosted` {% /details %} {% hr /%} **page_size**: `integer` Optional. Maximum number of environments to return. If unspecified, defaults to 50. Maximum is 1000. {% hr /%} **page_token**: `string` Optional. Pagination token. {% /section %} {% /left-column %} {% right-column class="sticky" %} **Example request** {% class="example-heading" %} {% tabs %} {% tab label="REST" %} ```sh curl -X GET https://generativelanguage.googleapis.com/v1beta/environments \ -H "x-goog-api-key: $GEMINI_API_KEY" ``` {% /tab %} {% tab label="Python" %} ```python from google import genai client = genai.Client(http_options={"api_version": "v1beta"}) response = client.environments.list() for environment in response.environments or []: print(environment.id) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript import {GoogleGenAI} from '@google/genai'; const ai = new GoogleGenAI({apiVersion: 'v1beta'}); const response = await ai.environments.list(); for (const env of response.environments ?? []) { console.log(env.id); } ``` {% /tab %} {% tab label="Java" %} ```java import com.google.genai.Client; import com.google.genai.gaos.models.environments.Environment; import com.google.genai.types.HttpOptions; import com.google.genai.gaos.models.operations.ListEnvironmentsResponse; Client client = Client.builder().httpOptions(HttpOptions.builder().apiVersion("v1beta").build()).build(); ListEnvironmentsResponse response = client.environments.listEnvironmentsDirect(); for (com.google.genai.gaos.models.environments.Environment env : response.listEnvironmentsResponse().flatMap(res -> res.environments()).orElse(List.of())) { System.out.println(env.id().orElse("")); } ``` {% /tab %} {% tab label="Go" %} ```go package main import ( "context" "fmt" "log" "google.golang.org/genai" "google.golang.org/genai/interactions/models/operations" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, &genai.ClientConfig{ HTTPOptions: genai.HTTPOptions{APIVersion: "v1beta"}, }) if err != nil { log.Fatal(err) } res, err := client.Environments.ListEnvironments(ctx, operations.ListEnvironmentsRequest{}) if err != nil { log.Fatal(err) } if res.ListEnvironmentsResponse != nil { for _, env := range res.ListEnvironmentsResponse.Environments { if env.ID != "" { fmt.Println(env.ID) } } } } ``` {% /tab %} {% /tabs %} {% /right-column %} {% /two-column-layout %} ## Response {% class="hide-from-toc" id="response" %} {% section class="api-ref-property-list" %} **environments**: [`Environment`](/api-reference/environments/list-environments#Resource:Environment) `array` Environments belonging to the provided project. {% hr /%} **next_page_token**: `string` Pagination token. {% /section %} ## Resources {% class="hide-from-toc" id="resources" %} ### Environment {% class="hide-from-toc" id="Resource:Environment" %} An execution environment for an agent. **Properties:** {% section class="api-ref-property-list" %} **id**: {% mark %}required{% /mark %} `string` Output only. The ID of the environment. {% hr /%} {% details %} {% summary %} **sources**: `Source array` Sources to be mounted into the environment. {% /summary %} {% details %} {% summary %} **type**: `string enum` {% /summary %} Possible values: - `gcs`: A Cloud Storage bucket. - `inline`: Inline content. - `repository`: A generic repository. The protocol prefix in the source URL identifies the provider (e.g., github://, gcs://). {% /details %} **source**: `string` The source of the environment. For Cloud Storage, this is the Cloud Storage path. For GitHub, this is the GitHub path. **target**: `string` Where the source should appear in the environment. **content**: `string` The inline content if `type` is `INLINE`. **encoding**: `string` Optional encoding for inline content (e.g. `base64`). {% /details %} {% hr /%} **created**: `string` Output only. The time at which the environment was created in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ). {% hr /%} **updated**: `string` Output only. The time at which the environment was last updated in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ). {% hr /%} **last_accessed**: `string` Output only. The time at which the environment was last accessed in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ). {% hr /%} {% details %} {% summary %} **status**: `string enum` Output only. The status of the environment container. {% /summary %} Possible values: - `active`: Output only. The status of the environment container. - `expired`: Output only. The status of the environment container. {% /details %} {% hr /%} {% details %} {% summary %} **network**: `EnvironmentNetworkEgressAllowlist` or `string enum` Network configuration for the environment. {% /summary %} **Possible Types:** {% class="api-ref-label" %} {% details %} {% summary %} **EnvironmentNetworkEgressAllowlist** {% /summary %} Network egress configuration for the environment. {% details %} {% summary %} **allowlist**: `EgressRule array` or `string enum` List of allowed domains and their configurations. Set to `"disabled"` to block all network egress. {% /summary %} **Possible Types:** {% class="api-ref-label" %} {% details %} {% summary %} **EgressRule array** {% /summary %} A single domain allowlist rule with optional header injection. **domain**: {% mark %}required{% /mark %} `string` Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). Use '*' to allow all domains. **transform**: `object` Headers to inject into requests matching this rule. Key: header name (e.g., "Authorization"). Value: header value (e.g., "Bearer your-token"). **credential**: `string` Optional. Reference to a server-managed Credential resource by ID. {% /details %} {% details %} {% summary %} **string enum** {% /summary %} Possible values: - `disabled`: All network egress is blocked. {% /details %} {% /details %} {% /details %} {% details %} {% summary %} **string enum** {% /summary %} Possible values: - `disabled`: All network egress is blocked. {% /details %} {% /details %} {% hr /%} **file_count**: `string` Output only. The number of files in the environment, output only. {% hr /%} **size_bytes**: `string` Output only. The total size of the environment files in bytes, output only. {% hr /%} {% details %} {% summary %} **mode**: `string enum` Output only. The compute lifecycle mode for this environment. {% /summary %} Possible values: - `on_demand`: Output only. The compute lifecycle mode for this environment. - `self_hosted`: Output only. The compute lifecycle mode for this environment. {% /details %} {% hr /%} **custom_config**: `object` Output only. Arbitrary customer-defined JSON configuration passed through to the self-hosted environment poller. Only populated for `self_hosted` environments when configured. {% hr /%} **environment_key**: `string` Output only. Secret token generated upon environment creation for self_hosted environments. Used by the self-hosted sandbox daemon to authenticate polling and streaming requests. Only returned in the CreateEnvironment response; omitted from subsequent GetEnvironment and ListEnvironments calls. {% /section %}