এই নির্দেশিকাটি আপনাকে অ্যান্টিগ্র্যাভিটি এজেন্ট ব্যবহার করে জেমিনি এপিআই-তে ম্যানেজড এজেন্ট তৈরি এবং ব্যবহার করার পদ্ধতি ধাপে ধাপে দেখাবে। আপনি আপনার প্রথম এজেন্ট কলটি করবেন, একাধিক পালাক্রমে কথোপকথন চালিয়ে যাবেন, প্রতিক্রিয়া স্ট্রিম করবেন, স্যান্ডবক্স থেকে ফাইল ডাউনলোড করবেন এবং অ্যান্টিগ্র্যাভিটি ম্যানেজড এজেন্টের সাথে কাজ করবেন।
আপনার প্রথম এজেন্ট ইন্টারঅ্যাকশন চালান
ইন্টারঅ্যাকশনস এপিআই -তে একটিমাত্র কল একটি লিনাক্স স্যান্ডবক্স প্রস্তুত করে, এজেন্ট লুপটি চালায় এবং ফলাফল ফেরত দেয়। আপনাকে তিনটি প্যারামিটার নির্ধারণ করতে হবে:
-
agentহিসেবে"antigravity-preview-09-2026"পাস করুন, যেটি আমাদের পূর্বনির্ধারিত এবং সাধারণ উদ্দেশ্যমূলক পরিচালিত এজেন্টের বর্তমান সংস্করণ। - একটি নতুন স্যান্ডবক্স এনভায়রনমেন্ট তৈরি করতে
environment="remote"নির্ধারণ করুন। এজেন্ট কী করবে তা নির্ধারণ করে একটি ইনপুট তৈরি করুন।
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Write a Python script that generates the first 20 Fibonacci numbers and saves them to fibonacci.txt. Then read the file and print its contents.",
environment="remote",
)
# Print the agent's final output
print(f"Interaction ID: {interaction.id}")
print(f"Environment ID: {interaction.environment_id}")
print(f"Output: {interaction.output_text}")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Write a Python script that generates the first 20 Fibonacci numbers and saves them to fibonacci.txt. Then read the file and print its contents.",
environment: "remote",
});
console.log(`Interaction ID: ${interaction.id}`);
console.log(`Environment ID: ${interaction.environment_id}`);
console.log(`Output: ${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 params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Write a Python script that generates the first 20 Fibonacci numbers and saves them to fibonacci.txt. Then read the file and print its contents."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
// Print the agent's final output
System.out.println("Interaction ID: " + interaction.id().orElse(""));
System.out.println("Environment ID: " + interaction.environmentId().orElse(""));
System.out.println("Output: " + 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)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Write a Python script that generates the first 20 Fibonacci numbers and saves them to fibonacci.txt. Then read the file and print its contents."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res.Interaction
// Print the agent's final output
fmt.Printf("Interaction ID: %s\n", *interaction.ID)
fmt.Printf("Environment ID: %s\n", *interaction.EnvironmentID)
fmt.Printf("Output: %s\n", *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": "Write a Python script that generates the first 20 Fibonacci numbers and saves them to fibonacci.txt. Then read the file and print its contents."}],
"environment": {"type": "remote"}
}'
প্রতিক্রিয়াটি একটি Interaction অবজেক্ট ফেরত দেয়। একই স্যান্ডবক্সে কথোপকথন চালিয়ে যাওয়ার জন্য interaction.id এবং interaction.environment_id সংরক্ষণ করুন। এজেন্টের চূড়ান্ত প্রতিক্রিয়া অ্যাক্সেস করতে interaction.output_text ব্যবহার করুন। interaction.steps এজেন্টের নেওয়া প্রতিটি ধাপের তালিকা দেখায় (যুক্তি প্রদান, টুল কল, কোড সম্পাদন)।
কথোপকথন চালিয়ে যান (একাধিক পালা)
এপিআই দুটি স্বাধীন অবস্থার মাত্রা ট্র্যাক করে:
- কথোপকথনের প্রেক্ষাপট: চ্যাটের ইতিহাস, যুক্তির বিবরণ, টুলের ব্যবহার,
previous_interaction_idব্যবহার। - পরিবেশের অবস্থা: ফাইল, ইনস্টল করা প্যাকেজ এবং স্যান্ডবক্সের অবস্থা,
environmentব্যবহার করে নির্ধারিত হয়।
পুনরায় শুরু করতে উভয়কে নিজ নিজ স্থানে পাস করুন:
পাইথন
interaction_2 = client.interactions.create(
agent="antigravity-preview-09-2026",
previous_interaction_id=interaction.id,
environment=interaction.environment_id,
input="Now plot the Fibonacci sequence as a line chart and save it as chart.png.",
)
print(interaction_2.output_text)
জাভাস্ক্রিপ্ট
const interaction2 = await client.interactions.create({
agent: "antigravity-preview-09-2026",
previous_interaction_id: interaction.id,
environment: interaction.environment_id,
input: "Now plot the Fibonacci sequence as a line chart and save it as chart.png.",
}, { timeout: 300_000 });
console.log(interaction2.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();
String interactionId = "INTERACTION_ID";
String environmentId = "ENVIRONMENT_ID";
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.previousInteractionId(interactionId)
.environment(CreateAgentInteractionEnvironment.of(environmentId))
.input(InteractionsInput.of("Now plot the Fibonacci sequence as a line chart and save it as chart.png."))
.build();
Interaction interaction2 = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction2.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)
}
interactionID := "INTERACTION_ID"
environmentID := "ENVIRONMENT_ID"
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
PreviousInteractionID: genai.Ptr(interactionID),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(environmentID)),
Input: interactions.NewInteractionsInput("Now plot the Fibonacci sequence as a line chart and save it as chart.png."),
}),
})
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",
"previous_interaction_id": "interaction_id_from_step_1",
"environment": "environment_id_from_step_1",
"input": [{"type": "text", "text": "Now plot the Fibonacci sequence as a line chart and save it as chart.png."}]
}'
প্রথম টার্নের ফাইলগুলো ( fibonacci.txt ) দ্বিতীয় টার্নেও থেকে যায়। এজেন্ট কথোপকথনের প্রেক্ষাপটও ধরে রাখে।
আপনি এগুলো আলাদাভাবে মিলিয়ে মিশিয়ে নিতে পারেন:
- কথোপকথন মুছে ফেলুন, ফাইল রাখুন:
previous_interaction_idবাদ দিন, একই ওয়ার্কস্পেসে নতুন কথোপকথনের জন্য শুধুenvironmentব্যবহার করে এনভায়রনমেন্ট আইডি দিন। - কথোপকথন চালু রাখুন, নতুন ওয়ার্কস্পেস:
previous_interaction_idপাস করুন, একটি নতুন স্যান্ডবক্সের জন্যenvironment="remote"সেট করুন।
স্বয়ংক্রিয় প্রসঙ্গ সংক্ষেপণ
দীর্ঘস্থায়ী, একাধিক পালাবিশিষ্ট কথোপকথনে, যুক্তির ধাপগুলোর মূল ইতিহাস, টুল কল এবং বড় ফাইলের বিষয়বস্তু দ্রুত বাড়তে পারে এবং উল্লেখযোগ্য পরিমাণে কনটেক্সট স্পেস দখল করতে পারে। টোকেন লিমিটজনিত ত্রুটি এড়াতে এবং এজেন্টের ফোকাস বজায় রাখতে (যা ‘কনটেক্সট রট’ প্রতিরোধ করে), ম্যানেজড এজেন্টস এপিআই-তে প্রায় ১৩৫ হাজার টোকেন পূর্ণ হলে একটি নেটিভ কনটেক্সট কম্প্যাকশন ধাপ রয়েছে। এটি স্বয়ংক্রিয়ভাবে ঘটে।
প্রতিক্রিয়াটি স্ট্রিম করুন
দীর্ঘ সময় ধরে চলা কাজগুলোর ক্ষেত্রে, এজেন্টের কাজ রিয়েল টাইমে দেখতে আপনি রেসপন্সটি স্ট্রিম করতে পারেন:
পাইথন
from google import genai
client = genai.Client()
stream = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Read Hacker News, summarize the top 5 stories, and save the results as a PDF.",
environment="remote",
stream=True,
)
for event in stream:
print(event)
if event.event_type == "step.stop" and event.usage:
print(event.usage)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const stream = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Read Hacker News, summarize the top 5 stories, and save the results as a PDF.",
environment: "remote",
stream: true,
});
for await (const event of stream) {
console.log(event);
if (event.event_type === "step.stop" && event.usage) {
console.log(event.usage);
}
}
জাভা
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.InteractionSSEStreamEvent;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.StepStop;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.utils.EventStream;
Client client = new Client();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Read Hacker News, summarize the top 5 stories, and save the results as a PDF."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.stream(true)
.build();
try (EventStream<InteractionSSEStreamEvent> stream =
client.interactions.create(CreateInteractionRequestBody.of(params)).events()) {
for (InteractionSSEStreamEvent event : stream) {
System.out.println(event);
if (event.data().isPresent() && event.data().get() instanceof StepStop stepStop) {
stepStop.usage().ifPresent(System.out::println);
}
}
}
যান
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("Read Hacker News, summarize the top 5 stories, and save the results as a PDF."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
Stream: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
stream := res.InteractionSSEStreamEvent
defer stream.Close()
for stream.Next() {
event := stream.Value()
fmt.Printf("%+v\n", event)
if stepStop := event.GetDataStepStop(); stepStop != nil && stepStop.Usage != nil {
fmt.Printf("%+v\n", stepStop.Usage)
}
}
if err := stream.Err(); err != nil {
log.Fatal(err)
}
}
বিশ্রাম
curl -N -s -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": "Read Hacker News, summarize the top 5 stories, and save the results as a PDF.",
"environment": "remote",
"stream": true
}'
স্ট্রিমিং ক্রমবর্ধমান আপডেটের সাথে স্টেপ ডেল্টা ফেরত দেয়। যখন একটি স্টেপ সম্পূর্ণ হয়, তখন step.stop ইভেন্টে সঞ্চিত ব্যবহারের পরিসংখ্যান অন্তর্ভুক্ত থাকে। স্ট্রিমিং গাইডে আরও জানুন।
পরিবেশ থেকে ফাইল ডাউনলোড করুন
যখন এজেন্ট স্যান্ডবক্সের ভিতরে ফাইল তৈরি করে, তখন ফাইলস এপিআই (Files API) ব্যবহার করে সরাসরি HTTP অনুরোধের মাধ্যমে সেগুলি ডাউনলোড করুন (এখনও কোনো এসডিকে পদ্ধতি নেই):
পাইথন
import os
import requests
import tarfile
env_id = interaction.environment_id
api_key = os.environ["GEMINI_API_KEY"]
response = requests.get(
f"https://generativelanguage.googleapis.com/v1beta/files/environment-{env_id}:download",
params={"alt": "media"},
headers={"x-goog-api-key": api_key},
allow_redirects=True,
)
with open("snapshot.tar", "wb") as f:
f.write(response.content)
with tarfile.open("snapshot.tar") as tar:
tar.extractall(path="extracted_snapshot")
জাভাস্ক্রিপ্ট
import fs from "fs";
import { execSync } from "child_process";
const envId = interaction.environment_id;
const apiKey = process.env.GEMINI_API_KEY || "";
const url = `https://generativelanguage.googleapis.com/v1beta/files/environment-${envId}:download?alt=media`;
const response = await fetch(url, {
headers: {
"x-goog-api-key": apiKey,
},
});
if (!response.ok) {
throw new Error(`Failed to download file: ${response.statusText}`);
}
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("snapshot.tar", buffer);
if (!fs.existsSync("extracted_snapshot")) {
fs.mkdirSync("extracted_snapshot");
}
execSync("tar -xf snapshot.tar -C extracted_snapshot");
console.log(fs.readdirSync("extracted_snapshot"));
জাভা
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Paths;
String envId = "ENVIRONMENT_ID";
String apiKey = System.getenv("GEMINI_API_KEY");
HttpClient httpClient = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NORMAL)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://generativelanguage.googleapis.com/v1beta/files/environment-" + envId + ":download?alt=media"))
.header("x-goog-api-key", apiKey)
.GET()
.build();
HttpResponse<byte[]> response = httpClient.send(request, HttpResponse.BodyHandlers.ofByteArray());
Files.write(Paths.get("snapshot.tar"), response.body());
System.out.println("Saved snapshot to snapshot.tar");
যান
package main
import (
"context"
"fmt"
"io"
"log"
"net/http"
"os"
)
func main() {
ctx := context.Background()
envID := "ENVIRONMENT_ID"
apiKey := os.Getenv("GEMINI_API_KEY")
url := fmt.Sprintf("https://generativelanguage.googleapis.com/v1beta/files/environment-%s:download?alt=media", envID)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("x-goog-api-key", apiKey)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
data, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("snapshot.tar", data, 0644); err != nil {
log.Fatal(err)
}
fmt.Println("Saved snapshot to snapshot.tar")
}
বিশ্রাম
ENV_ID="your_environment_id_here"
curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/files/environment-$ENV_ID:download?alt=media" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-o snapshot.tar
mkdir -p extracted_snapshot
tar -xf snapshot.tar -C extracted_snapshot
একজন পরিচালিত এজেন্টকে বাঁচান
পূর্ববর্তী ধাপগুলোতে, আমরা ডিফল্ট অ্যান্টিগ্র্যাভিটি এজেন্ট ব্যবহার করেছি এবং এটিকে ইনলাইনে কাস্টমাইজ করেছি। একবার আপনি আপনার কনফিগারেশন (নির্দেশাবলী, দক্ষতা, মডেল নির্বাচন এবং পরিবেশ) পরিমার্জন করে নিলে, আপনি এটিকে একটি পুনঃব্যবহারযোগ্য ম্যানেজড এজেন্ট হিসেবে সংরক্ষণ করতে পারেন। এর ফলে আপনি কনফিগারেশনের পুনরাবৃত্তি না করেই আইডি দ্বারা এটিকে চালু করতে পারবেন।
যখন আপনি একটি এজেন্ট সংরক্ষণ করেন, তখন ইনলাইন ইন্টারঅ্যাকশনগুলির সাথে এর স্থাপত্যগত সামঞ্জস্য লক্ষ্য করুন: আপনি base_agent: "antigravity-preview-09-2026" নির্দিষ্ট করেন এবং interactions.create মতোই আপনার নির্বাচিত model সহ একটি agent_config পাস করতে পারেন। এছাড়াও আপনি একটি base_environment সংজ্ঞায়িত করেন (হয় সোর্স থেকে অথবা একটি বিদ্যমান এনভায়রনমেন্ট ফোর্ক করে)। এজেন্টটি প্রতিটি নতুন ইন্টারঅ্যাকশনের জন্য এই এনভায়রনমেন্ট এবং মডেল কনফিগারেশন ব্যবহার করবে।
উৎস থেকে: ইনলাইনে উৎস নির্ধারণ করুন, অথবা গিটহাব বা ক্লাউড স্টোরেজের মতো অন্যান্য উৎস থেকে।
পাইথন
agent = client.agents.create(
id="fibonacci-analyst",
base_agent="antigravity-preview-09-2026",
agent_config={
"type": "antigravity",
"model": "gemini-3.8-flash",
},
system_instruction="You are a math analysis agent. Generate sequences, visualize them, and export results as PDF reports.",
base_environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always include a chart and a summary table in your reports.",
},
{
"type": "repository",
"source": "https://github.com/your-org/skills",
"target": ".agents/skills"
}
],
},
)
print(f"Saved agent: {agent.id}")
জাভাস্ক্রিপ্ট
const agent = await client.agents.create({
id: "fibonacci-analyst",
base_agent: "antigravity-preview-09-2026",
agent_config: {
type: "antigravity",
model: "gemini-3.8-flash",
},
system_instruction: "You are a math analysis agent. Generate sequences, visualize them, and export results as PDF reports.",
base_environment: {
type: "remote",
sources: [
{
type: "inline",
target: ".agents/AGENTS.md",
content: "Always include a chart and a summary table in your reports.",
},
{
type: "repository",
source: "https://github.com/your-org/skills",
target: ".agents/skills"
}
],
},
});
console.log(`Saved agent: ${agent.id}`);
জাভা
import com.google.genai.Client;
import com.google.genai.gaos.models.agents.Agent;
import com.google.genai.gaos.models.agents.AgentConfig;
import com.google.genai.gaos.models.agents.BaseEnvironment;
import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import java.util.List;
Client client = new Client();
Environment env = Environment.builder()
.sources(List.of(
Source.builder()
.type(SourceType.INLINE)
.target(".agents/AGENTS.md")
.content("Always include a chart and a summary table in your reports.")
.build(),
Source.builder()
.type(SourceType.REPOSITORY)
.source("https://github.com/your-org/skills")
.target(".agents/skills")
.build()
))
.build();
Agent agentParams = Agent.builder()
.id("fibonacci-analyst")
.baseAgent("antigravity-preview-09-2026")
.agentConfig(AgentConfig.of(
AntigravityAgentConfig.builder()
.model("gemini-3.8-flash")
.build()
))
.systemInstruction("You are a math analysis agent. Generate sequences, visualize them, and export results as PDF reports.")
.baseEnvironment(BaseEnvironment.of(env))
.build();
Agent agent = client.agents.create(agentParams).agent().get();
System.out.println("Saved agent: " + agent.id().orElse(""));
যান
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/agents"
"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.SourceTypeInline.ToPointer(),
Target: genai.Ptr(".agents/AGENTS.md"),
Content: genai.Ptr("Always include a chart and a summary table in your reports."),
},
{
Type: interactions.SourceTypeRepository.ToPointer(),
Source: genai.Ptr("https://github.com/your-org/skills"),
Target: genai.Ptr(".agents/skills"),
},
},
}
res, err := client.Agents.Create(ctx, operations.CreateAgentRequest{
Body: agents.Agent{
ID: genai.Ptr("fibonacci-analyst"),
BaseAgent: genai.Ptr("antigravity-preview-09-2026"),
AgentConfig: genai.Ptr(agents.NewAgentConfig(interactions.AntigravityAgentConfig{
Model: genai.Ptr("gemini-3.8-flash"),
})),
SystemInstruction: genai.Ptr("You are a math analysis agent. Generate sequences, visualize them, and export results as PDF reports."),
BaseEnvironment: genai.Ptr(agents.NewBaseEnvironment(env)),
},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Saved agent: %s\n", *res.Agent.ID)
}
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/agents" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"id": "fibonacci-analyst",
"base_agent": "antigravity-preview-09-2026",
"agent_config": {
"type": "antigravity",
"model": "gemini-3.8-flash"
},
"system_instruction": "You are a math analysis agent. Generate sequences, visualize them, and export results as PDF reports.",
"base_environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always include a chart and a summary table in your reports."
},
{
"type": "repository",
"source": "https://github.com/your-org/skills",
"target": ".agents/skills"
}
]
}
}'
পরিচালিত এজেন্টকে আহ্বান করুন
একবার একটি ম্যানেজড এজেন্ট সেভ করার পর, আপনি আইডি দিয়ে এটিকে চালু করতে পারেন। প্রতিটি চালু করার ফলে বেস এনভায়রনমেন্টটি ফর্ক হয়, তাই প্রতিটি রান পরিষ্কারভাবে শুরু হয়:
পাইথন
result = client.interactions.create(
agent="fibonacci-analyst",
input="Generate the first 50 prime numbers, plot their distribution, and save a PDF report.",
environment="remote",
)
print(result.output_text)
জাভাস্ক্রিপ্ট
const result = await client.interactions.create({
agent: "fibonacci-analyst",
input: "Generate the first 50 prime numbers, plot their distribution, and save a PDF report.",
environment: "remote",
}, {
timeout: 300_000,
});
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.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("fibonacci-analyst"))
.input(InteractionsInput.of("Generate the first 50 prime numbers, plot their distribution, and save a PDF report."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction result = client.interactions.create(CreateInteractionRequestBody.of(params)).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)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("fibonacci-analyst"),
Input: interactions.NewInteractionsInput("Generate the first 50 prime numbers, plot their distribution, and save a PDF report."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
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": "fibonacci-analyst",
"environment": "remote",
"input": "Generate the first 50 prime numbers, plot their distribution, and save a PDF report."
}'
এরপর কী?
- অ্যান্টিগ্র্যাভিটি এজেন্ট : সক্ষমতা, সমর্থিত সরঞ্জাম, মাল্টিমোডাল ইনপুট, মূল্য নির্ধারণ এবং সীমাবদ্ধতা।
- পরিচালিত এজেন্ট তৈরি করুন : আপনার নিজস্ব নির্দেশাবলী, দক্ষতা এবং ডেটা দিয়ে অ্যান্টিগ্র্যাভিটিকে প্রসারিত করুন।
- পরিবেশ : উৎস, নেটওয়ার্কিং, জীবনচক্র, সম্পদের সীমাবদ্ধতা।
- ইন্টারঅ্যাকশন এপিআই : মডেল এবং এজেন্টদের অন্তর্নিহিত এপিআই।