gen_ai_hub.proxy.langchain packageΒΆ

gen_ai_hub.proxy.langchain.init_llm(*args, proxy_client: BaseProxyClient | None = None, temperature: float = 0.0, max_tokens: int = 256, top_k: int | None = None, top_p: float = 1.0, init_func: Callable | None = None, model_id: str | None = '', **kwargs) BaseLanguageModelΒΆ

Initializes a language model using the specified parameters.

Parameters:
  • proxy_client (ProxyClient) – The proxy client to use for the model (optional)

  • temperature (float) – The temperature parameter for model generation (default: 0.0)

  • max_tokens (int) – The maximum number of tokens to generate (default: 256)

  • top_k (int) – The top-k parameter for model generation (optional)

  • top_p (float) – The top-p parameter for model generation (default: 1.0)

  • init_func (Callable) – Function to call for initializing the model, optional

  • model_id (str) – id of the Amazon Bedrock model, needed in case a custom Amazon Bedrock model is being initiated (optional)

Returns:

The initialized language model

Return type:

BaseLanguageModel

gen_ai_hub.proxy.langchain.init_embedding_model(*args, proxy_client: BaseProxyClient | None = None, init_func: Callable | None = None, model_id: str | None = '', **kwargs) EmbeddingsΒΆ

Initializes an embedding model using the specified parameters.

Parameters:
  • proxy_client (BaseProxyClient) – The proxy client to use for the model (optional)

  • init_func (Callable) – Function to call for initializing the model, optional

  • model_id (str) – id of the Amazon Bedrock model, needed in case a custom Amazon Bedrock model is being initiated (optional)

Returns:

The initialized embedding model

Return type:

Embeddings

gen_ai_hub.proxy.langchain.OpenAIClientΒΆ

alias of OpenAI

class gen_ai_hub.proxy.langchain.OpenAIEmbeddings(*args, client: ~typing.Any = None, async_client: ~typing.Any = None, model: str | None = None, dimensions: int | None = None, deployment: str | None = 'text-embedding-ada-002', api_version: str | None = None, base_url: str | None = <factory>, openai_api_type: str | None = <factory>, openai_proxy: str | None = <factory>, embedding_ctx_length: int = 8191, api_key: ~pydantic.types.SecretStr | None | ~collections.abc.Callable[[], str] | ~collections.abc.Callable[[], ~collections.abc.Awaitable[str]] = <factory>, organization: str | None = <factory>, allowed_special: ~typing.Literal['all'] | set[str] | None = None, disallowed_special: ~typing.Literal['all'] | set[str] | ~collections.abc.Sequence[str] | None = None, chunk_size: int = 16, max_retries: int = 2, timeout: float | tuple[float, float] | ~typing.Any | None = None, headers: ~typing.Any = None, tiktoken_enabled: bool = True, tiktoken_model_name: str | None = 'text-embedding-ada-002', show_progress_bar: bool = False, model_kwargs: dict[str, ~typing.Any] = <factory>, skip_empty: bool = False, default_headers: ~collections.abc.Mapping[str, str] | None = None, default_query: ~collections.abc.Mapping[str, object] | None = None, retry_min_seconds: int = 4, retry_max_seconds: int = 20, http_client: ~typing.Any | None = None, http_async_client: ~typing.Any | None = None, check_embedding_ctx_length: bool = True, proxy_client: ~typing.Any | None = None, deployment_id: str | None = None, config_name: str | None = None, config_id: str | None = None, proxy_model_name: str | None = None, input_type: str | None = None, **kwargs)ΒΆ

Bases: ProxyOpenAI, OpenAIEmbeddings

OpenAI Embeddings model using a proxy.

__init__(*args, **kwargs)ΒΆ

Initialize the OpenAIEmbeddings object.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'validate_by_alias': True, 'validate_by_name': True}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod validate_environment(values: Dict) DictΒΆ

Validates the environment.

Parameters:

values (Dict) – The input values

Returns:

The validated values

Return type:

Dict

model: str | NoneΒΆ
tiktoken_model_name: str | NoneΒΆ

The model name to pass to tiktoken when using this class.

Tiktoken is used to count the number of tokens in documents to constrain them to be under a certain limit.

By default, when set to None, this will be the same as the embedding model name. However, there are some cases where you may want to use this Embedding class with a model name not supported by tiktoken. This can include when using Azure embeddings or when using one of the many model providers that expose an OpenAI-like API but with different models. In those cases, in order to avoid erroring when tiktoken is called, you can specify a model name to use here.

chunk_size: intΒΆ

Maximum number of texts to embed in each batch

openai_api_version: str | NoneΒΆ

Version of the OpenAI API to use.

Automatically inferred from env var OPENAI_API_VERSION if not provided.

input_type: str | NoneΒΆ
gen_ai_hub.proxy.langchain.AsyncOpenAIClientΒΆ

alias of AsyncOpenAI

class gen_ai_hub.proxy.langchain.ChatOpenAI(*args, name: str | None = None, cache: ~langchain_core.caches.BaseCache | bool | None = None, verbose: bool = <factory>, callbacks: list[~langchain_core.callbacks.base.BaseCallbackHandler] | ~langchain_core.callbacks.base.BaseCallbackManager | None = None, tags: list[str] | None = None, metadata: dict[str, ~typing.Any] | None = None, custom_get_token_ids: ~collections.abc.Callable[[str], list[int]] | None = None, rate_limiter: ~langchain_core.rate_limiters.BaseRateLimiter | None = None, disable_streaming: bool | ~typing.Literal['tool_calling'] = False, output_version: str | None = <factory>, profile: ~langchain_core.language_models.model_profile.ModelProfile | None = None, client: ~typing.Any = None, async_client: ~typing.Any = None, root_client: ~typing.Any = None, root_async_client: ~typing.Any = None, model_name: str | None = None, temperature: float | None = None, model_kwargs: dict[str, ~typing.Any] = <factory>, api_key: ~pydantic.types.SecretStr | None | ~collections.abc.Callable[[], str] | ~collections.abc.Callable[[], ~collections.abc.Awaitable[str]] = None, base_url: str | None = None, organization: str | None = None, openai_proxy: str | None = <factory>, timeout: float | tuple[float, float] | ~typing.Any | None = None, stream_usage: bool | None = None, max_retries: int | None = None, presence_penalty: float | None = None, frequency_penalty: float | None = None, seed: int | None = None, logprobs: bool | None = None, top_logprobs: int | None = None, logit_bias: dict[int, int] | None = None, streaming: bool = False, n: int | None = None, top_p: float | None = None, max_completion_tokens: int | None = None, reasoning_effort: str | None = None, reasoning: dict[str, ~typing.Any] | None = None, verbosity: str | None = None, tiktoken_model_name: str | None = None, default_headers: ~collections.abc.Mapping[str, str] | None = None, default_query: ~collections.abc.Mapping[str, object] | None = None, http_client: ~typing.Any | None = None, http_async_client: ~typing.Any | None = None, http_socket_options: ~collections.abc.Sequence[tuple[int, int, int]] | None = None, stream_chunk_timeout: float | None = <factory>, stop_sequences: list[str] | str | None = None, extra_body: ~collections.abc.Mapping[str, ~typing.Any] | None = None, include_response_headers: bool = False, disabled_params: dict[str, ~typing.Any] | None = None, context_management: list[dict[str, ~typing.Any]] | None = None, include: list[str] | None = None, prompt_cache_options: dict[str, ~typing.Any] | None = None, service_tier: str | None = None, store: bool | None = None, truncation: str | None = None, use_previous_response_id: bool = False, use_responses_api: bool | None = None, proxy_client: ~typing.Any | None = None, deployment_id: str | None = None, config_name: str | None = None, config_id: str | None = None, proxy_model_name: str | None = None, api_version: str | None = None, **kwargs)ΒΆ

Bases: ProxyOpenAI, ChatOpenAI

ChatOpenAI model using a proxy.

Parameters:
  • ProxyOpenAI (class) – Base class for OpenAI models using a proxy

  • ChatOpenAI (class) – ChatOpenAI class from langchain_openai

__init__(*args, **kwargs)ΒΆ

Initialize the ChatOpenAI object.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'validate_by_alias': True, 'validate_by_name': True}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod validate_environment(values: Dict) DictΒΆ

Validates the environment.

Parameters:

values (Dict) – The input values

Raises:

ValueError – n must be at least 1.

Returns:

The validated values

Return type:

Dict

model_name: str | NoneΒΆ

Model name to use.

openai_api_version: str | NoneΒΆ
class gen_ai_hub.proxy.langchain.BedrockEmbeddings(*args, client: Any = None, region_name: str | None = None, credentials_profile_name: str | None = None, model_id: str = 'amazon.titan-embed-text-v1', model_kwargs: Dict | None = None, endpoint_url: str | None = None, normalize: bool = False, **kwargs)ΒΆ

Bases: AICoreBedrockBaseModel, BedrockEmbeddings

Drop-in replacement for LangChain BedrockEmbeddings.

__init__(*args, **kwargs)ΒΆ
Initializes the AICoreBedrockBaseModel with AICore specific parameters.

Extends the constructor of the base class with aicore specific parameters

Parameters:
  • model_id (str, optional) – the model identifier, defaults to β€œβ€

  • deployment_id (str, optional) – the deployment identifier, defaults to β€œβ€

  • model_name (str, optional) – the model name, defaults to β€œβ€

  • config_id (str, optional) – the configuration identifier, defaults to β€œβ€

  • config_name (str, optional) – the configuration name, defaults to β€œβ€

  • proxy_client (Optional[BaseProxyClient], optional) – the proxy client to use, defaults to None

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'protected_namespaces': ()}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

client: AnyΒΆ

Bedrock client.

region_name: str | NoneΒΆ

The aws region e.g., us-west-2. Fallsback to AWS_DEFAULT_REGION env variable or region specified in ~/.aws/config in case it is not provided here.

credentials_profile_name: str | NoneΒΆ

The name of the profile in the ~/.aws/credentials or ~/.aws/config files, which has either access keys or role information specified. If not specified, the default credential profile or, if on an EC2 instance, credentials from IMDS will be used. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html

model_id: strΒΆ

Id of the model to call, e.g., amazon.titan-embed-text-v1, this is equivalent to the modelId property in the list-foundation-models api

model_kwargs: Dict | NoneΒΆ

Keyword arguments to pass to the model.

endpoint_url: str | NoneΒΆ

Needed if you don’t want to default to us-east-1 endpoint

normalize: boolΒΆ

Whether the embeddings should be normalized to unit vectors

class gen_ai_hub.proxy.langchain.AICoreBedrockBaseModel(*args, model_id: str = '', deployment_id: str = '', model_name: str = '', config_id: str = '', config_name: str = '', proxy_client: BaseProxyClient | None = None, **kwargs)ΒΆ

Bases: BaseModel

AICoreBedrockBaseModel provides all adjustments to boto3 based LangChain classes to enable communication with SAP AI Core.

__init__(*args, model_id: str = '', deployment_id: str = '', model_name: str = '', config_id: str = '', config_name: str = '', proxy_client: BaseProxyClient | None = None, **kwargs)ΒΆ
Initializes the AICoreBedrockBaseModel with AICore specific parameters.

Extends the constructor of the base class with aicore specific parameters

Parameters:
  • model_id (str, optional) – the model identifier, defaults to β€œβ€

  • deployment_id (str, optional) – the deployment identifier, defaults to β€œβ€

  • model_name (str, optional) – the model name, defaults to β€œβ€

  • config_id (str, optional) – the configuration identifier, defaults to β€œβ€

  • config_name (str, optional) – the configuration name, defaults to β€œβ€

  • proxy_client (Optional[BaseProxyClient], optional) – the proxy client to use, defaults to None

static get_corresponding_model_id(full_model_name, model_version='latest')ΒΆ

Gets the corresponding model ID for a given model name. :param full_model_name: the model name :type full_model_name: str :param model_version: the model version :type model_version: str :return: the corresponding model ID :rtype: str

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod validate_environment(values: Dict) DictΒΆ

Validates and sets up the environment for the model.

Parameters:

values (Dict) – the input values

Returns:

the validated values

Return type:

Dict

class gen_ai_hub.proxy.langchain.ChatBedrock(*args, name: str | None = None, cache: ~langchain_core.caches.BaseCache | bool | None = None, verbose: bool = <factory>, callbacks: list[~langchain_core.callbacks.base.BaseCallbackHandler] | ~langchain_core.callbacks.base.BaseCallbackManager | None = None, tags: list[str] | None = None, metadata: dict[str, ~typing.Any] | None = None, custom_get_token_ids: ~collections.abc.Callable[[str], list[int]] | None = None, client: ~typing.Any = None, bedrock_client: ~typing.Any = None, region: str | None = None, credentials_profile_name: str | None = None, aws_access_key_id: ~pydantic.types.SecretStr | None = <factory>, aws_secret_access_key: ~pydantic.types.SecretStr | None = <factory>, aws_session_token: ~pydantic.types.SecretStr | None = <factory>, api_key: ~pydantic.types.SecretStr | None = <factory>, config: ~typing.Any = None, timeout: int | None = None, max_retries: int | None = None, provider: str | None = None, model: str, base_model: str | None = None, model_kwargs: ~typing.Dict[str, ~typing.Any] | None = None, endpoint_url: str | None = None, streaming: bool = False, provider_stop_sequence_key_name_map: ~typing.Mapping[str, str] = {'ai21': 'stop_sequences', 'amazon': 'stopSequences', 'anthropic': 'stop_sequences', 'cohere': 'stop_sequences', 'mistral': 'stop_sequences'}, provider_stop_reason_key_map: ~typing.Mapping[str, str] = {'ai21': 'finishReason', 'amazon': 'completionReason', 'anthropic': 'stop_reason', 'cohere': 'finish_reason', 'mistral': 'stop_reason'}, guardrails: ~typing.Mapping[str, ~typing.Any] | None = {'guardrailIdentifier': None, 'guardrailVersion': None, 'trace': None}, temperature: float | None = None, max_tokens: int | None = None, service_tier: ~typing.Literal['priority', 'default', 'flex', 'reserved'] | None = None, rate_limiter: ~langchain_core.rate_limiters.BaseRateLimiter | None = None, disable_streaming: bool | ~typing.Literal['tool_calling'] = False, output_version: str | None = <factory>, profile: ~langchain_core.language_models.model_profile.ModelProfile | None = None, system_prompt_with_tools: str = '', beta_use_converse_api: bool = False, stop: ~typing.List[str] | None = None, **kwargs)ΒΆ

Bases: AICoreBedrockBaseModel, ChatBedrock

Drop-in replacement for LangChain ChatBedrock.

__init__(*args, **kwargs)ΒΆ
Initializes the AICoreBedrockBaseModel with AICore specific parameters.

Extends the constructor of the base class with aicore specific parameters

Parameters:
  • model_id (str, optional) – the model identifier, defaults to β€œβ€

  • deployment_id (str, optional) – the deployment identifier, defaults to β€œβ€

  • model_name (str, optional) – the model name, defaults to β€œβ€

  • config_id (str, optional) – the configuration identifier, defaults to β€œβ€

  • config_name (str, optional) – the configuration name, defaults to β€œβ€

  • proxy_client (Optional[BaseProxyClient], optional) – the proxy client to use, defaults to None

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'validate_by_alias': True, 'validate_by_name': True}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.proxy.langchain.ChatBedrockConverse(*args, name: str | None = None, cache: ~langchain_core.caches.BaseCache | bool | None = None, verbose: bool = <factory>, callbacks: list[~langchain_core.callbacks.base.BaseCallbackHandler] | ~langchain_core.callbacks.base.BaseCallbackManager | None = None, tags: list[str] | None = None, metadata: dict[str, ~typing.Any] | None = None, custom_get_token_ids: ~collections.abc.Callable[[str], list[int]] | None = None, rate_limiter: ~langchain_core.rate_limiters.BaseRateLimiter | None = None, disable_streaming: bool | ~typing.Literal['tool_calling'] = False, output_version: str | None = <factory>, profile: ~langchain_core.language_models.model_profile.ModelProfile | None = None, client: ~typing.Any = None, bedrock_client: ~typing.Any = None, model: str, base_model: str | None = None, system: ~typing.List[str | ~typing.Dict[str, ~typing.Any]] | None = None, max_tokens: int | None = None, stop: ~typing.List[str] | None = None, temperature: float | None = None, top_p: float | None = None, region_name: str | None = None, credentials_profile_name: str | None = None, aws_access_key_id: ~pydantic.types.SecretStr | None = <factory>, aws_secret_access_key: ~pydantic.types.SecretStr | None = <factory>, aws_session_token: ~pydantic.types.SecretStr | None = <factory>, api_key: ~pydantic.types.SecretStr | None = <factory>, provider: str = '', streaming: bool = False, base_url: str | None = None, default_headers: ~typing.Mapping[str, str] | None = None, config: ~typing.Any = None, timeout: int | None = None, max_retries: int | None = None, guardrails: ~typing.Dict[str, ~typing.Any] | None = None, additional_model_request_fields: ~typing.Dict[str, ~typing.Any] | None = None, reasoning_effort: ~typing.Literal['low', 'medium', 'high', 'xhigh', 'max'] | None = None, additional_model_response_field_paths: ~typing.List[str] | None = None, supports_tool_choice_values: ~typing.Sequence[~typing.Literal['auto', 'any', 'tool']] | None = None, performance_config: ~typing.Mapping[str, ~typing.Any] | None = None, service_tier: ~typing.Literal['priority', 'default', 'flex', 'reserved'] | None = None, output_config: ~typing.Dict[str, ~typing.Any] | None = None, request_metadata: ~typing.Dict[str, str] | None = None, guard_last_turn_only: bool = False, raw_blocks: ~typing.List[~typing.Dict[str, ~typing.Any]] | None = None, **kwargs)ΒΆ

Bases: AICoreBedrockBaseModel, ChatBedrockConverse

Drop-in replacement for LangChain ChatBedrockConverse.

__init__(*args, **kwargs)ΒΆ
Initializes the AICoreBedrockBaseModel with AICore specific parameters.

Extends the constructor of the base class with aicore specific parameters

Parameters:
  • model_id (str, optional) – the model identifier, defaults to β€œβ€

  • deployment_id (str, optional) – the deployment identifier, defaults to β€œβ€

  • model_name (str, optional) – the model name, defaults to β€œβ€

  • config_id (str, optional) – the configuration identifier, defaults to β€œβ€

  • config_name (str, optional) – the configuration name, defaults to β€œβ€

  • proxy_client (Optional[BaseProxyClient], optional) – the proxy client to use, defaults to None

extract_model_kwargs_parameters(kwargs)ΒΆ

Extracts specific parameters from model_kwargs and moves them to the top level of kwargs.

Parameters:

kwargs (Dict) – the input keyword arguments

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'validate_by_alias': True, 'validate_by_name': True}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.proxy.langchain.ChatGoogleGenerativeAI(model: str = '', proxy_model_name: str = '', model_id: str = '', deployment_id: str = '', config_id: str = '', config_name: str = '', proxy_client: ~gen_ai_hub.proxy.core.base.BaseProxyClient | None = None, *, name: str | None = None, cache: ~langchain_core.caches.BaseCache | bool | None = None, verbose: bool = <factory>, callbacks: list[~langchain_core.callbacks.base.BaseCallbackHandler] | ~langchain_core.callbacks.base.BaseCallbackManager | None = None, tags: list[str] | None = None, metadata: dict[str, ~typing.Any] | None = None, custom_get_token_ids: ~collections.abc.Callable[[str], list[int]] | None = None, rate_limiter: ~langchain_core.rate_limiters.BaseRateLimiter | None = None, disable_streaming: bool | ~typing.Literal['tool_calling'] = False, output_version: str | None = <factory>, profile: ~langchain_core.language_models.model_profile.ModelProfile | None = None, api_key: ~pydantic.types.SecretStr | None = <factory>, credentials: ~typing.Any = None, vertexai: bool | None = None, project: str | None = None, location: str | None = <factory>, client_options: str | dict | None = None, additional_headers: dict[str, str] | None = None, client_args: dict[str, ~typing.Any] | None = None, api_version: str | None = None, temperature: float | None = 0.7, frequency_penalty: float | None = None, presence_penalty: float | None = None, top_p: float | None = None, top_k: int | None = None, max_tokens: int | None = None, candidate_count: int = 1, retries: int = 6, request_timeout: float | None = None, response_modalities: list[~google.genai.types.Modality] | None = None, media_resolution: ~google.genai.types.MediaResolution | None = None, image_config: dict[str, ~typing.Any] | None = None, thinking_budget: int | None = None, include_thoughts: bool | None = None, safety_settings: dict[~google.genai.types.HarmCategory, ~google.genai.types.HarmBlockThreshold] | None = None, seed: int | None = None, labels: dict[str, str] | None = None, client: ~google.genai.client.Client | None = None, default_metadata_input: ~collections.abc.Sequence[tuple[str, str]] | None = None, model_kwargs: dict[str, ~typing.Any] = <factory>, streaming: bool | None = None, convert_system_message_to_human: bool = False, stop_sequences: list[str] | None = None, response_mime_type: str | None = None, response_schema: dict[str, ~typing.Any] | None = None, thinking_level: ~typing.Literal['minimal', 'low', 'medium', 'high'] | None = None, thinking_config: dict[str, ~typing.Any] | ~google.genai.types.ThinkingConfig | None = None, cached_content: str | None = None)ΒΆ

Bases: _BaseGoogleGenerativeAI, ChatGoogleGenerativeAI

Drop-in replacement for langchain_google_genai.ChatGoogleGenerativeAI.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'ignore', 'populate_by_name': True, 'protected_namespaces': (), 'validate_by_alias': True, 'validate_by_name': True}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

client: Client | NoneΒΆ
default_metadata: Sequence[tuple[str, str]] | NoneΒΆ
model_kwargs: dict[str, Any]ΒΆ

Holds any unexpected initialization parameters.

streaming: bool | NoneΒΆ

Whether to stream responses from the model.

convert_system_message_to_human: boolΒΆ

Whether to merge any leading SystemMessage into the following HumanMessage.

Gemini does not support system messages; any unsupported messages will raise an error.

stop: list[str] | NoneΒΆ

Stop sequences for the model.

response_mime_type: str | NoneΒΆ

Output response MIME type of the generated candidate text.

Supported MIME types:
  • β€˜text/plain’: (default) Text output.

  • β€˜application/json’: JSON response in the candidates.

  • β€˜text/x.enum’: Enum in plain text. (legacy; use JSON schema output instead)

!!! note

The model also needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.

(In other words, simply setting this param doesn’t force the model to comply; it only tells the model the kind of output expected. You still need to prompt it correctly.)

response_schema: dict[str, Any] | NoneΒΆ

Enforce a schema to the output.

The format of the dictionary should follow JSON Schema specification.

!!! note β€œSchema Transformation”

The Google GenAI SDK automatically transforms schemas for Gemini compatibility:

  • Inlines $defs definitions (enables Union types with anyOf)

  • Resolves $ref pointers for nested/recursive schemas

  • Preserves property ordering

  • Supports constraints like minimum/maximum, minItems/maxItems

!!! tip β€œUsing Union Types”

Union types in Pydantic models (e.g., field: Union[TypeA, TypeB]) are automatically converted to anyOf schemas and work correctly with the json_schema method.

Refer to the Gemini API [docs](https://ai.google.dev/gemini-api/docs/structured-output) for more details on supported JSON Schema features.

reasoning_effort: Literal['minimal', 'low', 'medium', 'high'] | NoneΒΆ

Indicates the thinking level.

Possible values (support varies by model):
  • β€˜minimal’: Lowest available reasoning depth.

  • β€˜low’: Minimizes latency and cost.

  • β€˜medium’: Balances latency/cost with reasoning depth.

  • β€˜high’: Maximizes reasoning depth.

Check the model profile’s reasoning_effort_levels and reasoning_effort_default fields for model-specific support. If those fields are unavailable, consult the upstream [Gemini API docs](https://ai.google.dev/gemini-api/docs/generate-content/thinking#thinking-levels-gemini-3).

!!! note β€œReplaces thinking_budget”

thinking_budget is deprecated for Gemini 3+ models. If both parameters are provided, this field takes precedence.

If left unspecified, the model’s default thinking level is used.

!!! note β€œthinking_level alias”

thinking_level – Gemini’s own native name for this setting – is also accepted as an alias for this field, at both construction and call time. If both thinking_level and reasoning_effort are set, thinking_level wins (Pydantic’s alias-resolution precedence). Use reasoning_effort or thinking_level interchangeably to read the value back.

thinking_config: dict[str, Any] | ThinkingConfig | NoneΒΆ

Raw Google GenAI thinking configuration.

Accepts the same fields as google.genai.types.ThinkingConfig, including thinking_level, thinking_budget, and include_thoughts.

!!! note β€œPrecedence”

If thinking_config is provided together with flat thinking arguments, the flat arguments take precedence for matching fields. After merging, thinking_level takes precedence over thinking_budget for Gemini 3+ models.

cached_content: str | NoneΒΆ

The name of the cached content used as context to serve the prediction.

!!! note

Only used in explicit caching, where users can have control over caching (e.g. what content to cache) and enjoy guaranteed cost savings. Format: cachedContents/{cachedContent}.

class gen_ai_hub.proxy.langchain.GoogleGenerativeAIEmbeddings(model: str = '', proxy_model_name: str = '', model_id: str = '', deployment_id: str = '', config_id: str = '', config_name: str = '', proxy_client: ~gen_ai_hub.proxy.core.base.BaseProxyClient | None = None, *, client: ~typing.Any = None, task_type: str | None = None, api_key: ~pydantic.types.SecretStr | None = <factory>, credentials: ~typing.Any = None, vertexai: bool | None = None, project: str | None = None, location: str | None = <factory>, base_url: str | None = None, additional_headers: dict[str, str] | None = None, client_args: dict[str, ~typing.Any] | None = None, api_version: str | None = None, request_options: dict | None = None, output_dimensionality: int | None = None, **kwargs)ΒΆ

Bases: _BaseGoogleGenerativeAI, GoogleGenerativeAIEmbeddings

Drop-in replacement for langchain_google_genai.GoogleGenerativeAIEmbeddings.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.proxy.langchain.OpenAI(*args, name: str | None = None, cache: ~langchain_core.caches.BaseCache | bool | None = None, verbose: bool = <factory>, callbacks: list[~langchain_core.callbacks.base.BaseCallbackHandler] | ~langchain_core.callbacks.base.BaseCallbackManager | None = None, tags: list[str] | None = None, metadata: dict[str, ~typing.Any] | None = None, custom_get_token_ids: ~collections.abc.Callable[[str], list[int]] | None = None, client: ~typing.Any = None, async_client: ~typing.Any = None, model_name: str | None = None, temperature: float = 0.7, max_tokens: int = 256, top_p: float = 1, frequency_penalty: float = 0, presence_penalty: float = 0, n: int = 1, best_of: int = 1, model_kwargs: dict[str, ~typing.Any] = <factory>, api_key: ~pydantic.types.SecretStr | None | ~collections.abc.Callable[[], str] = <factory>, base_url: str | None = <factory>, organization: str | None = <factory>, openai_proxy: str | None = <factory>, batch_size: int = 20, timeout: float | tuple[float, float] | ~typing.Any | None = None, logit_bias: dict[str, float] | None = None, max_retries: int = 2, seed: int | None = None, logprobs: int | None = None, streaming: bool = False, allowed_special: ~typing.Literal['all'] | set[str] = {}, disallowed_special: ~typing.Literal['all'] | ~collections.abc.Collection[str] = 'all', tiktoken_model_name: str | None = None, default_headers: ~collections.abc.Mapping[str, str] | None = None, default_query: ~collections.abc.Mapping[str, object] | None = None, http_client: ~typing.Any | None = None, http_async_client: ~typing.Any | None = None, extra_body: ~collections.abc.Mapping[str, ~typing.Any] | None = None, proxy_client: ~typing.Any | None = None, deployment_id: str | None = None, config_name: str | None = None, config_id: str | None = None, proxy_model_name: str | None = None, api_version: str | None = None, **kwargs)ΒΆ

Bases: ProxyOpenAI, OpenAI

OpenAI model using a proxy.

__init__(*args, **kwargs)ΒΆ

Initialize the OpenAI object.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'validate_by_alias': True, 'validate_by_name': True}ΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod validate_environment(values: Dict) DictΒΆ

Validates the environment.

Parameters:

values (Dict) – The input values

Returns:

The validated values

Return type:

Dict

model_name: str | NoneΒΆ

Model name to use.

openai_api_version: str | NoneΒΆ

SubmodulesΒΆ