Skip to content

Token limit error with google/gemini-3-pro-image-preview: Request exceeds maximum context length #116

@rainerWJY

Description

@rainerWJY

Problem Description

I'm encountering a token limit error when using the google/gemini-3-pro-image-preview model through both the TypeScript client and the OpenRouter chat web interface.

Error Message

This endpoint's maximum context length is 128000 tokens. However, you requested about 550819 tokens (550222 of text input, 597 of tool input). Please reduce the length of either one, or use the "middle-out" transform to compress your prompt automatically.

Expected Behavior

The model should either:

  1. Accept the request and process it, or
  2. Provide clearer guidance on how to handle large context requests

Actual Behavior

The request is rejected with the above error message, even though I'm using the model through OpenRouter's interface.

Steps to Reproduce

  1. Use google/gemini-3-pro-image-preview model via OpenRouter API (TypeScript client)
  2. Or use the same model in OpenRouter's chat web interface
  3. Send a request with a large context (approximately 550K tokens)
  4. Receive the token limit error

Environment

  • Model: google/gemini-3-pro-image-preview
  • Platform: OpenRouter (both API and web interface)
  • Client: TypeScript

Questions

  1. Is this a limitation of the underlying Google Gemini model, or is it specific to OpenRouter's implementation?
  2. What is the recommended approach for handling large context requests with this model?
  3. Is the "middle-out" transform feature mentioned in the error message available through OpenRouter?
  4. Are there any workarounds or best practices for working with large contexts using this model?

Additional Context

The error occurs consistently across both the API and web interface, suggesting it might be a model-level limitation rather than an implementation issue.

Thank you for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions