Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#3652·langchain4j

[FEATURE] Bedrock API timeout improvements

Author: mariuszpalaCreated Sep 7, 2025Updated Sep 24, 2026
LabelsenhancementP1P2AWS Bedrock

Is your feature request related to a problem? Please describe. The BedrockChatModel implementation does not respect the configured timeout. Underlying BedrockRuntimeClient requires more settings as instructed by AWS support. Otherwise for longer prompts the bedrock calls hangs or times out despite of any timeout setting.

Describe the solution you'd like AWS support team suggested adding the following settings:

		AttributeMap timeoutConfig = AttributeMap.builder()
				.put(SdkHttpConfigurationOption.READ_TIMEOUT, TIMEOUT)
				.build();

		SdkHttpClient httpClient = ApacheHttpClient.builder()
				.socketTimeout(TIMEOUT)
				.buildWithDefaults(timeoutConfig);


		BedrockRuntimeClient bedrockClient = BedrockRuntimeClient.builder()
				.httpClient(httpClient)
				.region(Region.of("us-east-1"))
				.overrideConfiguration(config -> config
						.apiCallTimeout(TIMEOUT)
						.apiCallAttemptTimeout(TIMEOUT))
				.build();

		BedrockChatModel claude = BedrockChatModel.builder()
				.modelId("us.anthropic.claude-sonnet-4-20250514-v1:0")
				.region(Region.of("us-east-1"))
				.timeout(TIMEOUT)
				.client(bedrockClient)
				.defaultRequestParameters(ChatRequestParameters.builder()
						.temperature(0.0).maxOutputTokens(65536)
						.build())
				.build();

Additionally, by default the maxOutputTokens is for some reason set to 8192 and we had to explicitely increase it to 65536 which is the limit for anthropic claude limit. I'm not sure though if this is a limit on langchain or bedrock client API.

Additional context We've done many tests using langchain4j and Amazon Bedrock and due to many timeouts and failures we've been instructed by AWS team to use the settings about that solved all the issues. Thus we'd suggest to include them in the default langchain4j implementation.

Source: langchain4j/langchain4j

View original on GitHubView discussion on GitHub