BedrockRuntimeClient.invoke_model
rboto-bedrock-runtime==0.4.0 · Service index · Types
Model summary (excerpt): Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. You use model inference to generate text, images, and embeddings. For example code, see Invoke model code examples in the Amazon Bedrock User Guide . This operation requires permission for the bedrock:InvokeModel action on both the inference target and the...
Install and imports
from rboto import BedrockRuntimeClient
from rboto_bedrock_runtime.types import (
InvokeModelOutput,
PerformanceConfigLatency,
ServiceTierType,
Trace,
)
Signature
async def invoke_model(
*,
model_id: str,
body: bytes | None = None,
content_type: str | None = None,
accept: str | None = None,
trace: Trace | None = None,
guardrail_identifier: str | None = None,
guardrail_version: str | None = None,
performance_config_latency: PerformanceConfigLatency | None = None,
service_tier: ServiceTierType | None = None,
request_metadata: str | None = None,
project_identifier: str | None = None,
) -> InvokeModelOutput: ...
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) |
|---|---|---|
model_id |
Yes | The unique identifier of the model to invoke to run inference. The modelId to provide depends on the type of model or throughput that you use: If you use a base model, specify the model ID or its ARN. For a list of model IDs for base models, see Amazon Bedrock base model IDs (on-demand throughput) in the Amazon Bedrock User Guide. If you use an inference profile, specify the inference profile... |
body |
No | The prompt and inference parameters in the format specified in the contentType in the header. You must provide the body in JSON format. To see the format and content of the request and response bodies for different models, refer to Inference parameters . For more information, see Run inference in the Bedrock User Guide. |
content_type |
No | The MIME type of the input data in the request. You must specify application/json . |
accept |
No | The desired MIME type of the inference body in the response. The default value is application/json . |
trace |
No | Specifies whether to enable or disable the Bedrock trace. If enabled, you can see the full Bedrock trace. |
guardrail_identifier |
No | The unique identifier of the guardrail that you want to use. If you don't provide a value, no guardrail is applied to the invocation. An error will be thrown in the following situations. You don't provide a guardrail identifier but you specify the amazon-bedrock-guardrailConfig field in the request body. You enable the guardrail but the contentType isn't application/json . You provide a... |
guardrail_version |
No | The version number for the guardrail. The value can also be DRAFT . |
performance_config_latency |
No | Model performance settings for the request. |
service_tier |
No | Specifies the processing tier type used for serving the request. |
request_metadata |
No | Key-value pairs that you can use to filter invocation logs. |
project_identifier |
No | The ID or Amazon Resource Name (ARN) of the project to use for this invocation. The project must be active and belong to your AWS account and the AWS Region to which you send the request. Specify default or omit this field to use the default project for your account. For a non-default project, the inference target must resolve to a foundation model or system-defined inference profile.... |
Output
InvokeModelOutput.
Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.
| Field | Type | Presence | References |
|---|---|---|---|
body |
bytes |
Always present | — |
content_type |
str |
Always present | — |
performance_config_latency |
PerformanceConfigLatencyOutput | None |
Always present | PerformanceConfigLatencyOutput |
service_tier |
ServiceTierTypeOutput | None |
Always present | ServiceTierTypeOutput |
| 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.
Related types
InvokeModelOutput, PerformanceConfigLatency, ServiceTierType, Trace
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.
No output stream.
Errors
Import from rboto_bedrock_runtime.exceptions:
AccessDeniedError, InternalServerError, ModelError, ModelNotReadyError, ModelTimeoutError, ResourceNotFoundError, ServiceQuotaExceededError, ServiceUnavailableError, ThrottlingError, ValidationError.
Other service failures use the service base error; credential, transport and timeout failures use shared errors.