এনভায়রনমেন্ট হলো পরিচালিত লিনাক্স স্যান্ডবক্স, যা এজেন্টদের কোড এক্সিকিউট করতে এবং ফাইল সংরক্ষণ করতে একটি বিচ্ছিন্ন জায়গা দেয়। এগুলো ইন্টারঅ্যাকশন কনটেক্সট থেকে বিচ্ছিন্ন থাকে, ফলে আপনি একাধিক ইন্টারঅ্যাকশনের জন্য একই এনভায়রনমেন্ট পুনরায় ব্যবহার করতে পারেন অথবা যেকোনো সময় নতুন করে শুরু করতে পারেন।
নিম্নলিখিত উদাহরণটি দেখায় কিভাবে একটি নতুন রিমোট এনভায়রনমেন্টের সাথে ইন্টারঅ্যাকশন তৈরি করতে হয় এবং এর আইডি পুনরুদ্ধার করতে হয়:
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Install pandas and matplotlib, verify the imports, and print the versions.",
environment="remote",
)
print(f"Environment ID: {interaction.environment_id}")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Install pandas and matplotlib, verify the imports, and print the versions.",
environment: "remote",
});
console.log(`Environment ID: ${interaction.environment_id}`);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Install pandas and matplotlib, verify the imports, and print the versions."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Environment ID: " + interaction.environmentId().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Install pandas and matplotlib, verify the imports, and print the versions."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.EnvironmentID != nil {
fmt.Printf("Environment ID: %s\n", *res.Interaction.EnvironmentID)
}
}
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Install pandas and matplotlib, verify the imports, and print the versions.",
"environment": "remote"
}'
environment পরামিতি
environment প্যারামিটারটি তিনটি রূপ গ্রহণ করে:
| ফর্ম | উদাহরণ | কখন ব্যবহার করবেন |
|---|---|---|
"remote" | environment="remote" | একটি নতুন স্যান্ডবক্স প্রস্তুত করুন। |
| পরিবেশ আইডি | environment="env_abc123" | বিদ্যমান স্যান্ডবক্সটিকে তার সমস্ত ফাইল ও প্যাকেজসহ পুনরায় ব্যবহার করুন। |
| কনফিগারেশন অবজেক্ট | environment={...} | সোর্স, নেটওয়ার্ক রুল, এনভায়রনমেন্ট ভেরিয়েবল অথবা এগুলোর সমন্বয় ব্যবহার করে একটি নতুন স্যান্ডবক্স প্রস্তুত করুন। |
নিম্নলিখিত উদাহরণগুলিতে environment প্যারামিটার ব্যবহারের তিনটি পদ্ধতি দেখানো হয়েছে।
পাইথন
from google import genai
client = genai.Client()
# Fresh sandbox
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Write a hello world script.",
environment="remote",
)
# Reuse an existing sandbox
interaction_2 = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Modify the script to accept a name argument.",
environment=interaction.environment_id,
previous_interaction_id=interaction.id,
)
# New sandbox with sources
interaction_3 = client.interactions.create(
agent="antigravity-preview-09-2026",
input="List all files and summarize the project.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife",
}
],
},
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// Fresh sandbox
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Write a hello world script.",
environment: "remote",
});
// Reuse an existing sandbox
const interaction2 = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Modify the script to accept a name argument.",
environment: interaction.environment_id,
previous_interaction_id: interaction.id,
});
// New sandbox with sources
const interaction3 = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "List all files and summarize the project.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/octocat/Spoon-Knife",
target: "/workspace/spoon-knife",
},
],
},
});
console.log(interaction.output_text);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
Client client = new Client();
// Fresh sandbox
CreateAgentInteraction params1 = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Write a hello world script."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params1)).interaction().get();
// Reuse an existing sandbox
CreateAgentInteraction params2 = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Modify the script to accept a name argument."))
.environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))
.previousInteractionId(interaction.id().orElse(""))
.build();
Interaction interaction2 = client.interactions.create(CreateInteractionRequestBody.of(params2)).interaction().get();
// New sandbox with sources
Environment env3 = Environment.builder()
.sources(List.of(
Source.builder()
.type(SourceType.REPOSITORY)
.source("https://github.com/octocat/Spoon-Knife")
.target("/workspace/spoon-knife")
.build()
))
.build();
CreateAgentInteraction params3 = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("List all files and summarize the project."))
.environment(CreateAgentInteractionEnvironment.of(env3))
.build();
Interaction interaction3 = client.interactions.create(CreateInteractionRequestBody.of(params3)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
// Fresh sandbox
res1, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Write a hello world script."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res1.Interaction
// Reuse an existing sandbox
res2, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Modify the script to accept a name argument."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(*interaction.EnvironmentID)),
PreviousInteractionID: interaction.ID,
}),
})
if err != nil {
log.Fatal(err)
}
_ = res2
// New sandbox with sources
env3 := interactions.Environment{
Sources: []interactions.Source{
{
Type: interactions.SourceTypeRepository.ToPointer(),
Source: genai.Ptr("https://github.com/octocat/Spoon-Knife"),
Target: genai.Ptr("/workspace/spoon-knife"),
},
},
}
res3, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("List all files and summarize the project."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env3)),
}),
})
if err != nil {
log.Fatal(err)
}
_ = res3
if interaction.OutputText != nil {
fmt.Println(*interaction.OutputText)
}
}
বিশ্রাম
# Fresh sandbox
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": [{"type": "text", "text": "Write a hello world script."}],
"environment": "remote"
}'
# Reuse an existing sandbox (replace $ENV_ID and $INTERACTION_ID with values from the previous response)
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d "{
\"agent\": \"antigravity-preview-09-2026\",
\"input\": [{\"type\": \"text\", \"text\": \"Modify the script to accept a name argument.\"}],
\"environment\": \"$ENV_ID\",
\"previous_interaction_id\": \"$INTERACTION_ID\"
}"
# New sandbox with sources
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": [{"type": "text", "text": "List all files and summarize the project."}],
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife"
}
]
}
}'
একটি পরিবেশ কনফিগার করুন
একটি এনভায়রনমেন্ট সেট আপ করার একটি উপায় হলো এজেন্টকে জানিয়ে দেওয়া যে আপনার কী কী ইনস্টল করা প্রয়োজন। এটি ডিপেন্ডেন্সি রেজোলিউশন এবং ট্রাবলশুটিং পরিচালনা করে। এনভায়রনমেন্ট প্রস্তুত হয়ে গেলে, environment_id সেভ করে রাখুন এবং পুনরায় ব্যবহার করুন।
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
environment="remote",
)
# Reuse the configured environment
interaction_2 = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Clone https://github.com/octocat/Spoon-Knife into /workspace/tools. Run the test suite and fix any missing dependencies.",
environment=interaction.environment_id,
previous_interaction_id=interaction.id,
)
# Reuse the configured environment
interaction_3 = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Using the tools in /workspace/tools, list the files.",
environment=interaction.environment_id,
previous_interaction_id=interaction_2.id,
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
environment: "remote",
});
const interaction2 = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Clone https://github.com/octocat/Spoon-Knife into /workspace/tools. Run the test suite and fix any missing dependencies.",
environment: interaction.environment_id,
previous_interaction_id: interaction.id,
});
const interaction3 = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Using the tools in /workspace/tools, list the files.",
environment: interaction.environment_id,
previous_interaction_id: interaction2.id,
});
console.log(interaction.output_text);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateAgentInteraction params1 = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params1)).interaction().get();
// Reuse the configured environment
CreateAgentInteraction params2 = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Clone https://github.com/octocat/Spoon-Knife into /workspace/tools. Run the test suite and fix any missing dependencies."))
.environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))
.previousInteractionId(interaction.id().orElse(""))
.build();
Interaction interaction2 = client.interactions.create(CreateInteractionRequestBody.of(params2)).interaction().get();
// Reuse the configured environment
CreateAgentInteraction params3 = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Using the tools in /workspace/tools, list the files."))
.environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))
.previousInteractionId(interaction2.id().orElse(""))
.build();
Interaction interaction3 = client.interactions.create(CreateInteractionRequestBody.of(params3)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res1, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res1.Interaction
// Reuse the configured environment
res2, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Clone https://github.com/octocat/Spoon-Knife into /workspace/tools. Run the test suite and fix any missing dependencies."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(*interaction.EnvironmentID)),
PreviousInteractionID: interaction.ID,
}),
})
if err != nil {
log.Fatal(err)
}
interaction2 := res2.Interaction
// Reuse the configured environment
res3, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Using the tools in /workspace/tools, list the files."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(*interaction.EnvironmentID)),
PreviousInteractionID: interaction2.ID,
}),
})
if err != nil {
log.Fatal(err)
}
_ = res3
if interaction.OutputText != nil {
fmt.Println(*interaction.OutputText)
}
}
বিশ্রাম
# Create interaction
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
"environment": "remote"
}'
একটি উৎস থেকে মাউন্ট করুন
এজেন্টের ঠিক কোন ফাইলগুলো প্রয়োজন তা যদি আপনি জানেন, তবে বারবার না করে একটিমাত্র কলে সেগুলোকে মাউন্ট করুন। environment কনফিগ অবজেক্টটি তিন ধরনের sources অ্যারে গ্রহণ করে:
| উৎস প্রকার | type মান | বর্ণনা | সীমা |
|---|---|---|---|
| গিট রিপোজিটরি | repository | একটি URL থেকে রিপোজিটরিকে target -এর স্যান্ডবক্সে ক্লোন করে। | ৫০০ এমবি |
| ক্লাউড স্টোরেজ | gcs | ক্লাউড স্টোরেজ থেকে কোনো ফাইল বা ডিরেক্টরি target -এর স্যান্ডবক্সে কপি করে। | ২ জিবি |
| ইনলাইন কন্টেন্ট | inline | target -এ অবস্থিত স্যান্ডবক্সের একটি ফাইলে মূল টেক্সট কন্টেন্ট লেখে। | প্রতি ফাইলে ১ এমবি, মোট ২ এমবি |
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="List all files under /workspace and describe what you find.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife",
},
{
"type": "gcs",
"source": "gs://cloud-samples-data/bigquery/us-states/",
"target": "/workspace/gcs-data",
},
{
"type": "inline",
"content": "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
"target": "/workspace/notes/readme.md",
},
],
},
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "List all files under /workspace and describe what you find.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/octocat/Spoon-Knife",
target: "/workspace/spoon-knife",
},
{
type: "gcs",
source: "gs://cloud-samples-data/bigquery/us-states/",
target: "/workspace/gcs-data",
},
{
type: "inline",
content: "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
target: "/workspace/notes/readme.md",
},
],
},
});
console.log(interaction.output_text);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
Client client = new Client();
Environment env = Environment.builder()
.sources(List.of(
Source.builder()
.type(SourceType.REPOSITORY)
.source("https://github.com/octocat/Spoon-Knife")
.target("/workspace/spoon-knife")
.build(),
Source.builder()
.type(SourceType.GCS)
.source("gs://cloud-samples-data/bigquery/us-states/")
.target("/workspace/gcs-data")
.build(),
Source.builder()
.type(SourceType.INLINE)
.content("# Project Notes\n\n- Analyze state population data\n- Create visualizations\n")
.target("/workspace/notes/readme.md")
.build()
))
.build();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("List all files under /workspace and describe what you find."))
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
env := interactions.Environment{
Sources: []interactions.Source{
{
Type: interactions.SourceTypeRepository.ToPointer(),
Source: genai.Ptr("https://github.com/octocat/Spoon-Knife"),
Target: genai.Ptr("/workspace/spoon-knife"),
},
{
Type: interactions.SourceTypeGcs.ToPointer(),
Source: genai.Ptr("gs://cloud-samples-data/bigquery/us-states/"),
Target: genai.Ptr("/workspace/gcs-data"),
},
{
Type: interactions.SourceTypeInline.ToPointer(),
Content: genai.Ptr("# Project Notes\n\n- Analyze state population data\n- Create visualizations\n"),
Target: genai.Ptr("/workspace/notes/readme.md"),
},
},
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("List all files under /workspace and describe what you find."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env)),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
বিশ্রাম
# Create interaction with sources
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "List all files under /workspace and describe what you find.",
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife"
},
{
"type": "gcs",
"source": "gs://cloud-samples-data/bigquery/us-states/",
"target": "/workspace/gcs-data"
},
{
"type": "inline",
"content": "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
"target": "/workspace/notes/readme.md"
}
]
}
}'
আপনি উভয় পদ্ধতিই একত্রিত করতে পারেন: পরিচিত সোর্সগুলোকে ডিক্লারেটিভভাবে মাউন্ট করুন, তারপর প্যাকেজ ইনস্টল করতে বা সেটআপ স্ক্রিপ্ট চালাতে ফলো-আপ ইন্টারঅ্যাকশনের মাধ্যমে পুনরাবৃত্তি করুন। কাস্টম সোর্স যোগ করার সময় আপনি রুট ( / ) কে টার্গেট হিসেবে সেট করতে পারবেন না, আপনাকে সর্বদা একটি সাব-ডিরেক্টরি নির্দিষ্ট করতে হবে।
হুক
নিরাপত্তামূলক ব্যবস্থা জোরদার করতে অথবা টুল চালু হওয়ার সাথে সাথে স্বয়ংক্রিয় যাচাইকরণ চালানোর জন্য আপনি স্যান্ডবক্সে একটি .agents/hooks.json কনফিগারেশন ফাইল এবং কাস্টম ইন্টারসেপশন স্ক্রিপ্টও মাউন্ট করতে পারেন। স্কিমা সংজ্ঞা এবং কোড উদাহরণের জন্য, হুকস (Hooks) দেখুন।
ব্যক্তিগত সূত্র
আপনি নেটওয়ার্ক কনফিগারেশনে সোর্স ডোমেইনটি প্রমাণীকরণের মাধ্যমে ব্যক্তিগত গিটহাব রিপোজিটরি বা ব্যক্তিগত ক্লাউড স্টোরেজ বাকেট থেকেও ডাউনলোড করতে পারেন।
একটি উপায় হলো আইডি দ্বারা নির্দেশিত একটি সংরক্ষিত ক্রেডেনশিয়াল , যার ফলে আপনি সিক্রেটটি একবার সংরক্ষণ করেন এবং যে কোনো এনভায়রনমেন্ট যার সেই সোর্সটির প্রয়োজন, সে এটিকে রেফারেন্স করতে পারে:
"network": {
"allowlist": [
{ "domain": "github.com", "credential": "github-production" },
{ "domain": "*" }
]
}
আপনি transform ব্যবহার করে হেডারটি ইনলাইনেও সেট করতে পারেন, যেমনটা নিচের উদাহরণগুলোতে করা হয়েছে। ইগ্রেস প্রক্সি উভয় পদ্ধতিই একইভাবে প্রয়োগ করে, এবং কোনো ক্ষেত্রেই সিক্রেটটি স্যান্ডবক্সের ভেতরে যায় না।
ব্যক্তিগত গিট রিপোজিটরিগুলির জন্য, আপনার গিটহাব পার্সোনাল অ্যাক্সেস টোকেন (PAT) দিয়ে Basic অথেন্টিকেশন ব্যবহার করুন। ইউজারনেম হিসেবে x-oauth-basic ব্যবহার করে টোকেনটি এনকোড করুন:
echo -n "x-oauth-basic:ghp_YourPATHere" | base64
পাইথন
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Run the test for my backend app and fix any issue.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/your-org/backend",
"target": "/backend-app"
}
],
"network": {
"allowlist": [
{
"domain": "github.com",
"transform": {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
)
জাভাস্ক্রিপ্ট
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Run the test for my backend app and fix any issue.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/your-org/backend",
target: "/backend-app"
}
],
network: {
allowlist: [
{
domain: "github.com",
transform: {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
domain: "*"
}
]
}
},
});
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.Allowlist;
import com.google.genai.gaos.models.interactions.AllowlistEntry;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Network;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import com.google.genai.gaos.models.interactions.Transform;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
import java.util.Map;
Client client = new Client();
Environment env = Environment.builder()
.sources(List.of(
Source.builder()
.type(SourceType.REPOSITORY)
.source("https://github.com/your-org/backend")
.target("/backend-app")
.build()
))
.network(Network.of(EnvironmentNetworkEgressAllowlist.of(
Allowlist.builder()
.allowlist(List.of(
AllowlistEntry.builder()
.domain("github.com")
.transform(Transform.of(Map.of(
"Authorization", "Basic YOUR_BASE64_TOKEN"
)))
.build(),
AllowlistEntry.builder()
.domain("*")
.build()
))
.build()
)))
.build();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Run the test for my backend app and fix any issue."))
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
env := interactions.Environment{
Sources: []interactions.Source{
{
Type: interactions.SourceTypeRepository.ToPointer(),
Source: genai.Ptr("https://github.com/your-org/backend"),
Target: genai.Ptr("/backend-app"),
},
},
Network: genai.Ptr(interactions.NewNetwork(interactions.NewEnvironmentNetworkEgressAllowlist(interactions.Allowlist{
Allowlist: []interactions.AllowlistEntry{
{
Domain: "github.com",
Transform: genai.Ptr(interactions.NewTransform(map[string]string{
"Authorization": "Basic YOUR_BASE64_TOKEN",
})),
},
{
Domain: "*",
},
},
}))),
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Run the test for my backend app and fix any issue."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env)),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Run the test for my backend app and fix any issue.",
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/your-org/backend",
"target": "/backend-app"
}
],
"network": {
"allowlist": [
{
"domain": "github.com",
"transform": {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
}'
ব্যক্তিগত ক্লাউড স্টোরেজ বাকেটগুলির জন্য, একটি স্ট্যান্ডার্ড OAuth 2.0 বেয়ারার টোকেন ব্যবহার করুন:
gcloud auth print-access-token
পাইথন
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Analyze the discrepancies across the data in workspace",
environment={
"type": "remote",
"sources": [
{
"type": "gcs",
"source": "gs://my-private-bucket/data",
"target": "/workspace",
}
],
"network": {
"allowlist": [
{
"domain": "*.googleapis.com",
"transform": {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
"domain": "*"
}
]
}
},
)
জাভাস্ক্রিপ্ট
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Analyze the discrepancies across the data in workspace",
environment: {
type: "remote",
sources: [
{
type: "gcs",
source: "gs://my-private-bucket/data",
target: "/workspace",
}
],
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
domain: "*"
}
]
}
},
});
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.Allowlist;
import com.google.genai.gaos.models.interactions.AllowlistEntry;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Network;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import com.google.genai.gaos.models.interactions.Transform;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
import java.util.Map;
Client client = new Client();
Environment env = Environment.builder()
.sources(List.of(
Source.builder()
.type(SourceType.GCS)
.source("gs://my-private-bucket/data")
.target("/workspace")
.build()
))
.network(Network.of(EnvironmentNetworkEgressAllowlist.of(
Allowlist.builder()
.allowlist(List.of(
AllowlistEntry.builder()
.domain("*.googleapis.com")
.transform(Transform.of(Map.of(
"Authorization", "Bearer YOUR_GCS_TOKEN"
)))
.build(),
AllowlistEntry.builder()
.domain("*")
.build()
))
.build()
)))
.build();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Analyze the discrepancies across the data in workspace"))
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
env := interactions.Environment{
Sources: []interactions.Source{
{
Type: interactions.SourceTypeGcs.ToPointer(),
Source: genai.Ptr("gs://my-private-bucket/data"),
Target: genai.Ptr("/workspace"),
},
},
Network: genai.Ptr(interactions.NewNetwork(interactions.NewEnvironmentNetworkEgressAllowlist(interactions.Allowlist{
Allowlist: []interactions.AllowlistEntry{
{
Domain: "*.googleapis.com",
Transform: genai.Ptr(interactions.NewTransform(map[string]string{
"Authorization": "Bearer YOUR_GCS_TOKEN",
})),
},
{
Domain: "*",
},
},
}))),
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Analyze the discrepancies across the data in workspace"),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env)),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Analyze the discrepancies across the data in workspace",
"environment": {
"type": "remote",
"sources": [
{
"type": "gcs",
"source": "gs://my-private-bucket/data",
"target": "/workspace"
}
],
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
}'
আগে থেকে ইনস্টল করা সফটওয়্যার
স্যান্ডবক্সটি উবুন্টুতে চলে এবং এতে রানটাইম ও সাধারণ প্যাকেজগুলো আগে থেকেই ইনস্টল করা থাকে। এজেন্টটি রানটাইমে pip install বা npm install ব্যবহার করে অতিরিক্ত প্যাকেজ ইনস্টল করতে পারে। কোনো ইন্টারঅ্যাকশনের সময় ইনস্টল করা প্যাকেজগুলো একই environment_id পুনরায় ব্যবহার করলেও থেকে যায়।
| বিভাগ | আগে থেকে ইনস্টল করা প্যাকেজগুলি |
|---|---|
| ইউনিক্স টুলস | curl , wget , git , rsync , unzip , ripgrep , fd-find , gawk , bc , tree , which , lsof , htop , jq , iproute2 , procps , gcloud CLI |
| পাইথন ৩.১২ | numpy , pandas , requests , google-genai , beautifulsoup4 , pyyaml , ast-grep-cli |
| নোড.জেএস ২২ | create-next-app , create-vite , typescript |
পরিবেশগত পরিবর্তনশীল
স্যান্ডবক্সের ভিতরে এনভায়রনমেন্ট ভেরিয়েবল সেট করতে env ফিল্ডটি ব্যবহার করুন। প্রতিটি এন্ট্রি একটি ভেরিয়েবলের নামকে কনফিগারেশনের জন্য একটি আক্ষরিক স্ট্রিং অথবা কোনো সিক্রেটের জন্য সংরক্ষিত ক্রেডেনশিয়ালের রেফারেন্সের সাথে ম্যাপ করে। এজেন্ট এগুলোকে যেকোনো শেলের মতোই দেখতে পায়, তাই যে টুল এবং স্ক্রিপ্টগুলো প্রসেস এনভায়রনমেন্ট থেকে ডেটা পড়ে, তারা কোনো অতিরিক্ত সংযোগ ছাড়াই এগুলো গ্রহণ করতে পারে।
| মাঠ | প্রকার | বর্ণনা |
|---|---|---|
env | object | ভেরিয়েবলের নাম এবং মানের একটি ম্যাপ। মানটি হয় একটি আক্ষরিক string অথবা {"credential": "credential-id"} ফর্মের একটি ক্রেডেনশিয়াল রেফারেন্স। |
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Build the project and run the test suite.",
environment={
"type": "remote",
"env": {
"NODE_ENV": "production",
"LOG_LEVEL": "debug",
"API_TOKEN": {"credential": "my-api-token"},
},
},
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Build the project and run the test suite.",
environment: {
type: "remote",
env: {
NODE_ENV: "production",
LOG_LEVEL: "debug",
API_TOKEN: { credential: "my-api-token" },
},
},
});
console.log(interaction.output_text);
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": [{"type": "text", "text": "Build the project and run the test suite."}],
"environment": {
"type": "remote",
"env": {
"NODE_ENV": "production",
"LOG_LEVEL": "debug",
"API_TOKEN": {"credential": "my-api-token"}
}
}
}'
সেই ইন্টারঅ্যাকশনে এজেন্ট কর্তৃক চালিত প্রতিটি কমান্ডের ক্ষেত্রে ভ্যারিয়েবলগুলো প্রযোজ্য হয়, যার মধ্যে শেল কমান্ড, বিল্ড স্টেপ এবং এর দ্বারা শুরু করা যেকোনো প্রসেস অন্তর্ভুক্ত।
এই দুই ধরনের ভ্যালু ভিন্নভাবে কাজ করে। একটি লিটারেল স্ট্রিং কন্টেইনারে সাধারণ টেক্সট হিসেবে লেখা হয়। কিন্তু একটি ক্রেডেনশিয়াল রেফারেন্সের ক্ষেত্রে তা হয় না: ভেরিয়েবলটি একটি প্লেসহোল্ডার গ্রহণ করে, এবং ইগ্রেস প্রক্সি শুধুমাত্র সেই ক্রেডেনশিয়ালের বিশ্বস্ত ডোমেইনগুলোতে পাঠানো অনুরোধের ক্ষেত্রে আসল সিক্রেটটি প্রতিস্থাপন করে। এটি কীভাবে কাজ করে তা জানতে ‘Use credentials as environment variables’ দেখুন।
নেটওয়ার্ক কনফিগারেশন
ডিফল্টরূপে, এনভায়রনমেন্টগুলোর অবাধ আউটবাউন্ড নেটওয়ার্ক অ্যাক্সেস থাকে। নির্দিষ্ট ডোমেইনে আউটবাউন্ড ট্র্যাফিক সীমাবদ্ধ করতে network ফিল্ডটি ব্যবহার করুন। প্রতিটি নিয়মে একটি domain , একটি সংরক্ষিত সিক্রেট ইনজেক্ট করার জন্য একটি ঐচ্ছিক credential এবং ম্যাচিং রিকোয়েস্টগুলোতে হেডার ইনজেক্ট করার জন্য একটি ঐচ্ছিক transform অবজেক্ট নির্দিষ্ট করা থাকে। এই হেডারগুলো প্রতিটি ইন্টারঅ্যাকশনের জন্য স্বতন্ত্র হতে পারে এবং আপনি একই এনভায়রনমেন্টের জন্য এগুলো আপডেট করতে পারেন।
| মাঠ | প্রকার | বর্ণনা |
|---|---|---|
domain | string | ডোমেইন অবশ্যই মেলাতে হবে। সমস্ত ডোমেইনের জন্য সঠিক হোস্টনেম অথবা * ব্যবহার করুন। |
credential | string | সংরক্ষিত ক্রেডেনশিয়ালের আইডি। ইগ্রেস প্রক্সি এটিকে রিজলভ করে এবং রিকোয়েস্টের সময় অথ হেডারটি ইনজেক্ট করে। |
transform | object | সংশ্লিষ্ট অনুরোধগুলিতে ইনজেক্ট করার জন্য হেডারগুলির প্রতিনিধিত্বকারী ফ্ল্যাট কী-ভ্যালু পেয়ার ধারণকারী অবজেক্ট, যেমন {"Authorization": "Bearer ..."} । |
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Fetch the latest issues from the GitHub API for my-org/my-repo.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_your_github_token"
},
},
{"domain": "pypi.org"},
{"domain": "*"},
]
},
},
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Fetch the latest issues from the GitHub API for my-org/my-repo.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "api.github.com",
transform: {
"Authorization": "Bearer ghp_your_github_token"
},
},
{ domain: "pypi.org" },
{ domain: "*" },
]
}
},
});
console.log(interaction.output_text);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.Allowlist;
import com.google.genai.gaos.models.interactions.AllowlistEntry;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Network;
import com.google.genai.gaos.models.interactions.Transform;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
import java.util.Map;
Client client = new Client();
Environment env = Environment.builder()
.network(Network.of(EnvironmentNetworkEgressAllowlist.of(
Allowlist.builder()
.allowlist(List.of(
AllowlistEntry.builder()
.domain("api.github.com")
.transform(Transform.of(Map.of(
"Authorization", "Bearer ghp_your_github_token"
)))
.build(),
AllowlistEntry.builder().domain("pypi.org").build(),
AllowlistEntry.builder().domain("*").build()
))
.build()
)))
.build();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Fetch the latest issues from the GitHub API for my-org/my-repo."))
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
env := interactions.Environment{
Network: genai.Ptr(interactions.NewNetwork(interactions.NewEnvironmentNetworkEgressAllowlist(interactions.Allowlist{
Allowlist: []interactions.AllowlistEntry{
{
Domain: "api.github.com",
Transform: genai.Ptr(interactions.NewTransform(map[string]string{
"Authorization": "Bearer ghp_your_github_token",
})),
},
{
Domain: "pypi.org",
},
{
Domain: "*",
},
},
}))),
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Fetch the latest issues from the GitHub API for my-org/my-repo."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env)),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": [{"type": "text", "text": "Fetch the latest issues from the GitHub API for my-org/my-repo."}],
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_your_github_token"
}
},
{"domain": "pypi.org"},
{"domain": "*"}
]
}
}
}'
যখন একটি অ্যালাওলিস্ট সেট করা হয়, তখন শুধুমাত্র স্পষ্টভাবে তালিকাভুক্ত ডোমেইনগুলিতে করা অনুরোধগুলিই অনুমোদিত হয়। আপনি সাবডোমেইন মেলানোর জন্য ওয়াইল্ডকার্ড ব্যবহার করতে পারেন (যেমন, {"domain": "*.example.com"} ), কিন্তু মনে রাখবেন যে এটি রুট ডোমেইন example.com কে মেলায় না, যা আলাদাভাবে যোগ করতে হবে। অন্য সব ট্র্যাফিককে অনুমতি দেওয়ার জন্য, যেমন ইনজেক্টেড হেডার ছাড়া তালিকাভুক্ত নয় এমন ডোমেইন রাউটিং করার জন্য, {"domain": "*"} একটি ক্যাচ-অল এন্ট্রি হিসেবে যোগ করুন।
যোগ্যতা
আউটবাউন্ড ট্র্যাফিক প্রমাণীকরণের দুটি উপায় আছে: একটি হলো আইডি দ্বারা নির্দেশিত সংরক্ষিত ক্রেডেনশিয়াল এবং অন্যটি হলো অ্যালাওলিস্ট রুলে একটি ইনলাইন transform । ইগ্রেস প্রক্সি ওয়্যারে উভয় পদ্ধতিই প্রয়োগ করে, তাই উভয় ক্ষেত্রেই সিক্রেটটি কখনও স্যান্ডবক্সে প্রবেশ করে না এবং আপনার ইন্টারঅ্যাকশন পেলোডগুলিতেও কখনও প্রদর্শিত হয় না।
যখন আপনি কোনো গোপনীয় তথ্য একবার সংরক্ষণ করে পুনরায় ব্যবহার করতে চান, তখন ম্যানেজড ক্রেডেনশিয়ালই হলো সেরা উপায়। আপনার প্রোজেক্টের প্রতিটি এনভায়রনমেন্ট, এজেন্ট এবং ট্রিগার একই আইডি রেফারেন্স করতে পারে এবং আপনি এক জায়গা থেকেই সেটির পরিবর্তন বা আবর্তন করতে পারেন।
পাইথন
from google import genai
client = genai.Client()
# Store the secret once
client.credentials.create(
id="github-production",
type="bearer_token",
token="ghp_your_github_token",
)
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Fetch the latest issues from the GitHub API for my-org/my-repo.",
environment={
"type": "remote",
"network": {
"allowlist": [
{"domain": "api.github.com", "credential": "github-production"},
{"domain": "*"},
]
},
},
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// Store the secret once
await client.credentials.create({
id: "github-production",
type: "bearer_token",
token: "ghp_your_github_token",
});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Fetch the latest issues from the GitHub API for my-org/my-repo.",
environment: {
type: "remote",
network: {
allowlist: [
{ domain: "api.github.com", credential: "github-production" },
{ domain: "*" },
]
}
},
});
console.log(interaction.output_text);
বিশ্রাম
# Store the secret once
curl -X POST "https://generativelanguage.googleapis.com/v1beta/credentials" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"id": "github-production",
"type": "bearer_token",
"token": "ghp_your_github_token"
}'
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Fetch the latest issues from the GitHub API for my-org/my-repo.",
"environment": {
"type": "remote",
"network": {
"allowlist": [
{ "domain": "api.github.com", "credential": "github-production" },
{ "domain": "*" }
]
}
}
}'
একটি oauth2 ক্রেডেনশিয়াল তার অ্যাক্সেস টোকেনও স্বয়ংক্রিয়ভাবে রিফ্রেশ করে, ফলে টোকেনের মেয়াদ শেষ হয়ে গেলেও দীর্ঘস্থায়ী কোনো ইন্টারঅ্যাকশন ভেঙে যায় না। ক্রেডেনশিয়ালের প্রকারভেদ এবং ব্যবস্থাপনা কার্যক্রমের সম্পূর্ণ তালিকার জন্য ক্রেডেনশিয়ালস (Credentials) দেখুন।
আপনি transform সাথে ইনলাইনেও হেডার সেট করতে পারেন। এটি তখন প্রযোজ্য হয় যখন ভ্যালুটি একটিমাত্র কলের অন্তর্গত হয়, যেমন একটি টোকেন যা আপনি ইন্টারঅ্যাকশন তৈরি করার ঠিক আগে জেনারেট করেন। এইভাবে সেট করা হেডারগুলো একই ইগ্রেস প্রক্সি দ্বারা ইনজেক্ট করা হয়, এগুলো স্যান্ডবক্সের ভেতরে এনভায়রনমেন্ট ভেরিয়েবল বা ফাইল হিসেবে কখনোই প্রকাশ করা হয় না।
পাইথন
import subprocess
from google import genai
# Fetch a short-lived access token from your local gcloud CLI
gcloud_token = subprocess.check_output(
["gcloud", "auth", "print-access-token"], text=True
).strip()
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": f"Bearer {gcloud_token}"
},
}
]
},
},
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import { execSync } from "child_process";
const gcloudToken = execSync("gcloud auth print-access-token").toString().trim();
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": `Bearer ${gcloudToken}`
},
}
]
}
},
});
console.log(interaction.output_text);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.Allowlist;
import com.google.genai.gaos.models.interactions.AllowlistEntry;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Network;
import com.google.genai.gaos.models.interactions.Transform;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
// Fetch a short-lived access token from your local gcloud CLI
Process process = new ProcessBuilder("gcloud", "auth", "print-access-token").start();
String gcloudToken = new String(process.getInputStream().readAllBytes(), StandardCharsets.UTF_8).trim();
Client client = new Client();
Environment env = Environment.builder()
.network(Network.of(EnvironmentNetworkEgressAllowlist.of(
Allowlist.builder()
.allowlist(List.of(
AllowlistEntry.builder()
.domain("storage.googleapis.com")
.transform(Transform.of(Map.of(
"Authorization", "Bearer " + gcloudToken
)))
.build()
))
.build()
)))
.build();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("List the files in gs://my-bucket/reports/ using the GCS JSON API."))
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"os/exec"
"strings"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
// Fetch a short-lived access token from your local gcloud CLI
out, err := exec.Command("gcloud", "auth", "print-access-token").Output()
if err != nil {
log.Fatal(err)
}
gcloudToken := strings.TrimSpace(string(out))
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
env := interactions.Environment{
Network: genai.Ptr(interactions.NewNetwork(interactions.NewEnvironmentNetworkEgressAllowlist(interactions.Allowlist{
Allowlist: []interactions.AllowlistEntry{
{
Domain: "storage.googleapis.com",
Transform: genai.Ptr(interactions.NewTransform(map[string]string{
"Authorization": "Bearer " + gcloudToken,
})),
},
},
}))),
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("List the files in gs://my-bucket/reports/ using the GCS JSON API."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env)),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "List the files in gs://my-bucket/reports/ using the GCS JSON API.",
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer <YOUR_GCLOUD_TOKEN>"
}
}
]
}
}
}'
credential এবং transform একই রুলে থাকতে পারে। ক্রেডেনশিয়াল প্রথমে প্রয়োগ করা হয় এবং transform তার উপরে মার্জ হয়, তাই যদি উভয়ই একই কী সেট করে, তবে একটি সুস্পষ্ট transform হেডার প্রাধান্য পায়। একটি সাধারণ প্যাটার্ন হলো অথেনটিকেশন হেডারের জন্য ক্রেডেনশিয়াল এবং এর পাশাপাশি সার্ভিস দ্বারা প্রত্যাশিত অতিরিক্ত হেডারগুলোর জন্য transform ।
নেটওয়ার্ক অ্যাক্সেস নিষ্ক্রিয় করুন
সমস্ত বহির্গামী নেটওয়ার্ক অ্যাক্সেস ব্লক করতে, network disabled করুন:
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Analyze the local files only.",
environment={
"type": "remote",
"network": "disabled",
},
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Analyze the local files only.",
environment: {
type: "remote",
network: "disabled",
},
});
console.log(interaction.output_text);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Network;
import com.google.genai.gaos.models.interactions.NetworkEnum;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
Environment env = Environment.builder()
.network(Network.of(NetworkEnum.DISABLED))
.build();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Analyze the local files only."))
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
env := interactions.Environment{
Network: genai.Ptr(interactions.NewNetwork(interactions.NetworkEnumDisabled)),
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Analyze the local files only."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env)),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Analyze the local files only.",
"environment": {
"type": "remote",
"network": "disabled"
}
}'
পরিচয়পত্র রিফ্রেশ করুন
অ্যাক্সেস টোকেন এবং স্বল্পস্থায়ী এপিআই কী-এর মতো ইনলাইন টোকেনগুলোর মেয়াদ শেষ হয়ে যায়। পরবর্তী ইন্টারঅ্যাকশনের সময় বিদ্যমান environment_id সাথে একটি নতুন network কনফিগারেশন পাস করে আপনি এগুলো রিফ্রেশ করতে পারেন। নতুন নেটওয়ার্ক নিয়মগুলো আগেরগুলোকে সম্পূর্ণরূপে প্রতিস্থাপন করে, তবে এনভায়রনমেন্টের ফাইল সিস্টেমের অবস্থা (ইনস্টল করা প্যাকেজ, ফাইল, রিপোজিটরি) সংরক্ষিত থাকে।
এর পরিবর্তে যদি আপনি একটি সংরক্ষিত ক্রেডেনশিয়াল ব্যবহার করেন, তাহলে আপনার এটির প্রয়োজন নেই। একটি oauth2 ক্রেডেনশিয়াল নিজে থেকেই রিফ্রেশ হয়, এবং যেকোনো ক্রেডেনশিয়াল রোটেট করা হলো সেটির উপর একটি PATCH প্রয়োগ, যা সেটিকে উল্লেখকারী প্রতিটি allowlist রুলকে অক্ষত রাখে।
পাইথন
from google import genai
client = genai.Client()
# First interaction: use an initial token
first = client.interactions.create(
agent="antigravity-preview-09-2026",
input="List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer INITIAL_TOKEN"
},
}
]
},
},
)
# Later: refresh the token on the same environment
result = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Now download the file reports/q1.csv from the same bucket.",
environment={
"type": "remote",
"environment_id": first.environment_id,
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer REFRESHED_TOKEN"
},
}
]
},
},
)
print(result.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// First interaction: use an initial token
const first = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": "Bearer INITIAL_TOKEN"
},
}
]
}
},
});
// Later: refresh the token on the same environment
const result = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Now download the file reports/q1.csv from the same bucket.",
environment: {
type: "remote",
environment_id: first.environment_id,
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": "Bearer REFRESHED_TOKEN"
},
}
]
}
},
});
console.log(result.output_text);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.Allowlist;
import com.google.genai.gaos.models.interactions.AllowlistEntry;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Network;
import com.google.genai.gaos.models.interactions.Transform;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
import java.util.Map;
Client client = new Client();
// First interaction: use an initial token
Environment initialEnv = Environment.builder()
.network(Network.of(EnvironmentNetworkEgressAllowlist.of(
Allowlist.builder()
.allowlist(List.of(
AllowlistEntry.builder()
.domain("storage.googleapis.com")
.transform(Transform.of(Map.of(
"Authorization", "Bearer INITIAL_TOKEN"
)))
.build()
))
.build()
)))
.build();
CreateAgentInteraction firstParams = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("List the files in gs://my-bucket/reports/ using the GCS JSON API."))
.environment(CreateAgentInteractionEnvironment.of(initialEnv))
.build();
Interaction first = client.interactions.create(CreateInteractionRequestBody.of(firstParams)).interaction().get();
// Later: refresh the token on the same environment
Environment refreshedEnv = Environment.builder()
.environmentId(first.environmentId().orElse(""))
.network(Network.of(EnvironmentNetworkEgressAllowlist.of(
Allowlist.builder()
.allowlist(List.of(
AllowlistEntry.builder()
.domain("storage.googleapis.com")
.transform(Transform.of(Map.of(
"Authorization", "Bearer REFRESHED_TOKEN"
)))
.build()
))
.build()
)))
.build();
CreateAgentInteraction secondParams = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Now download the file reports/q1.csv from the same bucket."))
.environment(CreateAgentInteractionEnvironment.of(refreshedEnv))
.build();
Interaction result = client.interactions.create(CreateInteractionRequestBody.of(secondParams)).interaction().get();
System.out.println(result.outputText().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
// First interaction: use an initial token
initialEnv := interactions.Environment{
Network: genai.Ptr(interactions.NewNetwork(interactions.NewEnvironmentNetworkEgressAllowlist(interactions.Allowlist{
Allowlist: []interactions.AllowlistEntry{
{
Domain: "storage.googleapis.com",
Transform: genai.Ptr(interactions.NewTransform(map[string]string{
"Authorization": "Bearer INITIAL_TOKEN",
})),
},
},
}))),
}
firstRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("List the files in gs://my-bucket/reports/ using the GCS JSON API."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(initialEnv)),
}),
})
if err != nil {
log.Fatal(err)
}
first := firstRes.Interaction
// Later: refresh the token on the same environment
refreshedEnv := interactions.Environment{
EnvironmentID: first.EnvironmentID,
Network: genai.Ptr(interactions.NewNetwork(interactions.NewEnvironmentNetworkEgressAllowlist(interactions.Allowlist{
Allowlist: []interactions.AllowlistEntry{
{
Domain: "storage.googleapis.com",
Transform: genai.Ptr(interactions.NewTransform(map[string]string{
"Authorization": "Bearer REFRESHED_TOKEN",
})),
},
},
}))),
}
secondRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Now download the file reports/q1.csv from the same bucket."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(refreshedEnv)),
}),
})
if err != nil {
log.Fatal(err)
}
if secondRes.Interaction.OutputText != nil {
fmt.Println(*secondRes.Interaction.OutputText)
}
}
বিশ্রাম
# Use the environment_id from a previous interaction
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Now download the file reports/q1.csv from the same bucket.",
"environment": {
"type": "remote",
"environment_id": "<ENVIRONMENT_ID_FROM_PREVIOUS_INTERACTION>",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer REFRESHED_TOKEN"
}
}
]
}
}
}'
পরিবেশের জীবনচক্র
পরিবেশসমূহ এই জীবনচক্র অনুসরণ করে:
| রাজ্য | আচরণ |
|---|---|
| তৈরি করা হয়েছে | যখন কোনো ইন্টারঅ্যাকশনে environment: "remote" বা একটি কনফিগ অবজেক্ট নির্দিষ্ট করা থাকে, তখন এটি সরবরাহ করা হয়। |
| সক্রিয় | কোনো মিথস্ক্রিয়া চলাকালীন চলছে। |
| নিষ্ক্রিয় | স্বয়ংক্রিয়ভাবে ছবি তোলা শুরু হয় এবং ১৫ মিনিট নিষ্ক্রিয় থাকার পর তা বন্ধ হয়ে যায়। |
| অফলাইন | শেষবার সক্রিয় হওয়ার পর থেকে ৭ দিনের জন্য সংরক্ষিত। এর আইডি দিয়ে পুনরায় চালু করা যাবে। |
| মুছে ফেলা হয়েছে | ৭-দিনের টিটিএল মেয়াদ শেষ হওয়ার পর অথবা ম্যানুয়ালি মুছে ফেলার পর সিস্টেম থেকে স্বয়ংক্রিয়ভাবে অপসারিত হয়। |
পরিবেশ এপিআই
আপনি প্রোগ্রাম্যাটিকভাবে স্যান্ডবক্স সেশন পরিচালনা করতে এনভায়রনমেন্টস এপিআই (Environments API) ব্যবহার করতে পারেন। এনভায়রনমেন্টগুলো গণনা করার মাধ্যমে আপনি সক্রিয় সেশন আইডিগুলো খুঁজে বের করতে পারেন এবং কোনো দীর্ঘস্থায়ী টাস্ক চলাকালীন ক্লায়েন্ট সংযোগ বিচ্ছিন্ন হয়ে গেলে তার অবস্থা পুনরুদ্ধার করতে পারেন। এছাড়াও, আপনি সেশন মেটাডেটা পরীক্ষা করতে পারেন এবং ওয়ার্কফ্লো শেষ হয়ে গেলে স্বয়ংক্রিয় টিটিএল (TTL) মেয়াদ শেষ হওয়ার জন্য অপেক্ষা না করে সুস্পষ্টভাবে এনভায়রনমেন্টগুলো মুছে ফেলতে পারেন।
পরিবেশ তালিকাভুক্ত করুন
আপনার প্রোজেক্টের সক্রিয় এনভায়রনমেন্টগুলোর তালিকা দেখুন। রেসপন্স ব্যাচ সাইজ নিয়ন্ত্রণ করতে পেজিনেশন প্যারামিটার ব্যবহার করুন।
পাইথন
from google import genai
client = genai.Client()
response = client.environments.list(page_size=10)
for env in response.environments:
print(f"Environment ID: {env.id}, Status: {env.status}")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const response = await client.environments.list({ page_size: 10 });
for (const env of response.environments) {
console.log(`Environment ID: ${env.id}, Status: ${env.status}`);
}
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.environments.Environment;
import com.google.genai.gaos.models.environments.ListEnvironmentsResponse;
import java.util.List;
Client client = new Client();
ListEnvironmentsResponse response = client.environments.listEnvironments()
.pageSize(10)
.call()
.listEnvironmentsResponse()
.get();
for (Environment env : response.environments().orElse(List.of())) {
System.out.println("Environment ID: " + env.id().orElse("") + ", Status: " + env.status().orElse(null));
}
যান
package main
import (
"context"
"fmt"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
res, err := sdk.Environments.ListEnvironments(ctx, operations.ListEnvironmentsRequest{
PageSize: genai.Ptr(10),
})
if err != nil {
log.Fatal(err)
}
if res.ListEnvironmentsResponse != nil {
for _, env := range res.ListEnvironmentsResponse.Environments {
fmt.Printf("Environment ID: %s, Status: %v\n", env.ID, env.Status)
}
}
}
বিশ্রাম
curl -X GET "https://generativelanguage.googleapis.com/v1beta/environments?pageSize=10" \
-H "x-goog-api-key: $GEMINI_API_KEY"
প্রতিক্রিয়াটি দেখতে নিম্নলিখিতের অনুরূপ:
{
"environments": [
{
"id": "140128b2a13c12c00a5a0d8cf7af9469",
"status": "active"
},
{
"id": "362b738275a1d74af6f1c62bc050da73",
"status": "active"
}
],
"next_page_token": "Cj...5aE="
}
একটি পরিবেশ পান
রিসোর্স নামের মাধ্যমে একটি নির্দিষ্ট এনভায়রনমেন্টের মেটাডেটা ও কনফিগারেশন বিবরণ পুনরুদ্ধার করুন।
পাইথন
from google import genai
client = genai.Client()
env = client.environments.get(id="YOUR_ENVIRONMENT_ID")
print(f"Environment ID: {env.id}, Status: {env.status}")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const env = await client.environments.get("YOUR_ENVIRONMENT_ID");
console.log(`Environment ID: ${env.id}, Status: ${env.status}`);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.environments.Environment;
Client client = new Client();
Environment env = client.environments.getEnvironment("YOUR_ENVIRONMENT_ID").environment().get();
System.out.println("Environment ID: " + env.id().orElse("") + ", Status: " + env.status().orElse(null));
যান
package main
import (
"context"
"fmt"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
res, err := sdk.Environments.GetEnvironment(ctx, operations.GetEnvironmentRequest{
ID: "YOUR_ENVIRONMENT_ID",
})
if err != nil {
log.Fatal(err)
}
env := res.Environment
fmt.Printf("Environment ID: %s, Status: %v\n", env.ID, env.Status)
}
বিশ্রাম
curl -X GET "https://generativelanguage.googleapis.com/v1beta/environments/YOUR_ENVIRONMENT_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
প্রতিক্রিয়াটি দেখতে নিম্নলিখিতের অনুরূপ:
{
"id": "140128b2a13c12c00a5a0d8cf7af9469",
"status": "active",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife"
}
],
"network": {
"allowlist": [
{
"domain": "api.github.com"
},
{
"domain": "github.com"
}
]
}
}
একটি পরিবেশ মুছে ফেলুন
আপনার টাস্ক বা পাইপলাইন শেষ হলে স্যান্ডবক্স রিসোর্স পরিষ্কার করার জন্য পরিবেশটি স্পষ্টভাবে বন্ধ করে দিন এবং মুছে ফেলুন।
পাইথন
from google import genai
client = genai.Client()
client.environments.delete(id="YOUR_ENVIRONMENT_ID")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
await client.environments.delete("YOUR_ENVIRONMENT_ID");
জাভা
import com.google.genai.Client;
Client client = new Client();
client.environments.deleteEnvironment("YOUR_ENVIRONMENT_ID");
যান
package main
import (
"context"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
_, err := sdk.Environments.DeleteEnvironment(ctx, operations.DeleteEnvironmentRequest{
ID: "YOUR_ENVIRONMENT_ID",
})
if err != nil {
log.Fatal(err)
}
}
বিশ্রাম
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/environments/YOUR_ENVIRONMENT_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
পরিবেশে ফাইলগুলি পরিচালনা করুন
এজেন্টটি কার্য সম্পাদনের সময় স্যান্ডবক্সের ভিতরে ফাইল তৈরি ও পরিবর্তন করে। আপনি ডিরেক্টরির বিষয়বস্তু ব্রাউজ করতে, ফাইলের মেটাডেটা পেতে, পৃথক ফাইল বা সম্পূর্ণ ডিরেক্টরি ট্যার আর্কাইভ হিসাবে ডাউনলোড করতে এবং সরাসরি পরিবেশে ফাইল আপলোড বা আর্কাইভ এক্সট্র্যাক্ট করতে পারেন। স্যান্ডবক্স পরিবেশে স্টোরেজ ন্যায্য ব্যবহারের সীমার অধীন।
একটি ডিরেক্টরিতে ফাইলগুলির তালিকা
এনভায়রনমেন্টে থাকা কোনো ডিরেক্টরির বিষয়বস্তু তালিকাভুক্ত করুন। ডিফল্টরূপে, এটি রুট ডিরেক্টরি তালিকাভুক্ত করে।
কোয়েরি প্যারামিটার
| প্যারামিটার | প্রকার | বর্ণনা |
|---|---|---|
recursive | বুলিয়ান | true হলে, সমস্ত ফাইল ও ডিরেক্টরি রিকার্সিভলি তালিকাভুক্ত করে। ডিফল্ট: false । |
পাইথন
from google import genai
client = genai.Client()
# List root directory
response = client.environments.files.list(
environment="YOUR_ENVIRONMENT_ID",
path="",
)
for file in response.files:
print(f"{file.name} ({file.type}) - {file.path}")
# List a subdirectory recursively
response = client.environments.files.list(
environment="YOUR_ENVIRONMENT_ID",
path="src",
recursive=True,
)
for file in response.files:
print(f"{file.name} ({file.type}) - {file.path}")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// List root directory
const response = await client.environments.files.list({
environment: "YOUR_ENVIRONMENT_ID",
path: "",
});
for (const file of response.files) {
console.log(`${file.name} (${file.type}) - ${file.path}`);
}
// List a subdirectory recursively
const srcResponse = await client.environments.files.list({
environment: "YOUR_ENVIRONMENT_ID",
path: "src",
recursive: true,
});
for (const file of srcResponse.files) {
console.log(`${file.name} (${file.type}) - ${file.path}`);
}
বিশ্রাম
# List root directory
curl -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files" \
-H "x-goog-api-key: $GEMINI_API_KEY"
# List a subdirectory
curl -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files/src" \
-H "x-goog-api-key: $GEMINI_API_KEY"
# List all files recursively
curl -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files?recursive=true" \
-H "x-goog-api-key: $GEMINI_API_KEY"
প্রতিক্রিয়াটি প্রতিটি এন্ট্রির মেটাডেটা সহ একটি files অ্যারে ফেরত দেয়:
{
"files": [
{
"name": "config",
"path": "config",
"type": "DIRECTORY",
"created": "2026-08-12T07:44:18Z",
"modified": "2026-08-12T07:44:18Z"
},
{
"name": "main.py",
"path": "src/main.py",
"type": "FILE",
"size_bytes": "15",
"mime_type": "text/x-python; charset=utf-8",
"created": "2026-08-12T07:44:20Z",
"modified": "2026-08-12T07:44:20Z"
}
]
}
ফাইল এন্ট্রি ক্ষেত্রগুলি
| মাঠ | প্রকার | বর্ণনা |
|---|---|---|
name | স্ট্রিং | ফাইল বা ডিরেক্টরির নাম। |
path | স্ট্রিং | এনভায়রনমেন্ট রুটের সাপেক্ষে সম্পূর্ণ পাথ। |
type | স্ট্রিং | FILE অথবা DIRECTORY । |
size_bytes | স্ট্রিং | ফাইলের আকার বাইটে (শুধুমাত্র ফাইলের ক্ষেত্রে)। |
mime_type | স্ট্রিং | MIME টাইপ (শুধুমাত্র ফাইলের জন্য)। |
created | স্ট্রিং | ISO 8601 তৈরির সময়চিহ্ন। |
modified | স্ট্রিং | ISO 8601 সর্বশেষ পরিবর্তনের টাইমস্ট্যাম্প। |
ফাইলের মেটাডেটা পান
পাথ অনুযায়ী একটি নির্দিষ্ট ফাইলের মেটাডেটা পান।
পাইথন
from google import genai
client = genai.Client()
response = client.environments.files.list(
environment="YOUR_ENVIRONMENT_ID",
path="src/main.py",
)
file = response.files[0]
print(f"Name: {file.name}, Size: {file.size_bytes} bytes, Type: {file.mime_type}")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const response = await client.environments.files.list({
environment: "YOUR_ENVIRONMENT_ID",
path: "src/main.py",
});
const file = response.files[0];
console.log(`Name: ${file.name}, Size: ${file.size_bytes} bytes, Type: ${file.mime_type}`);
বিশ্রাম
curl -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files/src/main.py" \
-H "x-goog-api-key: $GEMINI_API_KEY"
প্রতিক্রিয়াটি একটি files অ্যারেতে মোড়ানো ফাইল মেটাডেটা ফেরত দেয়:
{
"files": [
{
"name": "main.py",
"path": "src/main.py",
"type": "FILE",
"size_bytes": "15",
"mime_type": "text/x-python; charset=utf-8",
"created": "2026-08-12T07:44:20Z",
"modified": "2026-08-12T07:44:20Z"
}
]
}
ফাইলটি বিদ্যমান না থাকলে, এপিআই একটি 404 ত্রুটি ফেরত দেয়:
{
"error": {
"message": "Path 'nonexistent.txt' not found in environment 'ENV_ID'.",
"code": "not_found"
}
}
একটি ফাইল ডাউনলোড করুন
একটি নির্দিষ্ট ফাইলের বিষয়বস্তু ডাউনলোড করুন। SDK-গুলোতে download() মেথডটি ব্যবহার করুন। REST রিকোয়েস্টের ক্ষেত্রে, ফাইল পাথের সাথে ?alt=media কোয়েরি প্যারামিটারটি যুক্ত করুন। সার্ভার 200 OK দিয়ে সাড়া দেয় এবং ফাইলের মূল বিষয়বস্তু স্ট্রিম করে।
পাইথন
from google import genai
client = genai.Client()
content = client.environments.files.download(
environment="YOUR_ENVIRONMENT_ID",
path="src/main.py",
)
with open("main.py", "wb") as f:
f.write(content)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import * as fs from "fs";
const client = new GoogleGenAI({});
const bytes = await client.environments.files.download({
environment: "YOUR_ENVIRONMENT_ID",
path: "src/main.py",
});
fs.writeFileSync("main.py", Buffer.from(bytes));
বিশ্রাম
curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files/src/main.py?alt=media" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-o main.py
একটি ডিরেক্টরিকে ট্যার আর্কাইভ হিসেবে ডাউনলোড করুন
সম্পূর্ণ ডিরেক্টরিটি একটি tar আর্কাইভ হিসাবে ডাউনলোড করতে, ?alt=media সহ ডিরেক্টরি পাথটি অনুরোধ করুন। এটি একটি POSIX tar ফাইল ফেরত দেয় (gzipped নয়)। নেস্টেড সাবডিরেক্টরি অন্তর্ভুক্ত করতে recursive=true ব্যবহার করুন।
পাইথন
import tarfile
from google import genai
client = genai.Client()
# Download a subdirectory archive
archive = client.environments.files.download(
environment="YOUR_ENVIRONMENT_ID",
path="src",
)
with open("src.tar", "wb") as f:
f.write(archive)
with tarfile.open("src.tar") as tar:
tar.extractall(path="./extracted")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import { execSync } from "child_process";
import * as fs from "fs";
const client = new GoogleGenAI({});
// Download a subdirectory archive
const bytes = await client.environments.files.download({
environment: "YOUR_ENVIRONMENT_ID",
path: "src",
});
fs.writeFileSync("src.tar", Buffer.from(bytes));
execSync("tar -xf src.tar -C ./extracted");
বিশ্রাম
# Download a subdirectory (top-level files only)
curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files/src?alt=media" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-o src.tar
# Download a subdirectory recursively (includes nested directories)
curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files/config?alt=media&recursive=true" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-o config.tar
# Download root directory
curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files?alt=media" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-o snapshot.tar
# Extract the archive
tar xf snapshot.tar -C ./extracted
আচরণ ম্যাট্রিক্স
নিম্নলিখিত আচরণ ম্যাট্রিক্সটি ফাইল ও ডিরেক্টরি এন্ডপয়েন্ট, HTTP মেথড এবং কোয়েরি প্যারামিটার জুড়ে প্রত্যাশিত প্রতিক্রিয়া এবং আর্কাইভ আচরণের সারসংক্ষেপ তুলে ধরে:
| অনুরোধ | alt | recursive | extract | overwrite | প্রতিক্রিয়া |
|---|---|---|---|---|---|
GET /files | (কিছুই না) | (কিছুই না) | - | - | রুট ডিরেক্টরির JSON তালিকা |
GET /files/{path} (ফাইল) | (কিছুই না) | - | - | - | ফাইলটির জন্য JSON মেটাডেটা |
GET /files/{path} (dir) | (কিছুই না) | false | - | - | নিকটতম চাইল্ডদের JSON তালিকা |
GET /files/{path} (dir) | (কিছুই না) | true | - | - | সমস্ত বংশধরদের JSON তালিকা |
GET /files/{path}?alt=media (file) | media | - | - | - | কাঁচা ফাইলের বিষয়বস্তু |
GET /files/{path}?alt=media (dir) | media | false | - | - | ডিরেক্টরিতে তাৎক্ষণিক ফাইলগুলির ট্যার আর্কাইভ |
GET /files/{path}?alt=media (dir) | media | true | - | - | পুনরাবৃত্তিমূলকভাবে সমস্ত ফাইলের ট্যার আর্কাইভ |
GET /files?alt=media | media | false | - | - | শুধুমাত্র রুট-স্তরের ফাইলগুলির ট্যার আর্কাইভ |
PUT /files/{path} (ফাইল) | - | - | false | false | ফাইলটিকে নির্দিষ্ট পাথে লেখে। ফাইলটি আগে থেকে বিদ্যমান থাকলে 409 Conflict রিটার্ন করে। |
PUT /files/{path}?overwrite=true | - | - | false | true | পাথে ফাইলটি লেখে বা ওভাররাইট করে |
PUT /files/{path}?extract=true | - | - | true | false | আর্কাইভটি গন্তব্য ডিরেক্টরিতে আনপ্যাক করে। কোনো টার্গেট ফাইল বিদ্যমান থাকলে 409 Conflict রিটার্ন করে। |
PUT /files/{path}?extract=true&overwrite=true | - | - | true | true | আর্কাইভটি আনপ্যাক করে এবং বিদ্যমান ফাইলগুলো প্রতিস্থাপন করে। |
পরিবেশে ফাইল আপলোড করুন
HTTP PUT ব্যবহার করে সরাসরি একটি বিদ্যমান এনভায়রনমেন্ট স্যান্ডবক্সে স্বতন্ত্র ফাইল বা ডিরেক্টরি আর্কাইভ আপলোড করুন। প্যারেন্ট ডিরেক্টরি বিদ্যমান না থাকলে তা স্বয়ংক্রিয়ভাবে তৈরি হয়ে যায়। এনভায়রনমেন্টের স্টোরেজ ন্যায্য ব্যবহারের সীমার অধীন।
একটি ফাইল আপলোড করুন
পাইথন
from google import genai
client = genai.Client()
with open("local_file.txt", "rb") as f:
result = client.environments.files.upload(
environment="YOUR_ENVIRONMENT_ID",
path="workspace/data/file.txt",
file=f,
mime_type="text/plain",
overwrite=True,
)
file = result.files[0]
print(f"Uploaded: {file.name} ({file.size_bytes} bytes)")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import * as fs from "fs";
const client = new GoogleGenAI({});
const content = fs.readFileSync("local_file.txt");
const result = await client.environments.files.upload({
environment: "YOUR_ENVIRONMENT_ID",
path: "workspace/data/file.txt",
file: content,
mime_type: "text/plain",
overwrite: true,
});
const file = result.files[0];
console.log(`Uploaded: ${file.name} (${file.size_bytes} bytes)`);
বিশ্রাম
curl -X PUT "https://generativelanguage.googleapis.com/upload/v1beta/environments/$ENV_ID/files/workspace/data/file.txt" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: text/plain" \
--data-binary @local_file.txt
প্রতিক্রিয়াটি আপলোড করা ফাইলের মেটাডেটা ফেরত দেয়, যা তালিকা এবং গেট এন্ডপয়েন্টগুলির সাথে সামঞ্জস্য রাখার জন্য একটি files অ্যারেতে মোড়ানো থাকে:
{
"files": [
{
"name": "file.txt",
"path": "workspace/data/file.txt",
"type": "FILE",
"size_bytes": "1024",
"mime_type": "text/plain"
}
]
}
একটি ডিরেক্টরি আর্কাইভ আপলোড এবং নিষ্কাশন করুন
একটিমাত্র অনুরোধে সম্পূর্ণ কোডবেস বা ডিরেক্টরি কাঠামো সিড করতে, extract=true সহ একটি .tar বা .tar.gz আর্কাইভ আপলোড করুন।
পাইথন
from google import genai
client = genai.Client()
with open("source.tar.gz", "rb") as f:
result = client.environments.files.upload(
environment="YOUR_ENVIRONMENT_ID",
path="workspace/src/",
file=f,
extract=True,
)
for entry in result.files:
print(f"Extracted: {entry.path}")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import * as fs from "fs";
const client = new GoogleGenAI({});
const archive = fs.readFileSync("source.tar.gz");
const result = await client.environments.files.upload({
environment: "YOUR_ENVIRONMENT_ID",
path: "workspace/src/",
file: archive,
extract: true,
});
for (const entry of result.files) {
console.log(`Extracted: ${entry.path}`);
}
বিশ্রাম
curl -X PUT "https://generativelanguage.googleapis.com/upload/v1beta/environments/$ENV_ID/files/workspace/src/?extract=true" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/x-tar" \
--data-binary @source.tar.gz
প্রতিক্রিয়াটি আর্কাইভ দ্বারা লিখিত প্রতিটি ফাইলের তালিকা দেখায়:
{
"files": [
{
"name": "app.py",
"path": "workspace/src/app.py",
"type": "FILE",
"size_bytes": "15",
"mime_type": "text/x-python"
},
{
"name": "requirements.txt",
"path": "workspace/src/requirements.txt",
"type": "FILE",
"size_bytes": "17",
"mime_type": "text/plain"
}
]
}
পুনরায় শুরুযোগ্য সেশন সহ বড় ফাইল আপলোড করুন
বড় আকারের পেলোডের ক্ষেত্রে, অথবা অনির্ভরযোগ্য সংযোগের মাধ্যমে আপলোড করার সময়, সম্পূর্ণ ডেটা একবারে না পাঠিয়ে একটি রিজিউমেবল সেশন ব্যবহার করুন। একটি রিজিউমেবল আপলোড ট্রান্সফারকে কয়েকটি খণ্ডে বিভক্ত করে, যেগুলো আলাদাভাবে পুনরায় চেষ্টা করা যায়। ফলে, মাঝপথে কোনো ব্যর্থতা ঘটলে আপনাকে আবার প্রথম থেকে শুরু করতে হয় না।
প্রথমে uploadType=resumable দিয়ে সেশনটি শুরু করুন। একটি খালি বডি পাঠান এবং আপনি যে পেলোডটি আপলোড করতে চান তার মিডিয়া টাইপ ও মোট সাইজ জানানোর জন্য X-Upload-Content-Type এবং X-Upload-Content-Length হেডারগুলো ব্যবহার করুন।
PUT /upload/v1beta/environments/$ENV_ID/files/workspace/data/large_dataset.bin?uploadType=resumable HTTP/1.1
Host: generativelanguage.googleapis.com
X-Upload-Content-Type: application/octet-stream
X-Upload-Content-Length: 20971520
Content-Length: 0
x-goog-api-key: $GEMINI_API_KEY
রেসপন্সটিতে Location হেডারে সেশন URL-টি থাকে। এই URL-টিতে আগে থেকেই একটি upload_id থাকে, তাই এখানে আবার API key-এর প্রয়োজন হয় না:
HTTP/1.1 200 OK
Location: https://generativelanguage.googleapis.com/upload/v1beta/environments/$ENV_ID/files/workspace/data/large_dataset.bin?uploadType=resumable&upload_id=AJjja9bfHjiYlGi60pUazCaTuPY
Content-Length: 0
পেলোডটি খণ্ডে খণ্ডে ঐ URL-এ আপলোড করুন। প্রতিটি খণ্ড একটি Content-Range হেডারের মাধ্যমে তার বাইট পরিসীমা এবং মোট আকার ঘোষণা করে:
PUT /upload/v1beta/environments/$ENV_ID/files/workspace/data/large_dataset.bin?uploadType=resumable&upload_id=AJjja9bfHjiYlGi60pUazCaTuPY HTTP/1.1
Host: generativelanguage.googleapis.com
Content-Type: application/octet-stream
Content-Range: bytes 0-10485759/20971520
Content-Length: 10485760
<10 MB binary payload>
শেষটি ছাড়া প্রতিটি চাঙ্ক 308 Resume Incomplete রিটার্ন করে। Range হেডারটি আপনাকে বলে দেয় সার্ভার কত বাইট কমিট করেছে, এবং কোনো চাঙ্ক ব্যর্থ হলে আপনি সেখান থেকেই পুনরায় শুরু করেন।
HTTP/1.1 308 Resume Incomplete
Range: bytes=0-10485759
Content-Length: 0
বাকি খণ্ডগুলোও একইভাবে পাঠান:
PUT /upload/v1beta/environments/$ENV_ID/files/workspace/data/large_dataset.bin?uploadType=resumable&upload_id=AJjja9bfHjiYlGi60pUazCaTuPY HTTP/1.1
Host: generativelanguage.googleapis.com
Content-Type: application/octet-stream
Content-Range: bytes 10485760-20971519/20971520
Content-Length: 10485760
<remaining 10 MB binary payload>
চূড়ান্ত অংশটি আপলোড সম্পন্ন করে এবং ফাইলের মেটাডেটা ফেরত দেয়, যা একক-ধাপের আপলোডের মতোই একই files এনভেলপে থাকে:
{
"files": [
{
"name": "large_dataset.bin",
"path": "workspace/data/large_dataset.bin",
"type": "FILE",
"size_bytes": "20971520",
"mime_type": "application/octet-stream"
}
]
}
রিস্যুমেবল সেশন extract এবং overwrite সাথেও কাজ করে। এই কোয়েরি প্যারামিটারগুলো আলাদা আলাদা চাঙ্কে নয়, বরং ইনিশিয়েটিং রিকোয়েস্টে সেট করুন।
ওভাররাইট সুরক্ষা
ডিফল্টরূপে, overwrite ফলস false ) থাকে। যদি গন্তব্য পথটি আগে থেকেই বিদ্যমান থাকে, তাহলে অনুরোধটি একটি 409 Conflict ত্রুটি ফেরত দেয় এবং কিছুই লেখা হয় না:
{
"error": {
"message": "Requested entity already exists",
"code": "aborted"
}
}
বিদ্যমান কোনো ফাইল বা ডিরেক্টরি প্রতিস্থাপন করতে, overwrite=true সেট করুন (অথবা REST-এ ?overwrite=true যুক্ত করুন)। extract=true করা থাকলে, আর্কাইভের প্রতিটি ফাইলের উপর কনফ্লিক্ট চেক প্রযোজ্য হয়, ফলে কোনো টার্গেট ফাইল আগে থেকে বিদ্যমান থাকলে অনুরোধটি ব্যর্থ হয়।
সম্পূর্ণ স্ন্যাপশট ডাউনলোড করুন (অপ্রচলিত)
বিদ্যমান কোডকে এনভায়রনমেন্ট ফাইলস এপিআই-তে স্থানান্তর করতে:
পাইথন : পুরোনো ফাইল ডাউনলোড অনুরোধগুলি প্রতিস্থাপন করুন:
archive = client.environments.files.download( environment="YOUR_ENVIRONMENT_ID", path="workspace", ) with open("snapshot.tar", "wb") as f: f.write(archive)জাভাস্ক্রিপ্ট : পুরোনো ফাইল ডাউনলোড অনুরোধগুলি প্রতিস্থাপন করুন:
const bytes = await client.environments.files.download({ environment: "YOUR_ENVIRONMENT_ID", path: "workspace", }); fs.writeFileSync("snapshot.tar", Buffer.from(bytes));REST :
GET /v1beta/files/environment-$ENV_ID:download?alt=mediaএর পরিবর্তে ব্যবহার করুন:curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/environments/$ENV_ID/files?alt=media" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -o snapshot.tar
মূল্য নির্ধারণ এবং সম্পদ
প্রতিটি পরিবেশ নির্দিষ্ট সম্পদ বরাদ্দ নিয়ে চলে:
| সম্পদ | মূল্য |
|---|---|
| সিপিইউ | ৪ কোর |
| স্মৃতি | ১৬ জিবি |
প্রিভিউ সময়কালে এনভায়রনমেন্ট কম্পিউট (সিপিইউ, মেমরি, স্যান্ডবক্স এক্সিকিউশন)-এর জন্য বিল করা হয় না । এজেন্ট টোকেন খরচের জন্য প্রাইসিং দেখুন।
সীমাবদ্ধতা
- প্রিভিউ স্ট্যাটাস: এনভায়রনমেন্ট এবং ম্যানেজড এজেন্টগুলো প্রিভিউ পর্যায়ে রয়েছে। ফিচার ও স্কিমা পরিবর্তিত হতে পারে।
- ইনলাইন সোর্সের আকার: প্রতিটি ফাইলের জন্য ইনলাইন সোর্সের আকার ১ মেগাবাইট এবং সমস্ত ফাইল মিলিয়ে মোট আকার ২ মেগাবাইটে সীমাবদ্ধ।
- সোর্স সাইজ : গিট রিপোজিটরি ৫০০ এমবি এবং ক্লাউড স্টোরেজ রিপোজিটরি ২ জিবি পর্যন্ত সীমাবদ্ধ।
- এনভায়রনমেন্ট চালু করা: একটি নতুন এনভায়রনমেন্ট প্রস্তুত করতে প্রায় ৫ সেকেন্ড পর্যন্ত সময় লাগে। বড় সোর্স রিপোজিটরি এই সময় বাড়িয়ে দিতে পারে।
- এনভায়রনমেন্টের মেয়াদোত্তীর্ণতা: নিষ্ক্রিয় অফলাইন এনভায়রনমেন্টগুলো স্বয়ংক্রিয় TTL ক্লিনআপ ব্যবহার করে মেয়াদোত্তীর্ণ হওয়ার আগে ৭ দিন পর্যন্ত সংরক্ষিত থাকে। মেয়াদোত্তীর্ণ বা অবৈধ এনভায়রনমেন্ট আইডি দিলে একটি
404 Not Foundত্রুটি ফেরত আসে। - ফাইল সমর্থন: এজেন্টটি বর্তমানে শুধুমাত্র টেক্সট এবং ইমেজ ফাইল পড়তে পারে। বাইনারি ফাইল সমর্থন এখনও উপলব্ধ নয়।
- রুট থেকে মাউন্ট করা যাবে না: কাস্টম সোর্স যোগ করার সময় আপনি রুট (
/) কে টার্গেট হিসেবে সেট করতে পারবেন না, আপনাকে সর্বদা একটি সাব-ডিরেক্টরি নির্দিষ্ট করতে হবে।
এরপর কী?
- এজেন্টদের সংক্ষিপ্ত বিবরণ : পরিচালিত এজেন্টদের মূল ধারণাগুলো সম্পর্কে জানুন।
- কুইকস্টার্ট : একাধিক পালায় কথোপকথন এবং স্ট্রিমিংয়ের মাধ্যমে নির্মাণ শুরু করুন।
- অ্যান্টিগ্র্যাভিটি এজেন্ট : ডিফল্ট এজেন্টের সক্ষমতা, টুলস, মডেল নির্বাচন এবং মূল্য সম্পর্কে জানুন।
- কাস্টম এজেন্ট তৈরি করা :
AGENTS.mdএবংSKILL.mdব্যবহার করে আপনার নিজস্ব এজেন্ট সংজ্ঞায়িত করুন। - হুকস : নিরাপত্তা সুরক্ষা ব্যবস্থা প্রয়োগ করতে এবং স্যান্ডবক্সের ভিতরে সাইড-ইফেক্ট ভ্যালিডেশন চালাতে।