Skip to content

BedrockAgentRuntimeClient.optimize_prompt

rboto-bedrock-agent-runtime==0.4.0 · Service index · Types

Model summary (excerpt): Optimizes a prompt for the task that you specify. For more information, see Optimize a prompt in the Amazon Bedrock User Guide .

Install and imports

python -m pip install "rboto[bedrock-agent-runtime]==0.4.0"
from rboto import BedrockAgentRuntimeClient
from rboto_bedrock_agent_runtime.types import (
    InputPrompt,
    OptimizePromptOutput,
)

Signature

async def optimize_prompt(
    *,
    input: InputPrompt,
    target_model_id: str,
) -> OptimizePromptOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
input Yes Contains the prompt to optimize.
target_model_id Yes The unique identifier of the model that you want to optimize the prompt for.

Output

OptimizePromptOutput.

Typed response mapping, accessed as response["field"].

Field Type Presence References
optimized_prompt AsyncIterator[OptimizedPromptStream] Always present OptimizedPromptStream

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

InputPrompt, OptimizePromptOutput

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

Output streams: OptimizePromptOutput.

Consume with async for. Do not reuse a consumed stream.

Errors

Import from rboto_bedrock_agent_runtime.exceptions:

AccessDeniedError, BadGatewayError, DependencyFailedError, InternalServerError, ThrottlingError, ValidationError.

Stream decoding may also raise the linked modeled event errors.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model