Replies: 2 comments
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Currently, you can't directly instantiate the Hello! That's a great question. You are right that most examples focus on Gemini models. Integrating other models like those from OpenAI, Anthropic, or local models is a key feature of ADK, and it's achieved using our While you can't define the 1. Define the Agent in PythonThe most direct and documented way to use First, ensure you have export OPENAI_API_KEY="YOUR_OPENAI_API_KEY" Next, create a Python file (e.g., from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
# --- Agent using OpenAI's GPT-4o via LiteLLM ---
my_agent = LlmAgent(
model=LiteLlm(model="openai/gpt-4o"),
name="openai_agent",
instruction="You are a helpful assistant powered by GPT-4o.",
# You can still define tools and other parameters here
# tools=[...]
) You can now use 2. Referencing a Python-defined Agent from YAMLIf you are using a YAML-centric workflow for a multi-agent setup (e.g., a Supervisor agent with sub-agents), you can define your For instance, if you have a supervisor agent defined in
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
openai_tool_agent = LlmAgent(
model=LiteLlm(model="openai/gpt-4o"),
name="openai_tool_agent",
description="An agent that can perform tasks using OpenAI.",
# ... tools, etc.
)
agent_class: Supervisor
name: my_supervisor
# ... other supervisor config
sub_agents:
- code: my_agents.openai_tool_agent # This points to the Python object
- config_path: some_other_gemini_agent.yaml This approach allows you to keep your agent configurations modular while seamlessly integrating agents that use different model backends. For more details on using different models, you can refer to the official documentation [1]. Let us know if you have any more questions! [1] https://google.github.io/adk-docs/agents/models |
Beta Was this translation helpful? Give feedback.
-
Let's use the other discussion thread. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All,
I am trying out the yaml config approach - simplifies a lot of things. How can I create the agent for any other LLM - openai or others through litellm in this?
If someone has some example, can you please point me to that.
I have looked at https://github.com/google/adk-python/tree/main/contributing/samples/tool_agent_tool_config and other examples, but all are based on gemini models.
Beta Was this translation helpful? Give feedback.
All reactions