Skip to content

Expose Interactions API error types from a public module #2344

@shaswatshah

Description

@shaswatshah

Problem

The Interactions API error types (APIStatusError, InternalServerError, RateLimitError, APIConnectionError, APITimeoutError, etc.) are only importable from the private google.genai._interactions module:

from google.genai._interactions import (
    APIStatusError,
    InternalServerError,
    RateLimitError,
    APIConnectionError,
    APITimeoutError,
)

The public google.genai.errors module exposes a separate hierarchy (ServerError, ClientError) that is unrelated to the stainless-generated Interactions API errors — issubclass(InternalServerError, ServerError) is False.

Impact

Linters flag these imports as private-module access violations (e.g. Ruff PLC2701), forcing consumers to suppress the rule. More importantly, private modules have no stability guarantees, so these imports could break on any patch release.

Suggestion

Re-export the Interactions API error types (or a shared base class like GeminiNextGenAPIClientError) from google.genai.errors or a new public module (e.g. google.genai.interactions.errors), so downstream code can catch them without reaching into private internals.

SDK version: 1.73.1

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.status:awaiting user responsetype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions