Skip to content

feat: add force_append_path parameter to http_options#1701

Open
what-is-thy-bidding wants to merge 16 commits intogoogleapis:mainfrom
what-is-thy-bidding:append_model_path
Open

feat: add force_append_path parameter to http_options#1701
what-is-thy-bidding wants to merge 16 commits intogoogleapis:mainfrom
what-is-thy-bidding:append_model_path

Conversation

@what-is-thy-bidding
Copy link

@what-is-thy-bidding what-is-thy-bidding commented Nov 14, 2025

feat: Add force_append_path parameter to http_options for explicit URL control

Add new force_append_path parameter to http_options that gives users explicit
control over whether API paths are appended to custom base URLs. This solves
404 errors when using custom base URLs with API gateway proxies.

Problem:
When using custom base URLs (e.g., API gateway proxies) with Bearer token
authentication, the SDK wasn't appending model-specific API paths, resulting
in 404 errors. Users had to resort to workarounds like setting dummy api_key
values.

Solution:
The new force_append_path parameter provides three options:

  • True: Always append API paths (recommended for custom proxies)
  • False: Never append paths (for complete endpoint URLs)
  • None: Use default SDK logic (backward compatible)

Changes:

  • Added force_append_path: Optional[bool] field to HttpOptions (types.py)
  • Added force_append_path: Optional[bool] field to HttpOptionsDict (types.py)
  • Updated URL construction logic in _api_client.py to check force_append_path
  • Priority: explicit force_append_path setting > default SDK logic
  • Updated README.md with usage examples and documentation

Example usage:

client = genai.Client(
    vertexai=True,
    http_options={
        'base_url': 'https://my-proxy.com/ais/v1/',
        'force_append_path': True,  # Explicitly enable path appending
        'headers': {'Authorization': 'Bearer token'},
    },
)

Benefits:

  • Clean, configuration-driven solution
  • No workarounds or dummy values needed
  • Backward compatible (None falls back to existing logic)
  • Explicit user control over URL construction

Files modified:

  • google/genai/types.py
  • google/genai/_api_client.py
  • README.md

Breaking changes: None
Backward compatible: Yes

@what-is-thy-bidding what-is-thy-bidding changed the title Append model path feat: Append model path Nov 14, 2025
@what-is-thy-bidding what-is-thy-bidding changed the title feat: Append model path feat: add append_path parameter to http_options Nov 14, 2025
@what-is-thy-bidding
Copy link
Author

@sasha-gitg : can you please have a look at this solution to my 404 error?
I'd really appreciate some feedback, I am trying to learn as well :)

@what-is-thy-bidding what-is-thy-bidding changed the title feat: add append_path parameter to http_options feat: add force_append_path parameter to http_options Nov 16, 2025
@janasangeetha janasangeetha self-assigned this Nov 19, 2025
@janasangeetha janasangeetha added size:L Code changes between 40-100 lines api: vertex-ai Issues related to the Vertex AI API. labels Nov 19, 2025
@janasangeetha
Copy link
Collaborator

Hi @what-is-thy-bidding
Thanks for your contributions!
The branch is out-of-date. Please update the same.

@what-is-thy-bidding
Copy link
Author

what-is-thy-bidding commented Nov 19, 2025

@janasangeetha : Thanks for reaching back.
I have updated the branch and tested the changes again.

Please let me know incase more info is needed form me.
Thanks

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

Labels

api: vertex-ai Issues related to the Vertex AI API. ready to pull size:L Code changes between 40-100 lines status:awaiting user response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants