Merge https://github.com/google/adk-python/pull/3394 This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling) Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes. ### Testing Plan The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/19056081305/attempts/1#summary-54426435973 The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/19056081446/attempts/1#summary-54426436321 **Unit Tests:** - [ ] I have added or updated unit tests for my change. - [ ] All unit tests pass locally. _Please include a summary of passed `pytest` results._ **Manual End-to-End (E2E) Tests:** _Please provide instructions on how to manually test your changes, including any necessary setup or configuration. Please provide logs or screenshots to help reviewers better understand the fix._ ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] New and existing unit tests pass locally with my changes. - [ ] I have manually tested my changes end-to-end. - [ ] Any dependent changes have been merged and published in downstream modules. ### Additional context - https://github.com/google/adk-python/pull/3382#issuecomment-3488654110 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3394 from jsoref:spelling-contributing c3d5e342c4350f7cae9f8f0c6638b176f2e30e80 PiperOrigin-RevId: 828659867
3.1 KiB
Hello World with Apigee LLM
This sample demonstrates how to use the Agent Development Kit (ADK) with an LLM fronted by an Apigee proxy. It showcases the flexibility of the ApigeeLlm class in configuring the target LLM provider (Gemini or Vertex AI) and API version through the model string.
Setup
Before running the sample, you need to configure your environment with the necessary credentials.
-
Create a
.envfile: Copy the sample environment file to a new file named.envin the same directory.cp .env-sample .env -
Set Environment Variables: Open the
.envfile and provide values for the following variables:GOOGLE_API_KEY: Your API key for the Google AI services (Gemini).APIGEE_PROXY_URL: The full URL of your Apigee proxy endpoint.
Example
.envfile:GOOGLE_API_KEY="your-google-api-key" APIGEE_PROXY_URL="https://your-apigee-proxy.net/basepath"The
main.pyscript will automatically load these variables when it runs.
Run the Sample
Once your .env file is configured, you can run the sample with the following command:
python main.py
Configuring the Apigee LLM
The ApigeeLlm class is configured using a special model string format in agent.py. This string determines which backend provider (Vertex AI or Gemini) and which API version to use.
Model String Format
The supported format is:
apigee/[<provider>/][<version>/]<model_id>
-
provider(optional): Can bevertex_aiorgemini.- If specified, it forces the use of that provider.
- If omitted, the provider is determined by the
GOOGLE_GENAI_USE_VERTEXAIenvironment variable. If this variable is set totrueor1, Vertex AI is used; otherwise,geminiis used by default.
-
version(optional): The API version to use (e.g.,v1,v1beta).- If omitted, the default version for the selected provider is used.
-
model_id(required): The identifier for the model you want to use (e.g.,gemini-2.5-flash).
Configuration Examples
Here are some examples of how to configure the model string in agent.py to achieve different behaviors:
-
Implicit Provider (determined by environment variable):
-
model="apigee/gemini-2.5-flash"- Uses the default API version.
- Provider is Vertex AI if
GOOGLE_GENAI_USE_VERTEXAIis true; otherwise, Gemini.
-
model="apigee/v1/gemini-2.5-flash"- Uses API version
v1. - Provider is determined by the environment variable.
- Uses API version
-
-
Explicit Provider (ignores environment variable):
-
model="apigee/vertex_ai/gemini-2.5-flash"- Uses Vertex AI with the default API version.
-
model="apigee/gemini/gemini-2.5-flash"- Uses Gemini with the default API version.
-
model="apigee/gemini/v1/gemini-2.5-flash"- Uses Gemini with API version
v1.
- Uses Gemini with API version
-
model="apigee/vertex_ai/v1beta/gemini-2.5-flash"- Uses Vertex AI with API version
v1beta.
- Uses Vertex AI with API version
-
By modifying the model string in agent.py, you can test various configurations without changing the core logic of the agent.