Example Request
curl -X POST https://generativelanguage.googleapis.com/v1beta/agents \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "data-analyst-abc123",
"base_agent": "antigravity-preview-05-2026",
"system_instruction": "You are a data analyst. Always include visualizations and export results as PDF.",
"base_environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always use matplotlib for charts. Include a summary table in every report."
},
{
"type": "repository",
"source": "https://github.com/my-org/analysis-templates",
"target": "/workspace/templates"
}
]
}
}'
import uuid
from google import genai
client = genai.Client()
agent = client.agents.create(
id=f"data-analyst-{uuid.uuid4().hex[:8]}",
base_agent="antigravity-preview-05-2026",
system_instruction=(
"You are a data analyst. Always include visualizations and export"
" results as PDF."
),
base_environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": (
"Always use matplotlib for charts. Include a summary"
" table in every report."
),
},
{
"type": "repository",
"source": "https://github.com/my-org/analysis-templates",
"target": "/workspace/templates",
},
],
},
)
print(f"Created agent: {agent.id}")
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const agentId = `data-analyst-${crypto.randomUUID().slice(0, 8)}`;
const agent = await ai.agents.create({
id: agentId,
base_agent: 'antigravity-preview-05-2026',
system_instruction:
'You are a data analyst. Always include visualizations and export results as PDF.',
base_environment: {
type: 'remote',
sources: [
{
type: 'inline',
target: '.agents/AGENTS.md',
content:
'Always use matplotlib for charts. Include a summary table in every report.',
},
{
type: 'repository',
source: 'https://github.com/my-org/analysis-templates',
target: '/workspace/templates',
},
],
},
});
console.log(`Created agent: ${agent.id}`);
import com.google.genai.gaos.models.agents.Agent;
import com.google.genai.gaos.models.agents.BaseEnvironment;
import com.google.genai.Client;
import com.google.genai.gaos.models.operations.CreateAgentResponse;
import com.google.genai.gaos.models.environments.Environment;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
Client client = new Client();
String agentId = "data-analyst-" + UUID.randomUUID().toString().substring(0, 8);
com.google.genai.gaos.models.interactions.Environment env =
com.google.genai.gaos.models.interactions.Environment.builder()
.sources(
List.of(
Source.builder()
.type(SourceType.INLINE)
.target(".agents/AGENTS.md")
.content(
"Always use matplotlib for charts. Include a summary table in every"
+ " report.")
.build(),
Source.builder()
.type(SourceType.REPOSITORY)
.source("https://github.com/my-org/analysis-templates")
.target("/workspace/templates")
.build()))
.build();
Agent agent =
Agent.builder()
.id(agentId)
.baseAgent("antigravity-preview-05-2026")
.systemInstruction(
"You are a data analyst. Always include visualizations and export results as PDF.")
.baseEnvironment(BaseEnvironment.of(env))
.build();
CreateAgentResponse response = client.agents.create(agent);
System.out.println("Created agent: " + response.agent().flatMap(Agent::id).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)
}
agentID := fmt.Sprintf("data-analyst-%d", time.Now().UnixNano())
env := gaos_interactions.Environment{
Sources: []gaos_interactions.Source{
{
Type: genai.Ptr(gaos_interactions.SourceTypeInline),
Target: genai.Ptr(".agents/AGENTS.md"),
Content: genai.Ptr("Always use matplotlib for charts. Include a summary table in every report."),
},
{
Type: genai.Ptr(gaos_interactions.SourceTypeRepository),
Source: genai.Ptr("https://github.com/my-org/analysis-templates"),
Target: genai.Ptr("/workspace/templates"),
},
},
}
req := operations.CreateAgentRequest{
Body: gaos_agents.Agent{
ID: genai.Ptr(agentID),
BaseAgent: genai.Ptr("antigravity-preview-05-2026"),
SystemInstruction: genai.Ptr("You are a data analyst. Always include visualizations and export results as PDF."),
BaseEnvironment: genai.Ptr(gaos_agents.NewBaseEnvironment(env)),
},
}
res, err := client.Agents.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Agent != nil && res.Agent.ID != nil {
fmt.Printf("Created agent: %s\n", *res.Agent.ID)
}
}