Class AsyncPromptOptimizer (1.121.0)

AsyncPromptOptimizer(api_client_: google.genai._api_client.BaseApiClient)

Prompt Optimizer

Methods

optimize

optimize(
 method: str,
 config: typing.Union[
 vertexai._genai.types.PromptOptimizerVAPOConfig,
 vertexai._genai.types.PromptOptimizerVAPOConfigDict,
 ],
) -> vertexai._genai.types.CustomJob

Call async Vertex AI Prompt Optimizer (VAPO).

Note: The wait_for_completion parameter in the config will be ignored when using the AsyncClient, as it is not supported.

Example usage: client = vertexai.Client(project=PROJECT_NAME, location='us-central1') vapo_config = vertexai.types.PromptOptimizerVAPOConfig( config_path='gs://you-bucket-name/your-config.json', service_account=service_account, ) job = await client.aio.prompt_optimizer.optimize( method='vapo', config=vapo_config)

optimize_prompt

optimize_prompt(
 *, prompt: str, config: typing.Optional[vertexai._genai.types.OptimizeConfig] = None
) -> vertexai._genai.types.OptimizeResponse

Makes an async request to _optimize_prompt and returns an optimized prompt.

Example usage: client = vertexai.Client(project=PROJECT_NAME, location='us-central1') prompt = "Generate system instructions for analyzing medical articles" response = await client.aio.prompt_optimizer.optimize_prompt(prompt=prompt)

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月30日 UTC.