Skip to content

handle error message when the model is experiencing high demand #5937

Closed

Description

@KellySit

Describe the Bug:
Went through a quick start and experienced the following error:
errorCode : "ServerError" errorMessage : "503 UNAVAILABLE. {'error': {'code': 503, 'message': 'This model is currently experiencing high demand. Spikes in demand are usually temporary. Please try again later.', 'status': 'UNAVAILABLE'}}"

Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:

  1. Follow all current Quick Start instructions
  2. If the model is now experiencing high demand, the error may appear.

Expected and Observed Behavior:
Unable to respond to the user for a short period of time.

Environment Details:

  • ADK Library Version : 2.1.0
  • Desktop OS: macOS
  • Python Version: 3.11

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-2.5-flash

Additional Context:
I suggest trying to add retry configuration to the gemini model in the Quick Start README.md (Agent part) to automatically handle these transient errors, since gemini 2.5 flash can be configured to automatically retry on this error using retry_options parameter in Gemini class.
But overall it is not an urgent bug to be fixed as it is a temporary issue which can resolve itself in a short wait.

How often has this issue occurred?:
Rare, only when the model is in high demand

Activity

  1. added
    documentation[Component] This issue is related to documentation, it will be transferred to adk-docs
    on Jun 2, 2026
  2. surajksharma07 commented on Jun 2, 2026

    @surajksharma07
    Collaborator

    @KellySit This looks like a transient 503 from Gemini's side — worth trying: pass retry_options=types.HttpRetryOptions(initial_delay=1, attempts=3) to the Gemini class (from google.genai import types), which lets the SDK automatically retry on these transient failures.

    Could you give that a try and let us know if it helps?

  3. added
    request clarification[Status] The maintainer need clarification or more information from the author
    on Jun 2, 2026
  4. KellySit commented on Jun 3, 2026

    @KellySit
    Author

    @surajksharma07 sure, I can give it a try and I will let you know more later

  5. nicolay-r commented on Jun 24, 2026

    @nicolay-r

    @surajksharma07, I've tried to customize the original agent example here in accordance with your comment:

    from google.adk.agents import Agent
    from google.adk.models import Gemini
    from google.genai import types
    
    root_agent = Agent(
        name="greeting_agent",
        model=Gemini(
                model="gemini-2.5-flash",
                retry_options=types.HttpRetryOptions(attempts=3, initial_delay=1.0),
        ),
        instruction="You are a helpful assistant. Greet the user warmly.",
    )

    And it works on the free-tier API!

  6. surajksharma07 commented on Jul 13, 2026

    @surajksharma07
    Collaborator

    Thanks for the independent confirmation @nicolay-r — good to know retry_options holds up on the free tier too!

    Worth flagging though: PR #6059 (the actual docs fix) has stalled.
    @boyangsvl asked back on Jun 11 for a dedicated retry_options sample instead of editing the main quickstart directly, that's never been addressed,Checked latest main directly: neither README.md nor contributing/samples/core/quickstart/agent.py mention retry_options yet, so this gap is still open through v2.4.0.

    @KellySit — are you able to add the dedicated sample so this can finally land, or should someone else pick it up?

    Team is looking more into it.
    Thanks!

  7. KellySit commented on Jul 14, 2026

    @KellySit
    Author

    @surajksharma07 sure I can pick this up and have it done soon!

  8. surajksharma07 commented on Aug 3, 2026

    @surajksharma07
    Collaborator

    Closing this out — @KellySit, the dedicated sample never landed and #6059 got closed for that same reason, so there's nothing left in flight here.

    To be clear, the README and quickstart still don't mention retry_options at latest (v2.6.1), but the workaround itself is solid — confirmed independently by two people now.
    Anyone hitting this transient 503 can use retry_options=types.HttpRetryOptions(attempts=3, initial_delay=1.0) on the Gemini model today.

    Reopen or send a fresh PR with the dedicated sample anytime if someone wants to pick it back up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

documentation[Component] This issue is related to documentation, it will be transferred to adk-docsrequest clarification[Status] The maintainer need clarification or more information from the author

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions