> ## 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 # Getting an environment {% 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/{id}` Gets an environment. {% two-column-layout %} {% left-column %} ## Parameters {% class="hide-from-toc" id="parameters" %} {% section class="api-ref-property-list" %} **id**: {% mark %}required{% /mark %} `string` Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. {% /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/env_abc123 \ -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"}) environment = client.environments.get(id=created.id) print(environment.id) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript import {GoogleGenAI} from '@google/genai'; const ai = new GoogleGenAI({apiVersion: 'v1beta'}); const environment = await ai.environments.get(created.id); console.log(environment.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; Client client = Client.builder().httpOptions(HttpOptions.builder().apiVersion("v1beta").build()).build(); com.google.genai.gaos.models.environments.Environment environment = client.environments.getEnvironment(envId).environment().orElseThrow(); System.out.println(environment.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.GetEnvironment(ctx, operations.GetEnvironmentRequest{ ID: envID, }) if err != nil { log.Fatal(err) } if res.Environment != nil && res.Environment.ID != "" { fmt.Println(res.Environment.ID) } } ``` {% /tab %} {% /tabs %} {% /right-column %} {% /two-column-layout %} ## Response {% class="hide-from-toc" id="response" %} {% 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 %}