Skip to content

CAMEL-23968: Expose OpenAI SDK client timeout, retries and headers#24900

Merged
davsclaus merged 4 commits into
apache:mainfrom
atiaomar1978-hub:CAMEL-23968-openai-client-options
Jul 19, 2026
Merged

CAMEL-23968: Expose OpenAI SDK client timeout, retries and headers#24900
davsclaus merged 4 commits into
apache:mainfrom
atiaomar1978-hub:CAMEL-23968-openai-client-options

Conversation

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor

CAMEL-23968.

Issue

CAMEL-23968 — expose OpenAI SDK client requestTimeout, maxRetries, and additionalHeader.* in camel-openai.

Changes

Option Wiring
requestTimeout (ms, default 0 = SDK 10 min) builder.timeout(Duration.ofMillis(...))
maxRetries (default 2) builder.maxRetries(...)
additionalHeader.<name> (multi-value, security=secret) builder.putHeader(name, value)

Applied once in createClient() via new configureHttpClient() method.

Tests — OpenAIClientConfigurationTest (8 tests)

  • Defaults and URI parsing
  • Request timeout applied / SDK default when 0
  • Max retries (0 and 5)
  • Additional headers on ClientOptions
  • Null header values skipped
  • HTTP headers verified on wire via mock (OpenAI-Organization, api-key)

Full module: 102/102 passed (mvn test on camel-openai)

Git

  • Branch: CAMEL-23968-openai-client-options
  • Commit: 72b2285c658

Add requestTimeout, maxRetries and additionalHeader options to camel-openai
and wire them in createClient. Includes configuration and mock integration tests.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: CAMEL-23968 — Expose OpenAI SDK client timeout, retries and headers

Well-implemented feature with thorough tests. Clean, focused changes.

Implementation

The three new options are cleanly wired:

  • requestTimeout (long, default 0 → SDK 10-min default): Good semantics — 0 means "don't override", positive value sets Duration.ofMillis(...).
  • maxRetries (int, default 2): Matches the SDK default, so explicitly setting 2 is a no-op — good consistency.
  • additionalHeader (Map, prefix additionalHeader., security = "secret"): Correctly marked as secret since headers can contain API keys. Multi-value prefix is properly registered.

The configureHttpClient() extraction keeps createClient() readable.

Tests

Good coverage across 8 tests:

  • Defaults validation
  • URI parsing with all three options
  • Timeout applied vs SDK default (0)
  • Max retries with 0 and 5
  • Additional headers wired to ClientOptions
  • Null header value skipped
  • End-to-end: additionalHeadersAreSentOnChatCompletionRequest uses OpenAIMock to verify headers arrive on the wire — this is the strongest test in the set

Minor observations (non-blocking)

  • The clientOptions() test helper uses reflection (setAccessible(true)) to read the SDK's private clientOptions field. This is pragmatic but fragile if the SDK renames the field — consider a comment noting this coupling for future maintainers.
  • No negative-value validation on requestTimeout — if someone sets -1, the timeout just won't be applied (since > 0 check). The SDK builder would likely handle it, but a doc note or validation could help. Very minor.

LGTM ✅


🤖 This review was generated by an AI agent (Claude Code) on behalf of gnodet. Opinions and technical assessments are AI-generated and should be validated by human reviewers.

…eout

Note that clientOptions() tests depend on SDK internal field naming, and
clarify that negative requestTimeout values fall back to the SDK default.
@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

CAMEL-23968 — OpenAI SDK client options

Two commits on CAMEL-23968-openai-client-options:

Main change (72b2285)

Exposes three OpenAI Java SDK client knobs in camel-openai:

Option Default Behavior
requestTimeout 0 HTTP timeout in ms; > 0builder.timeout(...); otherwise SDK default (~10 min)
maxRetries 2 Passed to builder.maxRetries(...)
additionalHeader.<name> Multi-value headers (e.g. Azure org/key); builder.putHeader(...)

Wiring: OpenAIEndpoint.configureHttpClient() runs from createClient().

Files: OpenAIConfiguration.java, OpenAIEndpoint.java, new OpenAIClientConfigurationTest.java (8 tests), regenerated openai.json + endpoint configurer/uri factory.

Follow-up (789f84b)

Review feedback:

  • Javadoc on test helper clientOptions() — notes reflection on SDK private field clientOptions (fragile if SDK renames it)
  • requestTimeout docs — negative values treated like 0 (SDK default)

Verification

  • 102/102 tests passed in camel-openai

@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

@davsclaus could you please trigger the GitHub Action?
I’ve resolved the merge conflict, but we need to merge the tickets one by one — especially the one that modifies openai.json.

Commit generated catalog, component schema, and endpoint DSL artifacts
for additionalHeader, maxRetries, and requestTimeout so CI clean-tree
check passes.

Co-Authored-By: Cursor <cursoragent@cursor.com>

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review after 4th commit (39df501): Generated metadata regeneration for client options — standard regeneration of catalog JSON and Endpoint DSL builder. My earlier approval stands.

Claude Code on behalf of gnodet — AI-generated review

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-ai/camel-openai
  • dsl/camel-endpointdsl

🔬 Scalpel shadow comparison — Scalpel: 11 tested, 27 compile-only — current: 9 all tested

Maveniverse Scalpel detected 38 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 11 modules (3 direct + 8 downstream), skip tests for 27 (generated code, meta-modules)

Modules Scalpel would test (11)
  • camel-catalog
  • camel-endpointdsl
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-openai
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • components/camel-ai/camel-openai: 6 test(s) disabled on GitHub Actions
All tested modules (38 modules)
  • Camel :: AI :: OpenAI
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.22.0 milestone Jul 19, 2026
@davsclaus davsclaus added the enhancement New feature or request label Jul 19, 2026
@davsclaus
davsclaus merged commit 4038a36 into apache:main Jul 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants