Example Request
# Step 1: Create a custom agent.
curl -X POST https://generativelanguage.googleapis.com/v1beta/agents \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "code-reviewer",
"base_agent": "antigravity-preview-05-2026",
"system_instruction": "You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.",
"base_environment": {
"type": "remote",
"sources": [{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/repo"
}]
}
}'
# Step 2: Use the custom agent.
curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent": "code-reviewer",
"input": "Review the latest changes in /workspace/repo/src and file a summary.",
"environment": "remote"
}'
import uuid
from google import genai
client = genai.Client()
# Step 1: Create a custom agent.
agent_id = f"code-reviewer-{uuid.uuid4().hex[:8]}"
client.agents.create(
id=agent_id,
base_agent="antigravity-preview-05-2026",
system_instruction=(
"You are a senior code reviewer. Check every file for bugs, style"
" issues, and security vulnerabilities."
),
base_environment={
"type": "remote",
"sources": [{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/repo",
}],
},
)
# Step 2: Use the custom agent.
result = client.interactions.create(
agent=agent_id,
input=(
"Review the latest changes in /workspace/repo/src and file a"
" summary."
),
environment="remote",
)
print(result.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
// Step 1: Create a custom agent.
const agentId = `code-reviewer-${crypto.randomUUID().slice(0, 8)}`;
await ai.agents.create({
id: agentId,
base_agent: 'antigravity-preview-05-2026',
system_instruction:
'You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.',
base_environment: {
type: 'remote',
sources: [
{
type: 'repository',
source: 'https://github.com/octocat/Spoon-Knife',
target: '/workspace/repo',
},
],
},
});
// Step 2: Use the custom agent.
const result = await ai.interactions.create({
agent: agentId,
input:
'Review the latest changes in /workspace/repo/src and file a summary.',
environment: 'remote',
});
console.log(result.output_text);
import com.google.genai.gaos.models.agents.Agent;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.agents.BaseEnvironment;
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.environments.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.interactions.Step;
Client client = new Client();
// Step 1: Create a custom agent.
String agentId = "code-reviewer-" + UUID.randomUUID().toString().substring(0, 8);
com.google.genai.gaos.models.interactions.Environment baseEnv =
com.google.genai.gaos.models.interactions.Environment.builder()
.sources(
List.of(
Source.builder()
.type(SourceType.REPOSITORY)
.source("https://github.com/octocat/Spoon-Knife")
.target("/workspace/repo")
.build()))
.build();
Agent customAgent =
Agent.builder()
.id(agentId)
.baseAgent("antigravity-preview-05-2026")
.systemInstruction(
"You are a senior code reviewer. Check every file for bugs, style issues, and"
+ " security vulnerabilities.")
.baseEnvironment(BaseEnvironment.of(baseEnv))
.build();
client.agents.create(customAgent);
// Step 2: Use the custom agent.
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent(AgentOption.of(agentId))
.input(
InteractionsInput.of(
"Review the latest changes in /workspace/repo/src and file a summary."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.outputText().orElse(""));
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/genai"
gaos_agents "google.golang.org/genai/interactions/models/agents"
gaos_interactions "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)
}
// Step 1: Create a custom agent.
agentID := fmt.Sprintf("code-reviewer-%d", time.Now().UnixNano())
baseEnv := gaos_interactions.Environment{
Sources: []gaos_interactions.Source{
{
Type: genai.Ptr(gaos_interactions.SourceTypeRepository),
Source: genai.Ptr("https://github.com/octocat/Spoon-Knife"),
Target: genai.Ptr("/workspace/repo"),
},
},
}
_, err = client.Agents.Create(ctx, operations.CreateAgentRequest{
Body: gaos_agents.Agent{
ID: genai.Ptr(agentID),
BaseAgent: genai.Ptr("antigravity-preview-05-2026"),
SystemInstruction: genai.Ptr("You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities."),
BaseEnvironment: genai.Ptr(gaos_agents.NewBaseEnvironment(baseEnv)),
},
})
if err != nil {
log.Fatal(err)
}
// Step 2: Use the custom agent.
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateAgentInteraction{
Agent: gaos_interactions.AgentOption(agentID),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("Review the latest changes in /workspace/repo/src and file a summary.")),
Environment: genai.Ptr(gaos_interactions.NewCreateAgentInteractionEnvironment("remote")),
})
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{Body: body})
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil && res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}