This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 4a63f7a9ed04 CAMEL-22917: Set default for baseUrl option on 
camel-openai
4a63f7a9ed04 is described below

commit 4a63f7a9ed04ca10407bace046e1a5f67bc4af2d
Author: James Netherton <[email protected]>
AuthorDate: Thu Jan 29 10:32:42 2026 +0000

    CAMEL-22917: Set default for baseUrl option on camel-openai
---
 .../apache/camel/catalog/components/openai.json    |  4 ++--
 .../org/apache/camel/component/openai/openai.json  |  4 ++--
 .../src/main/docs/openai-component.adoc            |  2 +-
 .../camel/component/openai/OpenAIComponent.java    |  5 +++--
 .../component/openai/OpenAIConfiguration.java      |  6 ++++--
 .../openai/integration/OpenAIChatCompletionIT.java |  2 +-
 .../openai/integration/OpenAITestSupport.java      | 23 ++++++++++++++++++++++
 .../dsl/OpenaiComponentBuilderFactory.java         |  2 ++
 .../endpoint/dsl/OpenAIEndpointBuilderFactory.java |  1 +
 9 files changed, 39 insertions(+), 10 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
index 987bbb3c5848..b67942ed8b1e 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
@@ -25,7 +25,7 @@
   },
   "componentProperties": {
     "apiKey": { "index": 0, "kind": "property", "displayName": "Api Key", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "Default API key for all endpoints" },
-    "baseUrl": { "index": 1, "kind": "property", "displayName": "Base Url", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "Default base URL for all endpoints" },
+    "baseUrl": { "index": 1, "kind": "property", "displayName": "Base Url", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": "https:\/\/api.openai.com\/v1", "description": 
"Default base URL for all endpoints" },
     "lazyStartProducer": { "index": 2, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
     "model": { "index": 3, "kind": "property", "displayName": "Model", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "Default model for all endpoints" },
     "autowiredEnabled": { "index": 4, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
@@ -53,7 +53,7 @@
     "operation": { "index": 0, "kind": "path", "displayName": "Operation", 
"group": "producer", "label": "", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The operation to perform 
(currently only chat-completion is supported)" },
     "additionalBodyProperty": { "index": 1, "kind": "parameter", 
"displayName": "Additional Body Property", "group": "producer", "label": "", 
"required": false, "type": "object", "javaType": 
"java.util.Map<java.lang.String, java.lang.Object>", "prefix": 
"additionalBodyProperty.", "multiValue": true, "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", 
"configurationField": "configur [...]
     "apiKey": { "index": 2, "kind": "parameter", "displayName": "Api Key", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": true, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "OpenAI API key. Can also be set via 
OPENAI_API_KEY environment variable." },
-    "baseUrl": { "index": 3, "kind": "parameter", "displayName": "Base Url", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "Base URL for OpenAI API. Defaults to OpenAI's 
official endpoint. Can be used for local or third-p [...]
+    "baseUrl": { "index": 3, "kind": "parameter", "displayName": "Base Url", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "defaultValue": 
"https:\/\/api.openai.com\/v1", "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "Base URL for OpenAI API. Defaults to OpenAI's 
off [...]
     "conversationHistoryProperty": { "index": 4, "kind": "parameter", 
"displayName": "Conversation History Property", "group": "producer", "label": 
"", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "defaultValue": "CamelOpenAIConversationHistory", "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "Exchan [...]
     "conversationMemory": { "index": 5, "kind": "parameter", "displayName": 
"Conversation Memory", "group": "producer", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 
false, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "Enable conversation memory per Exchange" },
     "developerMessage": { "index": 6, "kind": "parameter", "displayName": 
"Developer Message", "group": "producer", "label": "", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", 
"configurationField": "configuration", "description": "Developer message to 
prepend before user messages" },
diff --git 
a/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
 
b/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
index 987bbb3c5848..b67942ed8b1e 100644
--- 
a/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
+++ 
b/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
@@ -25,7 +25,7 @@
   },
   "componentProperties": {
     "apiKey": { "index": 0, "kind": "property", "displayName": "Api Key", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "Default API key for all endpoints" },
-    "baseUrl": { "index": 1, "kind": "property", "displayName": "Base Url", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "Default base URL for all endpoints" },
+    "baseUrl": { "index": 1, "kind": "property", "displayName": "Base Url", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": "https:\/\/api.openai.com\/v1", "description": 
"Default base URL for all endpoints" },
     "lazyStartProducer": { "index": 2, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
     "model": { "index": 3, "kind": "property", "displayName": "Model", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "Default model for all endpoints" },
     "autowiredEnabled": { "index": 4, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
@@ -53,7 +53,7 @@
     "operation": { "index": 0, "kind": "path", "displayName": "Operation", 
"group": "producer", "label": "", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The operation to perform 
(currently only chat-completion is supported)" },
     "additionalBodyProperty": { "index": 1, "kind": "parameter", 
"displayName": "Additional Body Property", "group": "producer", "label": "", 
"required": false, "type": "object", "javaType": 
"java.util.Map<java.lang.String, java.lang.Object>", "prefix": 
"additionalBodyProperty.", "multiValue": true, "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", 
"configurationField": "configur [...]
     "apiKey": { "index": 2, "kind": "parameter", "displayName": "Api Key", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": true, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "OpenAI API key. Can also be set via 
OPENAI_API_KEY environment variable." },
-    "baseUrl": { "index": 3, "kind": "parameter", "displayName": "Base Url", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "Base URL for OpenAI API. Defaults to OpenAI's 
official endpoint. Can be used for local or third-p [...]
+    "baseUrl": { "index": 3, "kind": "parameter", "displayName": "Base Url", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "defaultValue": 
"https:\/\/api.openai.com\/v1", "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "Base URL for OpenAI API. Defaults to OpenAI's 
off [...]
     "conversationHistoryProperty": { "index": 4, "kind": "parameter", 
"displayName": "Conversation History Property", "group": "producer", "label": 
"", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "defaultValue": "CamelOpenAIConversationHistory", "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "Exchan [...]
     "conversationMemory": { "index": 5, "kind": "parameter", "displayName": 
"Conversation Memory", "group": "producer", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 
false, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "Enable conversation memory per Exchange" },
     "developerMessage": { "index": 6, "kind": "parameter", "displayName": 
"Developer Message", "group": "producer", "label": "", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", 
"configurationField": "configuration", "description": "Developer message to 
prepend before user messages" },
diff --git 
a/components/camel-ai/camel-openai/src/main/docs/openai-component.adoc 
b/components/camel-ai/camel-openai/src/main/docs/openai-component.adoc
index 2a5bd9083871..06f7c42d1d9e 100644
--- a/components/camel-ai/camel-openai/src/main/docs/openai-component.adoc
+++ b/components/camel-ai/camel-openai/src/main/docs/openai-component.adoc
@@ -48,7 +48,7 @@ include::partial$component-endpoint-headers.adoc[]
 
 === Authentication
 
-Set `baseUrl` to your provider's endpoint 
(default:`https://api.openai.com/v1`).
+Set `baseUrl` to your providers endpoint (default: 
`https://api.openai.com/v1`).
 
 API key resolution order:
 
diff --git 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIComponent.java
 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIComponent.java
index c8980308302a..2d2d754e474c 100644
--- 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIComponent.java
+++ 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIComponent.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.openai;
 
 import java.util.Map;
 
+import com.openai.core.ClientOptions;
 import org.apache.camel.Endpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
@@ -32,8 +33,8 @@ public class OpenAIComponent extends DefaultComponent {
     @Metadata(description = "Default API key for all endpoints")
     private String apiKey;
 
-    @Metadata(description = "Default base URL for all endpoints")
-    private String baseUrl;
+    @Metadata(description = "Default base URL for all endpoints", defaultValue 
= ClientOptions.PRODUCTION_URL)
+    private String baseUrl = ClientOptions.PRODUCTION_URL;
 
     @Metadata(description = "Default model for all endpoints")
     private String model;
diff --git 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIConfiguration.java
 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIConfiguration.java
index 6e076149a944..3189e371797e 100644
--- 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIConfiguration.java
+++ 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.openai;
 
 import java.util.Map;
 
+import com.openai.core.ClientOptions;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -33,8 +34,9 @@ public class OpenAIConfiguration implements Cloneable {
     private String apiKey;
 
     @UriParam
-    @Metadata(description = "Base URL for OpenAI API. Defaults to OpenAI's 
official endpoint. Can be used for local or third-party providers.")
-    private String baseUrl;
+    @Metadata(description = "Base URL for OpenAI API. Defaults to OpenAI's 
official endpoint. Can be used for local or third-party providers.",
+              defaultValue = ClientOptions.PRODUCTION_URL)
+    private String baseUrl = ClientOptions.PRODUCTION_URL;
 
     @UriParam
     @Metadata(description = "The model to use for chat completion")
diff --git 
a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAIChatCompletionIT.java
 
b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAIChatCompletionIT.java
index 194e66ca7354..bc34bc6e4511 100644
--- 
a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAIChatCompletionIT.java
+++ 
b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAIChatCompletionIT.java
@@ -35,7 +35,7 @@ public class OpenAIChatCompletionIT extends OpenAITestSupport 
{
             public void configure() {
                 // Route for simple message test
                 from("direct:send-simple-message")
-                        
.toF("openai:chat-completion?apiKey=%s&baseUrl=%s&model=%s", apiKey, baseUrl, 
model)
+                        .toF("openai:chat-completion")
                         .to("mock:response");
             }
         };
diff --git 
a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAITestSupport.java
 
b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAITestSupport.java
index 0f4da0e4d0ac..72f92d33ade7 100644
--- 
a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAITestSupport.java
+++ 
b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/integration/OpenAITestSupport.java
@@ -16,9 +16,12 @@
  */
 package org.apache.camel.component.openai.integration;
 
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.openai.OpenAIComponent;
 import org.apache.camel.test.infra.ollama.services.OllamaService;
 import org.apache.camel.test.infra.ollama.services.OllamaServiceFactory;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
 
 public class OpenAITestSupport extends CamelTestSupport {
 
@@ -47,6 +50,26 @@ public class OpenAITestSupport extends CamelTestSupport {
         }
     }
 
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        OpenAIComponent component = new OpenAIComponent();
+        if (ObjectHelper.isNotEmpty(apiKey)) {
+            component.setApiKey(apiKey);
+        }
+
+        if (ObjectHelper.isNotEmpty(model)) {
+            component.setModel(model);
+        }
+
+        if (ObjectHelper.isNotEmpty(baseUrl)) {
+            component.setBaseUrl(baseUrl);
+        }
+
+        camelContext.addComponent("openai", component);
+        return camelContext;
+    }
+
     protected static boolean hasEnvironmentConfiguration() {
         String apiKey = System.getenv("OPENAI_API_KEY");
         return apiKey != null && !apiKey.trim().isEmpty();
diff --git 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/OpenaiComponentBuilderFactory.java
 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/OpenaiComponentBuilderFactory.java
index bb3be317eab8..7bd75c859e96 100644
--- 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/OpenaiComponentBuilderFactory.java
+++ 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/OpenaiComponentBuilderFactory.java
@@ -65,11 +65,13 @@ public interface OpenaiComponentBuilderFactory {
             return this;
         }
     
+        
         /**
          * Default base URL for all endpoints.
          * 
          * The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
          * 
+         * Default: https://api.openai.com/v1
          * Group: producer
          * 
          * @param baseUrl the value to set
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
index b68204ed35c8..79e7efb18ddf 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
@@ -106,6 +106,7 @@ public interface OpenAIEndpointBuilderFactory {
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
+         * Default: https://api.openai.com/v1
          * Group: producer
          * 
          * @param baseUrl the value to set

Reply via email to