পরিবেশ হল ম্যানেজ করা Linux স্যান্ডবক্স যা এজেন্টদের কোড এক্সিকিউট ও ফাইল সেভ করার জন্য একটি আইসোলেটেড জায়গা দেয়। এগুলি ইন্টার্যাকশন প্রসঙ্গ থেকে আলাদা করা থাকে, তাই আপনি একাধিক ইন্টার্যাকশন জুড়ে একই এনভায়র্নমেন্ট আবার ব্যবহার করতে পারেন অথবা যেকোনও সময় নতুন করে শুরু করতে পারেন।
ফ্রেশ রিমোট এনভায়রনমেন্টের সাথে কীভাবে ইন্টার্যাকশন তৈরি করতে হয় এবং তার আইডি কীভাবে পেতে হয় তা নিম্নলিখিত উদাহরণ থেকে বোঝা যায়:
Python
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}`);
Java
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)
}
}
REST
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
প্যারামিটার ব্যবহার করার তিনটি পদ্ধতি নিম্নলিখিত উদাহরণে দেখানো হয়েছে।
Python
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);
Java
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)
}
}
REST
# 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 সেভ করে
আবার ব্যবহার করুন।
Python
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);
Java
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)
}
}
REST
# 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টি |
বিবরণ | সীমা |
|---|---|---|---|
| Git রিপোজিটরি | repository |
target-এ URL থেকে স্যান্ডবক্সে একটি রিপোজিটরি ক্লোন করে। |
৫০০ এমবি |
| ক্লাউড স্টোরেজ | gcs |
Cloud Storage থেকে target-এ স্যান্ডবক্সে ফাইল বা ডিরেক্টরি কপি করে। |
২ জিবি |
| ইনলাইন কন্টেন্ট | inline |
target-এ স্যান্ডবক্সের কোনও ফাইলে প্রসেস না করা টেক্সট কন্টেন্ট লেখে। |
প্রতিটি ফাইলের জন্য ১ এমবি, মোট ২ এমবি |
Python
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);
Java
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)
}
}
REST
# 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 কনফিগারেশন ফাইল ও কাস্টম ইন্টারসেপশন স্ক্রিপ্ট মাউন্ট করতে পারবেন। স্কিমা সংজ্ঞা ও কোডের উদাহরণের জন্য, হুক দেখুন।
ব্যক্তিগত সোর্স
এছাড়াও, নেটওয়ার্ক কনফিগারেশনে সোর্স ডোমেনকে যাচাই করিয়ে আপনি ব্যক্তিগত GitHub রিপোজিটরি বা ব্যক্তিগত Cloud Storage বাকেট থেকে ডাউনলোড করতে পারবেন।
একটি বিকল্প হল আইডি দ্বারা রেফার করা স্টোর করা ক্রেডেনশিয়াল । এর ফলে আপনি সিক্রেটটি একবারই স্টোর করেন এবং সেই সোর্সের প্রয়োজন আছে এমন প্রতিটি এনভায়রনমেন্ট এটি রেফার করতে পারে:
"network": {
"allowlist": [
{ "domain": "github.com", "credential": "github-production" },
{ "domain": "*" }
]
}
এছাড়াও, আপনি transform-এর সাথে ইনলাইন হেডার সেট করতে পারেন, যেমনটি নিম্নলিখিত উদাহরণে
করা হয়েছে। এগ্রেস প্রক্সি দুটি ফর্ম একই উপায়ে প্রয়োগ করে এবং কোনও ক্ষেত্রেই
সিক্রেট স্যান্ডবক্সের মধ্যে ল্যান্ড করে না।
ব্যক্তিগত Git রিপোজিটরির জন্য, আপনার
GitHub ব্যক্তিগত অ্যাক্সেস টোকেন
(PAT) সহ Basic যাচাইকরণ ব্যবহার করুন।
x-oauth-basic-কে ইউজারনেম হিসেবে ব্যবহার করে টোকেন এনকোড করুন:
echo -n "x-oauth-basic:ghp_YourPATHere" | base64
Python
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: "*"
}
]
}
},
});
Java
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.builder()
.allowlist(Allowlist.of(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.EnvironmentNetworkEgressAllowlist{
Allowlist: genai.Ptr(interactions.NewAllowlist([]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)
}
}
REST
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": "*"
}
]
}
}
}'
ব্যক্তিগত Cloud Storage বাকেটের জন্য, একটি স্ট্যান্ডার্ড OAuth 2.0 বিয়ারার টোকেন ব্যবহার করুন:
gcloud auth print-access-token
Python
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: "*"
}
]
}
},
});
Java
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.builder()
.allowlist(Allowlist.of(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.EnvironmentNetworkEgressAllowlist{
Allowlist: genai.Ptr(interactions.NewAllowlist([]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)
}
}
REST
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": "*"
}
]
}
}
}'
প্রি-ইনস্টল করা সফ্টওয়্যার
স্যান্ডবক্স Ubuntu-তে চলে এবং এতে রানটাইম ও সাধারণ প্যাকেজ
প্রি-ইনস্টল করা থাকে। এজেন্ট pip
install বা npm install ব্যবহার করে রানটাইমে অতিরিক্ত প্যাকেজ ইনস্টল করতে পারে। ইন্টার্যাকশনের সময় ইনস্টল করা প্যাকেজগুলি তখনও থাকে যখন
আপনি একই environment_id আবার ব্যবহার করেন।
| বিভাগ | প্রি-ইনস্টল করা প্যাকেজ |
|---|---|
| UNIX টুল | curl, wget, git, rsync, unzip, ripgrep, fd-find, gawk, bc, tree, which, lsof, htop, jq, iproute2, procps, gcloud CLI |
| Python 3.12 | numpy, pandas, requests, google-genai, beautifulsoup4, pyyaml, ast-grep-cli |
| Node.js 22 | create-next-app, create-vite, typescript |
এনভায়রনমেন্ট ভেরিয়েবল
স্যান্ডবক্সের মধ্যে এনভায়রনমেন্ট ভেরিয়েবল সেট করতে env ফিল্ড ব্যবহার করুন। প্রতিটি এন্ট্রি
কনফিগারেশনের জন্য একটি আক্ষরিক স্ট্রিং অথবা
একটি সিক্রেটের জন্য স্টোর করা ক্রেডেনশিয়ালের
রেফারেন্সের সাথে ভেরিয়েবলের নাম ম্যাপ করে। এজেন্ট সেগুলিকে সেইভাবেই দেখে যেভাবে যেকোনও শেল দেখে, তাই প্রসেস এনভায়রনমেন্ট থেকে
রিড করা টুল ও স্ক্রিপ্ট অতিরিক্ত ওয়্যারিং ছাড়াই সেগুলিকে বেছে নেয়।
| ফিল্ড | ধরন | বিবরণ |
|---|---|---|
env |
object |
ভেরিয়েবলের নাম থেকে ভ্যালু পর্যন্ত ম্যাপ। ভ্যালু হয় লিটারেল string অথবা {"credential": "credential-id"} ফর্মের ক্রেডেনশিয়াল রেফারেন্স। |
Python
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);
REST
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"}
}
}
}'
এজেন্ট সেই ইন্টার্যাকশনে যত কমান্ড রান করায়, সবকটির ক্ষেত্রেই ভেরিয়েবল প্রযোজ্য হয়। এর মধ্যে শেল কমান্ড, বিল্ড স্টেপ ও এজেন্ট শুরু করা যেকোনও প্রসেস অন্তর্ভুক্ত।
দুটি ভ্যালু টাইপ আলাদা আলাদা আচরণ করে। একটি আক্ষরিক স্ট্রিং কন্টেনারে সাধারণ টেক্সট হিসেবে লেখা হয়। ক্রেডেনশিয়াল রেফারেন্স এগুলি নয়: ভেরিয়েবল একটি প্লেসহোল্ডার পায় এবং এগ্রেস প্রক্সি শুধুমাত্র সেই ক্রেডেনশিয়ালের বিশ্বস্ত ডোমেনে পাঠানো আউটবাউন্ড অনুরোধে আসল সিক্রেটটি পরিবর্তন করে। এটি কীভাবে কাজ করে তা জানতে এনভায়রনমেন্ট ভেরিয়েবল হিসেবে ক্রেডেনশিয়াল ব্যবহার করা দেখুন।
নেটওয়ার্ক কনফিগারেশন
সাধারণত, এনভায়রনমেন্টে আনরেস্ট্রিক্টেড আউটবাউন্ড নেটওয়ার্ক অ্যাক্সেস থাকে। নির্দিষ্ট ডোমেনে আউটবাউন্ড ট্রাফিক সীমিত করতে
network ফিল্ড ব্যবহার করুন। প্রতিটি নিয়ম
একটি domain নির্দিষ্ট করে, এছাড়াও স্টোর করা সিক্রেট ইনজেক্ট করার জন্য একটি ঐচ্ছিক credential
এবং ম্যাচ করা অনুরোধে হেডার ইনজেক্ট করার জন্য একটি ঐচ্ছিক transform অবজেক্ট নির্দিষ্ট করে।
প্রতিটি ইন্টার্যাকশনের জন্য এই হেডার অনন্য হতে পারে এবং আপনি একই এনভায়রনমেন্টের জন্য সেগুলি আপডেট করতে পারবেন।
| ফিল্ড | ধরন | বিবরণ |
|---|---|---|
domain |
string |
ম্যাচ করার জন্য ডোমেন। নির্দিষ্ট হোস্টনেম বা * সব ডোমেনের জন্য ব্যবহার করুন। |
credential |
string |
সেভ করা ক্রেডেনশিয়ালের আইডি। এগ্রেস প্রক্সি এটি সমাধান করে এবং অনুরোধ করার সময় প্রমাণীকরণ হেডার ইনজেক্ট করে। |
transform |
object |
ম্যাচ করা অনুরোধে ইনজেক্ট করার জন্য ফ্ল্যাট কী-ভ্যালু পেয়ার সহ অবজেক্ট, যেমন {"Authorization": "Bearer ..."}। |
Python
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);
Java
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.builder()
.allowlist(Allowlist.of(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.EnvironmentNetworkEgressAllowlist{
Allowlist: genai.Ptr(interactions.NewAllowlist([]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)
}
}
REST
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। এগ্রেস
প্রক্সিটি ওয়্যারে প্রয়োগ করা হয়, তাই দুটি ক্ষেত্রেই সিক্রেট কখনও
স্যান্ডবক্সে প্রবেশ করে না এবং আপনার ইন্ট্যার্যাকশন পেলোডে কখনও দেখা যায় না।
ম্যানেজ করা ক্রেডেনশিয়াল হল এমন একটি ক্রেডেনশিয়াল যা আপনি একবার সিক্রেট সেভ করে আবার ব্যবহার করতে চাইলে প্রয়োজন হয়। আপনার প্রোজেক্টের প্রতিটি এনভায়রনমেন্ট, এজেন্ট ও ট্রিগার একই আইডি রেফার করতে পারে এবং আপনি এটি এক জায়গায় রোটেট করতে পারেন।
Python
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);
REST
# 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 ক্রেডেনশিয়াল নিজেই নিজের অ্যাক্সেস টোকেন রিফ্রেশ করে, তাই টোকেনের মেয়াদ শেষ হয়ে গেলেও
দীর্ঘক্ষণ ধরে চলা ইন্ট্যার্যাকশন ভেঙে যায় না। ক্রেডেনশিয়ালের
সম্পূর্ণ তালিকা এবং ম্যানেজমেন্ট অপারেশন
সম্পর্কিত তথ্য পেতে ক্রেডেনশিয়াল দেখুন।
এছাড়াও, আপনি transform-এর সাথে ইনলাইন হেডার সেট করতে পারবেন। এটি তখনই প্রযোজ্য হয় যখন ভ্যালু
একটি কলের সাথে সম্পর্কিত হয়, যেমন, ইন্টার্যাকশন তৈরি করার ঠিক আগে
আপনি কোনও টোকেন জেনারেট করেন। এইভাবে সেট করা হেডার একই ইগ্রেস প্রক্সি ইনজেক্ট করে,
এগুলি কখনই স্যান্ডবক্সের মধ্যে এনভায়রনমেন্ট ভেরিয়েবল বা ফাইল হিসেবে এক্সপোজ করা হয় না।
Python
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);
Java
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.builder()
.allowlist(Allowlist.of(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.EnvironmentNetworkEgressAllowlist{
Allowlist: genai.Ptr(interactions.NewAllowlist([]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)
}
}
REST
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 হিসেবে সেট করুন:
Python
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);
Java
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)
}
}
REST
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"
}
}'
ক্রেডেনশিয়াল রিফ্রেশ করা
অ্যাক্সেস টোকেন ও স্বল্পমেয়াদী API কীয়ের মতো ইনলাইন টোকেনের মেয়াদ শেষ হয়ে যায়।
পরবর্তী ইন্ট্যার্যাকশনে, আগে থেকে থাকা environment_id-এর সাথে একটি
নতুন network কনফিগারেশন পাস করে আপনি সেগুলি রিফ্রেশ করতে পারবেন। নতুন নেটওয়ার্ক নিয়ম
পুরনো নিয়মকে সম্পূর্ণভাবে সরিয়ে দেয়, তবে এনভায়র্নমেন্টের ফাইল সিস্টেমের অবস্থা
(ইনস্টল করা প্যাকেজ, ফাইল, রেপোজিটরি) অপরিবর্তিত থাকে।
এর পরিবর্তে, আপনি স্টোর করা ক্রেডেনশিয়াল ব্যবহার করলে,
আপনার এটি প্রয়োজন নেই। oauth2 ক্রেডেনশিয়াল অটোমেটিক রিফ্রেশ হয় এবং কোনও ক্রেডেনশিয়াল রোটেট করা
হলে, সেটি ক্রেডেনশিয়ালের PATCH হয়, যার ফলে প্রতিটি অনুমোদিত তালিকা সংক্রান্ত নিয়ম
সেটি রেফারেন্স হিসেবে ব্যবহার করে অপরিবর্তিত থাকে।
Python
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);
Java
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.builder()
.allowlist(Allowlist.of(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.builder()
.allowlist(Allowlist.of(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.EnvironmentNetworkEgressAllowlist{
Allowlist: genai.Ptr(interactions.NewAllowlist([]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.EnvironmentNetworkEgressAllowlist{
Allowlist: genai.Ptr(interactions.NewAllowlist([]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)
}
}
REST
# 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" বা কনফিগারেশন অবজেক্ট নির্দিষ্ট করলে, প্রোভিশন করা হয়। |
| অ্যাক্টিভ | ইন্টার্যাকশন চলাকালীন চলছে। |
| নিষ্ক্রিয় | অটোমেটিক স্ন্যাপশট নেওয়া হয় এবং ১৫ মিনিট কোনও অ্যাক্টিভিটি না থাকলে বন্ধ হয়ে যায়। |
| অফলাইন | শেষবার অ্যাক্টিভ থাকার পর থেকে ৭ দিন পর্যন্ত সেভ করে রাখা হয়। এর আইডি পাস করে আবার চালু করা যেতে পারে। |
| মুছে দেওয়া হয়েছে | ৭-দিন TTL ধরে রাখার মেয়াদ শেষ হয়ে গেলে বা ম্যানুয়ালি মুছে দিলে সিস্টেম থেকে অটোমেটিক সরিয়ে দেওয়া হয়। |
Environments API
স্যান্ডবক্স সেশন প্রোগ্রামম্যাটিক উপায়ে ম্যানেজ করতে, আপনি Environments API ব্যবহার করতে পারবেন। এনুমারেট এনভায়রনমেন্ট আপনাকে অ্যাক্টিভ সেশন আইডি খুঁজে পেতে এবং কোনও দীর্ঘ-সময় ধরে চলা টাস্ক চলাকালীন ক্লায়েন্ট কানেকশন বন্ধ হয়ে গেলে স্টেট রিকভার করতে সাহায্য করে। এছাড়াও, আপনি সেশন মেটাডেটা পরিদর্শন করতে এবং অটোমেটিক TTL এক্সপায়ার হওয়ার জন্য অপেক্ষা না করে, ওয়ার্কফ্লো শেষ হয়ে গেলে স্পষ্টভাবে এনভায়রনমেন্ট মুছে দিতে পারবেন।
এনভায়রনমেন্টের তালিকা
আপনার প্রোজেক্টের সাথে সম্পর্কিত অ্যাক্টিভ এনভায়রনমেন্টের তালিকা। রেসপন্স ব্যাচ সাইজ কন্ট্রোল করতে প্যাজিনেশন প্যারামিটার ব্যবহার করুন।
Python
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}`);
}
Java
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)
}
}
}
REST
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="
}
এনভায়রনমেন্ট পাওয়া
কোনও নির্দিষ্ট এনভায়রনমেন্টের জন্য তার রিসোর্স নামের মাধ্যমে মেটাডেটা ও কনফিগারেশন সংক্রান্ত বিবরণ রিট্রিভ করুন।
Python
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}`);
Java
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)
}
REST
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"
}
]
}
}
এনভায়রনমেন্ট মোছা
আপনার টাস্ক বা পাইপলাইন সম্পূর্ণ হয়ে গেলে, স্যান্ডবক্স রিসোর্স ক্লিন-আপ করতে পরিবেশটি স্পষ্টভাবে বন্ধ করে দিন ও মুছে দিন।
Python
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");
Java
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)
}
}
REST
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/environments/YOUR_ENVIRONMENT_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
এনভায়রনমেন্টে ফাইল ম্যানেজ করা
এজেন্ট এক্সিকিউশনের সময় স্যান্ডবক্সের মধ্যে ফাইল তৈরি ও পরিবর্তন করে। আপনি ডিরেক্টরির কন্টেন্ট ব্রাউজ করতে, ফাইলের মেটাডেটা পেতে, আলাদা আলাদা ফাইল বা সম্পূর্ণ ডিরেক্টরি tar আর্কাইভ হিসেবে ডাউনলোড করতে এবং সরাসরি এনভায়রনমেন্টে ফাইল আপলোড বা আর্কাইভ এক্সট্র্যাক্ট করতে পারবেন। স্যান্ডবক্স এনভায়রনমেন্টে স্টোরেজ ন্যায্য ব্যবহারের সীমার অধীন।
ডিরেক্টরির ফাইল তালিকাভুক্ত করা
এনভায়রনমেন্টে কোনও ডিরেক্টরির কন্টেন্ট তালিকা তৈরি করে। ডিফল্ট হিসেবে, রুট ডিরেক্টরি তালিকাভুক্ত করে।
কোয়েরি প্যারামিটার
| প্যারামিটার | ধরন | বিবরণ |
|---|---|---|
recursive |
বুলিয়ান | true থাকলে, সব ফাইল ও ডিরেক্টরি রিকার্সিভভাবে তালিকাভুক্ত করে। ডিফল্ট: false. |
Python
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}`);
}
REST
# 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 শেষবার পরিবর্তন করার টাইমস্ট্যাম্প। |
ফাইলের মেটাডেটা পাওয়া
পাথ অনুযায়ী নির্দিষ্ট ফাইলের মেটাডেটা পান।
Python
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}`);
REST
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"
}
]
}
ফাইলটি না থাকলে, API একটি 404 সমস্যা দেখায়:
{
"error": {
"message": "Path 'nonexistent.txt' not found in environment 'ENV_ID'.",
"code": "not_found"
}
}
একটি ফাইল ডাউনলোড করা
নির্দিষ্ট ফাইলের কন্টেন্ট ডাউনলোড করা। SDK-তে, download()
পদ্ধতি ব্যবহার করুন। REST অনুরোধে, ফাইলের
পাথে ?alt=media কোয়েরি প্যারামিটার যোগ করুন। সার্ভার 200 OK দিয়ে উত্তর দেয় এবং কাঁচা ফাইলের কন্টেন্ট স্ট্রিম করে।
Python
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));
REST
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 ব্যবহার করে ডিরেক্টরির পাথ উল্লেখ করে
সম্পূর্ণ ডিরেক্টরি tar আর্কাইভ হিসেবে ডাউনলোড করুন। এটি একটি POSIX tar ফাইল (gzipped নয়) রিটার্ন করে। নেস্টেড সাবডিরেক্টরি অন্তর্ভুক্ত করতে
recursive=true ব্যবহার করুন।
Python
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");
REST
# 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 (ফাইল) |
media |
- | - | - | কাঁচা ফাইলের কন্টেন্ট |
GET /files/{path}?alt=media (dir) |
media |
false |
- | - | ডিরেক্টরিতে থাকা অবিলম্বে প্রয়োজনীয় ফাইলের Tar আর্কাইভ |
GET /files/{path}?alt=media (dir) |
media |
true |
- | - | সব ফাইলের রিকার্সিভ Tar আর্কাইভ |
GET /files?alt=media |
media |
false |
- | - | শুধুমাত্র রুট-লেভেল ফাইলের Tar আর্কাইভ |
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 ব্যবহার করে আগে থেকে থাকা এনভায়রনমেন্ট
স্যান্ডবক্সে সরাসরি আলাদা আলাদা ফাইল বা ডিরেক্টরি আর্কাইভ আপলোড করুন। প্যারেন্ট ডিরেক্টরি না থাকলে, সেটি
অটোমেটিক তৈরি হয়ে যায়। এনভায়রনমেন্টে স্টোরেজ ব্যবহারের ক্ষেত্রে উপযুক্ত ব্যবহারের সীমা প্রযোজ্য।
একটি ফাইল আপলোড করা
Python
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)`);
REST
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 আর্কাইভ আপলোড করুন।
Python
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}`);
}
REST
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 কী প্রয়োজন নেই:
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-এ append
?overwrite=true) সেট করুন। extract=true-এর মাধ্যমে, আর্কাইভের প্রতিটি ফাইলের ক্ষেত্রে
কনফ্লিক্ট চেক প্রযোজ্য হয়, তাই কোনও টার্গেট ফাইল আগে থেকেই থাকলে অনুরোধটি বাতিল হয়ে যায়।
সম্পূর্ণ স্ন্যাপশট ডাউনলোড করুন (বন্ধ হয়ে গেছে)
আগে থেকে থাকা কোডকে এনভায়রনমেন্ট ফাইল API-তে মাইগ্রেট করতে:
Python: পুরনো ফাইল ডাউনলোড করার অনুরোধের পরিবর্তে এগুলি ব্যবহার করুন:
archive = client.environments.files.download( environment="YOUR_ENVIRONMENT_ID", path="workspace", ) with open("snapshot.tar", "wb") as f: f.write(archive)JavaScript: পুরনো ফাইল ডাউনলোড করার অনুরোধের পরিবর্তে এগুলি ব্যবহার করুন:
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
দাম ও রিসোর্স
প্রতিটি এনভায়রনমেন্ট নির্দিষ্ট রিসোর্স অ্যালোকেশন নিয়ে চলে:
| রিসোর্স | ভ্যালু |
|---|---|
| সিপিইউ | ৪টি কোর |
| মেমরি | ১৬ জিবি |
প্রিভিউ পিরিয়ড চলাকালীন এনভায়রনমেন্ট কম্পিউট (CPU, মেমরি, স্যান্ডবক্স এক্সিকিউশন) বিল করা হয় না। এজেন্ট টোকেনের খরচের জন্য দাম দেখুন।
সীমাবদ্ধতা
- প্রিভিউ স্ট্যাটাস: এনভায়রনমেন্ট ও ম্যানেজ করা এজেন্ট প্রিভিউতে আছে। ফিচার ও স্কিমা পরিবর্তন হতে পারে।
- ইনলাইন সোর্সের সাইজ: ইনলাইন সোর্স প্রতি ফাইলে ১ এমবি এবং সব ফাইল মিলিয়ে মোট ২ এমবি হতে পারে।
- সোর্সের সাইজ: Git রিপোজিটরি ৫০০ এমবি এবং ক্লাউড স্টোরেজ রিপোজিটরি ২ জিবি পর্যন্ত হতে পারে।
- এনভায়রনমেন্ট স্টার্ট-আপ: নতুন এনভায়রনমেন্ট প্রোভিশন করতে সর্বাধিক ~৫ সেকেন্ড সময় লাগে। সোর্সের বড় রেপোজিটরি থাকলে এই সময় বেড়ে যেতে পারে।
- এনভায়রনমেন্টের মেয়াদ শেষ হওয়া: অটোমেটিক TTL ক্লিন-আপ ব্যবহার করে মেয়াদ শেষ হওয়ার আগে ৭
দিন পর্যন্ত ইনঅ্যাক্টিভ অফলাইন এনভায়রনমেন্ট ধরে রাখা হয়। মেয়াদ ফুরিয়ে যাওয়া বা
ভুল এনভায়রনমেন্ট আইডি দিলে
404 Not Foundসমস্যা হয়। - ফাইল সাপোর্ট: এজেন্ট বর্তমানে টেক্সট ও ছবি ফাইল পড়তে পারে। বাইনারি ফাইল সাপোর্ট এখনও উপলভ্য নয়।
- রুট থেকে মাউন্ট করা যাবে না: কাস্টম সোর্স যোগ করার সময় আপনি রুট (
/) টার্গেট হিসেবে সেট করতে পারবেন না, আপনাকে সবসময় একটি সাব-ডিরেক্টরি নির্দিষ্ট করতে হবে।
এর পরে কী করতে হবে
- এজেন্ট ওভারভিউ: ম্যানেজ করা এজেন্টদের মূল ধারণা সম্পর্কে জানুন।
- দ্রুত শুরু করা: একাধিক কথোপকথন ও স্ট্রিমিংয়ের মাধ্যমে তৈরি করা শুরু করুন।
- অ্যান্টিগ্র্যাভিটি এজেন্ট: ডিফল্ট এজেন্টের ক্ষমতা, টুল, মডেল বেছে নেওয়া ও দাম সম্পর্কে জানুন।
- কাস্টম এজেন্ট তৈরি করা:
AGENTS.mdওSKILL.mdব্যবহার করে আপনার নিজস্ব এজেন্ট নির্ধারণ করুন। - হুক: স্যান্ডবক্সের মধ্যে নিরাপত্তা গার্ডরেল প্রয়োগ করুন এবং সাইড-ইফেক্ট ভ্যালিডেশন রান করান।