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:
- 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,OpenAIEmbeddingsOpenAI 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,ChatOpenAIChatOpenAI 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,BedrockEmbeddingsDrop-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:
BaseModelAICoreBedrockBaseModel 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,ChatBedrockDrop-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,ChatBedrockConverseDrop-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,ChatGoogleGenerativeAIDrop-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].
- 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,GoogleGenerativeAIEmbeddingsDrop-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,OpenAIOpenAI 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ΒΆ
- gen_ai_hub.proxy.langchain.amazon module
AICoreBedrockBaseModelChatBedrockChatBedrock.model_configChatBedrock.__init__()ChatBedrock.system_prompt_with_toolsChatBedrock.beta_use_converse_apiChatBedrock.stop_sequencesChatBedrock.rate_limiterChatBedrock.disable_streamingChatBedrock.output_versionChatBedrock.profileChatBedrock.clientChatBedrock.bedrock_clientChatBedrock.region_nameChatBedrock.credentials_profile_nameChatBedrock.aws_access_key_idChatBedrock.aws_secret_access_keyChatBedrock.aws_session_tokenChatBedrock.bedrock_api_keyChatBedrock.configChatBedrock.timeoutChatBedrock.max_retriesChatBedrock.providerChatBedrock.model_idChatBedrock.base_model_idChatBedrock.model_kwargsChatBedrock.endpoint_urlChatBedrock.streamingChatBedrock.provider_stop_sequence_key_name_mapChatBedrock.provider_stop_reason_key_mapChatBedrock.guardrailsChatBedrock.temperatureChatBedrock.max_tokensChatBedrock.service_tierChatBedrock.cacheChatBedrock.verboseChatBedrock.callbacksChatBedrock.tagsChatBedrock.metadataChatBedrock.custom_get_token_idsChatBedrock.name
ChatBedrockConverseChatBedrockConverse.model_configChatBedrockConverse.__init__()ChatBedrockConverse.extract_model_kwargs_parameters()ChatBedrockConverse.clientChatBedrockConverse.bedrock_clientChatBedrockConverse.model_idChatBedrockConverse.base_model_idChatBedrockConverse.systemChatBedrockConverse.max_tokensChatBedrockConverse.stop_sequencesChatBedrockConverse.temperatureChatBedrockConverse.top_pChatBedrockConverse.region_nameChatBedrockConverse.credentials_profile_nameChatBedrockConverse.aws_access_key_idChatBedrockConverse.aws_secret_access_keyChatBedrockConverse.aws_session_tokenChatBedrockConverse.bedrock_api_keyChatBedrockConverse.providerChatBedrockConverse.streamingChatBedrockConverse.endpoint_urlChatBedrockConverse.default_headersChatBedrockConverse.configChatBedrockConverse.timeoutChatBedrockConverse.max_retriesChatBedrockConverse.guardrail_configChatBedrockConverse.additional_model_request_fieldsChatBedrockConverse.reasoning_effortChatBedrockConverse.additional_model_response_field_pathsChatBedrockConverse.supports_tool_choice_valuesChatBedrockConverse.performance_configChatBedrockConverse.service_tierChatBedrockConverse.output_configChatBedrockConverse.request_metadataChatBedrockConverse.guard_last_turn_onlyChatBedrockConverse.raw_blocksChatBedrockConverse.rate_limiterChatBedrockConverse.disable_streamingChatBedrockConverse.output_versionChatBedrockConverse.profileChatBedrockConverse.cacheChatBedrockConverse.verboseChatBedrockConverse.callbacksChatBedrockConverse.tagsChatBedrockConverse.metadataChatBedrockConverse.custom_get_token_idsChatBedrockConverse.name
BedrockEmbeddingsinit_chat_model()init_chat_converse_model()init_embedding_model()
- gen_ai_hub.proxy.langchain.base module
- gen_ai_hub.proxy.langchain.google_genai module
ChatGoogleGenerativeAIChatGoogleGenerativeAI.model_configChatGoogleGenerativeAI.clientChatGoogleGenerativeAI.default_metadataChatGoogleGenerativeAI.model_kwargsChatGoogleGenerativeAI.streamingChatGoogleGenerativeAI.convert_system_message_to_humanChatGoogleGenerativeAI.stopChatGoogleGenerativeAI.response_mime_typeChatGoogleGenerativeAI.response_schemaChatGoogleGenerativeAI.reasoning_effortChatGoogleGenerativeAI.thinking_configChatGoogleGenerativeAI.cached_contentChatGoogleGenerativeAI.google_api_keyChatGoogleGenerativeAI.credentialsChatGoogleGenerativeAI.vertexaiChatGoogleGenerativeAI.projectChatGoogleGenerativeAI.locationChatGoogleGenerativeAI.base_urlChatGoogleGenerativeAI.additional_headersChatGoogleGenerativeAI.client_argsChatGoogleGenerativeAI.api_versionChatGoogleGenerativeAI.modelChatGoogleGenerativeAI.temperatureChatGoogleGenerativeAI.frequency_penaltyChatGoogleGenerativeAI.presence_penaltyChatGoogleGenerativeAI.top_pChatGoogleGenerativeAI.top_kChatGoogleGenerativeAI.max_output_tokensChatGoogleGenerativeAI.nChatGoogleGenerativeAI.max_retriesChatGoogleGenerativeAI.timeoutChatGoogleGenerativeAI.response_modalitiesChatGoogleGenerativeAI.media_resolutionChatGoogleGenerativeAI.image_configChatGoogleGenerativeAI.thinking_budgetChatGoogleGenerativeAI.include_thoughtsChatGoogleGenerativeAI.safety_settingsChatGoogleGenerativeAI.seedChatGoogleGenerativeAI.labelsChatGoogleGenerativeAI.rate_limiterChatGoogleGenerativeAI.disable_streamingChatGoogleGenerativeAI.output_versionChatGoogleGenerativeAI.profileChatGoogleGenerativeAI.cacheChatGoogleGenerativeAI.verboseChatGoogleGenerativeAI.callbacksChatGoogleGenerativeAI.tagsChatGoogleGenerativeAI.metadataChatGoogleGenerativeAI.custom_get_token_idsChatGoogleGenerativeAI.name
GoogleGenerativeAIEmbeddingsGoogleGenerativeAIEmbeddings.model_configGoogleGenerativeAIEmbeddings.clientGoogleGenerativeAIEmbeddings.modelGoogleGenerativeAIEmbeddings.task_typeGoogleGenerativeAIEmbeddings.google_api_keyGoogleGenerativeAIEmbeddings.credentialsGoogleGenerativeAIEmbeddings.vertexaiGoogleGenerativeAIEmbeddings.projectGoogleGenerativeAIEmbeddings.locationGoogleGenerativeAIEmbeddings.base_urlGoogleGenerativeAIEmbeddings.additional_headersGoogleGenerativeAIEmbeddings.client_argsGoogleGenerativeAIEmbeddings.api_versionGoogleGenerativeAIEmbeddings.request_optionsGoogleGenerativeAIEmbeddings.output_dimensionality
init_chat_model()init_embedding_model()
- gen_ai_hub.proxy.langchain.init_models module
- gen_ai_hub.proxy.langchain.openai module
get_client_params()ProxyOpenAIChatOpenAIChatOpenAI.model_nameChatOpenAI.openai_api_versionChatOpenAI.model_configChatOpenAI.__init__()ChatOpenAI.validate_environment()ChatOpenAI.deployment_idChatOpenAI.config_nameChatOpenAI.config_idChatOpenAI.proxy_model_nameChatOpenAI.max_tokensChatOpenAI.clientChatOpenAI.async_clientChatOpenAI.root_clientChatOpenAI.root_async_clientChatOpenAI.temperatureChatOpenAI.model_kwargsChatOpenAI.openai_api_keyChatOpenAI.openai_api_baseChatOpenAI.openai_organizationChatOpenAI.openai_proxyChatOpenAI.request_timeoutChatOpenAI.stream_usageChatOpenAI.max_retriesChatOpenAI.presence_penaltyChatOpenAI.frequency_penaltyChatOpenAI.seedChatOpenAI.logprobsChatOpenAI.top_logprobsChatOpenAI.logit_biasChatOpenAI.streamingChatOpenAI.nChatOpenAI.top_pChatOpenAI.reasoning_effortChatOpenAI.reasoningChatOpenAI.verbosityChatOpenAI.tiktoken_model_nameChatOpenAI.default_headersChatOpenAI.default_queryChatOpenAI.http_clientChatOpenAI.http_async_clientChatOpenAI.http_socket_optionsChatOpenAI.stream_chunk_timeoutChatOpenAI.stopChatOpenAI.extra_bodyChatOpenAI.include_response_headersChatOpenAI.disabled_paramsChatOpenAI.context_managementChatOpenAI.includeChatOpenAI.prompt_cache_optionsChatOpenAI.service_tierChatOpenAI.storeChatOpenAI.truncationChatOpenAI.use_previous_response_idChatOpenAI.use_responses_apiChatOpenAI.output_versionChatOpenAI.rate_limiterChatOpenAI.disable_streamingChatOpenAI.profileChatOpenAI.cacheChatOpenAI.verboseChatOpenAI.callbacksChatOpenAI.tagsChatOpenAI.metadataChatOpenAI.custom_get_token_idsChatOpenAI.name
OpenAIOpenAI.model_nameOpenAI.openai_api_versionOpenAI.model_configOpenAI.__init__()OpenAI.validate_environment()OpenAI.deployment_idOpenAI.config_nameOpenAI.config_idOpenAI.proxy_model_nameOpenAI.clientOpenAI.async_clientOpenAI.temperatureOpenAI.max_tokensOpenAI.top_pOpenAI.frequency_penaltyOpenAI.presence_penaltyOpenAI.nOpenAI.best_ofOpenAI.model_kwargsOpenAI.openai_api_keyOpenAI.openai_api_baseOpenAI.openai_organizationOpenAI.openai_proxyOpenAI.batch_sizeOpenAI.request_timeoutOpenAI.logit_biasOpenAI.max_retriesOpenAI.seedOpenAI.logprobsOpenAI.streamingOpenAI.allowed_specialOpenAI.disallowed_specialOpenAI.tiktoken_model_nameOpenAI.default_headersOpenAI.default_queryOpenAI.http_clientOpenAI.http_async_clientOpenAI.extra_bodyOpenAI.cacheOpenAI.verboseOpenAI.callbacksOpenAI.tagsOpenAI.metadataOpenAI.custom_get_token_idsOpenAI.name
OpenAIEmbeddingsOpenAIEmbeddings.modelOpenAIEmbeddings.tiktoken_model_nameOpenAIEmbeddings.chunk_sizeOpenAIEmbeddings.openai_api_versionOpenAIEmbeddings.input_typeOpenAIEmbeddings.model_configOpenAIEmbeddings.__init__()OpenAIEmbeddings.validate_environment()OpenAIEmbeddings.deployment_idOpenAIEmbeddings.config_nameOpenAIEmbeddings.config_idOpenAIEmbeddings.proxy_model_nameOpenAIEmbeddings.clientOpenAIEmbeddings.async_clientOpenAIEmbeddings.dimensionsOpenAIEmbeddings.deploymentOpenAIEmbeddings.openai_api_baseOpenAIEmbeddings.openai_api_typeOpenAIEmbeddings.openai_proxyOpenAIEmbeddings.embedding_ctx_lengthOpenAIEmbeddings.openai_api_keyOpenAIEmbeddings.openai_organizationOpenAIEmbeddings.allowed_specialOpenAIEmbeddings.disallowed_specialOpenAIEmbeddings.max_retriesOpenAIEmbeddings.request_timeoutOpenAIEmbeddings.headersOpenAIEmbeddings.tiktoken_enabledOpenAIEmbeddings.show_progress_barOpenAIEmbeddings.model_kwargsOpenAIEmbeddings.skip_emptyOpenAIEmbeddings.default_headersOpenAIEmbeddings.default_queryOpenAIEmbeddings.retry_min_secondsOpenAIEmbeddings.retry_max_secondsOpenAIEmbeddings.http_clientOpenAIEmbeddings.http_async_clientOpenAIEmbeddings.check_embedding_ctx_length
init_chat_model()init_embedding_model()