Back to Prompt Library
implementation

Initialize Google ADK Agent for Inference Routing

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Google ADK Multi-Model Inference Routing with DeepSeek R1 for Cerebras/Trainium Optimization

Format
Code-aware
Lines
13
Sections
1
Linked challenge
Google ADK Multi-Model Inference Routing with DeepSeek R1 for Cerebras/Trainium Optimization

Prompt source

Original prompt text with formatting preserved for inspection.

13 lines
1 sections
No variables
1 code block
Your first task is to set up a Google ADK agent that serves as the primary inference router. Define its initial capabilities and how it will accept incoming inference requests. Integrate a DeepSeek R1 client as a tool the agent can call, and define a simulated 'Trainium' tool for cost-effective inference. The agent should be able to decide which tool (model) to use. ```python
import google.generativeai as genai
from google.generativeai import GenerativeModel
from google.generativeai.types import ChatResponse
from typing import List, Dict, Union # Configure DeepSeek R1 client (placeholder - replace with actual API calls)
class DeepSeekR1Client: def infer(self, prompt: str) -> str: # Simulate DeepSeek R1 API call return f"DeepSeek R1 response for: {prompt}" # Simulated Trainium tool
@genai.tool
def simulated_trainium_infer(prompt: str) -> str: """Performs cost-effective, lower-latency inference for simple tasks.""" return f"Simulated Trainium response for: {prompt}" # Configure the Google ADK model (using a powerful LLM for routing decisions)
# genai.configure(api_key="YOUR_GEMINI_API_KEY")
# routing_model = GenerativeModel('gemini-3-flash') # Or other powerful model # Define the agent function
def inference_router_agent_fn(prompt: str) -> Union[str, genai.tool]: # Agent logic to decide between DeepSeek R1 or simulated_trainium_infer # This should return a tool call or a direct response. if len(prompt.split()) < 10 and "translate" in prompt.lower(): return simulated_trainium_infer.function(prompt) else: # Directly call DeepSeekR1Client or wrap it as a tool for ADK # For this prompt, assume it's integrated as a callable by the agent's logic return DeepSeekR1Client().infer(prompt) # This function would be part of the ADK orchestration
# response = routing_model.generate_content(inference_router_agent_fn("Your prompt"))
```

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.