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

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


The following commit(s) were added to refs/heads/main by this push:
     new 6c50b4f57 chore: openai-chat-action works without an API key, has a 
jsonSchemaStrict option, and is Preview (CAMEL-27402, CAMEL-27403) (#3370)
6c50b4f57 is described below

commit 6c50b4f5725030ce45a75bcb14464df94f218e00
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 23 12:56:55 2026 +0100

    chore: openai-chat-action works without an API key, has a jsonSchemaStrict 
option, and is Preview (CAMEL-27402, CAMEL-27403) (#3370)
    
    * chore: openai-chat-action works without an API key, and a 
jsonSchemaStrict option (CAMEL-27402, CAMEL-27403)
    
    - apiKey: with no key and no OPENAI_API_KEY, requests go without a key, for 
a
      local server such as Ollama (no dummy value any more).
    - jsonSchemaStrict (default false): the model follows jsonSchema exactly, 
with
      OpenAI's rules for a strict schema in its description.
    - The JSON test sends no API key, asks strictly for its first message, and 
its
      timer now has includeMetadata, so the choice between the inline schema 
and the
      schema file really takes the inline one for the first message.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    * chore: openai-chat-action is Preview, as the other new Kamelets of 4.24
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    ---------
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 kamelets/openai-chat-action.kamelet.yaml                   | 10 ++++++++--
 .../src/main/resources/META-INF/kamelets-index.json        |  2 +-
 .../resources/kamelets/openai-chat-action.kamelet.yaml     | 10 ++++++++--
 .../resources/openai/openai-chat-action-json-route.yaml    |  9 +++++----
 .../openai/openai-chat-action-json.citrus.it.yaml          | 14 +++++---------
 5 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/kamelets/openai-chat-action.kamelet.yaml 
b/kamelets/openai-chat-action.kamelet.yaml
index 26fa7fc77..f36fb1e01 100644
--- a/kamelets/openai-chat-action.kamelet.yaml
+++ b/kamelets/openai-chat-action.kamelet.yaml
@@ -19,7 +19,7 @@ kind: Kamelet
 metadata:
   name: openai-chat-action
   annotations:
-    camel.apache.org/kamelet.support.level: "Stable"
+    camel.apache.org/kamelet.support.level: "Preview"
     camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
     camel.apache.org/kamelet.icon: 
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHBhdGggZmlsbD0iIzEwYTM3ZiIgZD0iTTEyIDZoNDBhOCA4IDAgMCAxIDggOHYyNGE4IDggMCAwIDEtOCA4SDI4TDE2IDU4VjQ2aC00YTggOCAwIDAgMS04LThWMTRhOCA4IDAgMCAxIDgtOHoiLz48Y2lyY2xlIGN4PSIyMCIgY3k9IjI2IiByPSI0IiBmaWxsPSIjZmZmIi8+PGNpcmNsZSBjeD0iMzIiIGN5PSIyNiIgcj0iNCIgZmlsbD0iI2ZmZiIvPjxjaXJjbGUgY3g9IjQ0IiBjeT0iMjYiIHI9IjQiIGZpbGw9IiNmZmYiLz48L3N2Zz4K"
     camel.apache.org/provider: "Apache Software Foundation"
@@ -54,7 +54,7 @@ spec:
         pattern: "^https?://.+"
       apiKey:
         title: API Key
-        description: The API key to send to the server, as a Bearer token. 
Create it in the OpenAI platform under API keys. When it is not set, the 
`OPENAI_API_KEY` environment variable is used, and with neither the Kamelet 
fails to start. A server that checks no key, such as a local one, still needs a 
value here, any text such as `none`.
+        description: The API key to send to the server, as a Bearer token. 
Create it in the OpenAI platform under API keys. When it is not set, the 
`OPENAI_API_KEY` environment variable is used. With neither, requests are sent 
without a key, which suits a local server that checks none, such as Ollama, 
while OpenAI answers them with the status 401.
         type: string
         format: password
         x-descriptors:
@@ -84,6 +84,11 @@ spec:
         description: "The JSON schema of the answer: JSON text, or 
`resource:file:` followed by the path of a file that holds it. The model is 
asked to answer with JSON that follows it (the `response_format` of the 
request), and the body afterwards is that JSON as text. The answer is not 
checked against the schema. The model and the server must support structured 
outputs. In a route, two closing braces next to each other are read as the end 
of a placeholder: write them with a space in be [...]
         type: string
         example: "resource:file:/etc/camel/ticket-schema.json"
+      jsonSchemaStrict:
+        title: JSON Schema Strict
+        description: "Whether the model must follow `jsonSchema` exactly 
(`strict` structured outputs), so the answer has all the fields of the schema 
and no others. OpenAI then only accepts a schema where each object lists all 
its properties in `required` and sets `additionalProperties` to false, and 
answers another with the status 400. Not all servers support it."
+        type: boolean
+        default: false
       maxRetries:
         title: Max Retries
         description: How many more times a request is sent when the server 
answers with the status 408, 409, 429 or 5xx, before the message fails. A 
`Retry-After` of the server is honoured. `0` sends each request once.
@@ -153,5 +158,6 @@ spec:
               temperature: "{{?temperature}}"
               maxTokens: "{{?maxTokens}}"
               jsonSchema: "RAW({{?jsonSchema}})"
+              jsonSchemaStrict: "{{jsonSchemaStrict}}"
               maxRetries: "{{maxRetries}}"
               stripThinking: "{{stripThinking}}"
diff --git 
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json 
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 39ceeeb36..a737e11db 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -1672,7 +1672,7 @@
   }, {
     "name" : "openai-chat-action",
     "type" : "action",
-    "supportLevel" : "Stable",
+    "supportLevel" : "Preview",
     "title" : "OpenAI Chat Action",
     "summary" : "Sends each message as a question to a chat model of OpenAI, 
or of any server with the same API such as Ollama, vLLM or LM Studio, and gives 
back the answer.",
     "description" : "Sends each message as a question to a chat model of 
OpenAI, or of any server with the same API such as Ollama, vLLM or LM Studio, 
and gives back the answer.\n\nUse it to summarize, classify, translate or 
answer questions about text as it flows, for example to sort support emails by 
topic or to pull the fields out of an order. Set `jsonSchema` to get the answer 
as JSON that has the fields you ask for. For a model in Amazon Bedrock or 
Google Vertex AI, use `aws-bedrock [...]
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/openai-chat-action.kamelet.yaml
 
b/library/camel-kamelets/src/main/resources/kamelets/openai-chat-action.kamelet.yaml
index 26fa7fc77..f36fb1e01 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/openai-chat-action.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/openai-chat-action.kamelet.yaml
@@ -19,7 +19,7 @@ kind: Kamelet
 metadata:
   name: openai-chat-action
   annotations:
-    camel.apache.org/kamelet.support.level: "Stable"
+    camel.apache.org/kamelet.support.level: "Preview"
     camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
     camel.apache.org/kamelet.icon: 
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHBhdGggZmlsbD0iIzEwYTM3ZiIgZD0iTTEyIDZoNDBhOCA4IDAgMCAxIDggOHYyNGE4IDggMCAwIDEtOCA4SDI4TDE2IDU4VjQ2aC00YTggOCAwIDAgMS04LThWMTRhOCA4IDAgMCAxIDgtOHoiLz48Y2lyY2xlIGN4PSIyMCIgY3k9IjI2IiByPSI0IiBmaWxsPSIjZmZmIi8+PGNpcmNsZSBjeD0iMzIiIGN5PSIyNiIgcj0iNCIgZmlsbD0iI2ZmZiIvPjxjaXJjbGUgY3g9IjQ0IiBjeT0iMjYiIHI9IjQiIGZpbGw9IiNmZmYiLz48L3N2Zz4K"
     camel.apache.org/provider: "Apache Software Foundation"
@@ -54,7 +54,7 @@ spec:
         pattern: "^https?://.+"
       apiKey:
         title: API Key
-        description: The API key to send to the server, as a Bearer token. 
Create it in the OpenAI platform under API keys. When it is not set, the 
`OPENAI_API_KEY` environment variable is used, and with neither the Kamelet 
fails to start. A server that checks no key, such as a local one, still needs a 
value here, any text such as `none`.
+        description: The API key to send to the server, as a Bearer token. 
Create it in the OpenAI platform under API keys. When it is not set, the 
`OPENAI_API_KEY` environment variable is used. With neither, requests are sent 
without a key, which suits a local server that checks none, such as Ollama, 
while OpenAI answers them with the status 401.
         type: string
         format: password
         x-descriptors:
@@ -84,6 +84,11 @@ spec:
         description: "The JSON schema of the answer: JSON text, or 
`resource:file:` followed by the path of a file that holds it. The model is 
asked to answer with JSON that follows it (the `response_format` of the 
request), and the body afterwards is that JSON as text. The answer is not 
checked against the schema. The model and the server must support structured 
outputs. In a route, two closing braces next to each other are read as the end 
of a placeholder: write them with a space in be [...]
         type: string
         example: "resource:file:/etc/camel/ticket-schema.json"
+      jsonSchemaStrict:
+        title: JSON Schema Strict
+        description: "Whether the model must follow `jsonSchema` exactly 
(`strict` structured outputs), so the answer has all the fields of the schema 
and no others. OpenAI then only accepts a schema where each object lists all 
its properties in `required` and sets `additionalProperties` to false, and 
answers another with the status 400. Not all servers support it."
+        type: boolean
+        default: false
       maxRetries:
         title: Max Retries
         description: How many more times a request is sent when the server 
answers with the status 408, 409, 429 or 5xx, before the message fails. A 
`Retry-After` of the server is honoured. `0` sends each request once.
@@ -153,5 +158,6 @@ spec:
               temperature: "{{?temperature}}"
               maxTokens: "{{?maxTokens}}"
               jsonSchema: "RAW({{?jsonSchema}})"
+              jsonSchemaStrict: "{{jsonSchemaStrict}}"
               maxRetries: "{{maxRetries}}"
               stripThinking: "{{stripThinking}}"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/openai/openai-chat-action-json-route.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/openai/openai-chat-action-json-route.yaml
index 4ac1869fb..742c80bca 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/openai/openai-chat-action-json-route.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/openai/openai-chat-action-json-route.yaml
@@ -20,10 +20,12 @@
       uri: "timer:chat"
       parameters:
         repeatCount: 2
+        # the counter of the timer that the choice reads
+        includeMetadata: true
       steps:
         - setBody:
             constant: "I was charged twice for my order, please fix it today."
-        # the server of the test checks no API key, but one must be set: any 
text will do
+        # the server of the test checks no API key, so none is set
         - choice:
             when:
               - simple: "${exchangeProperty.CamelTimerCounter} == 1"
@@ -34,9 +36,9 @@
                       uri: "kamelet:openai-chat-action"
                       parameters:
                         baseUrl: '{{chat.server.url}}/v1'
-                        apiKey: 'none'
                         model: '{{chat.model}}'
-                        jsonSchema: 
'{"type":"object","properties":{"topic":{"type":"string","enum":["billing","technical","other"]},"urgent":{"type":"boolean"}
 },"required":["topic","urgent"]}'
+                        jsonSchema: 
'{"type":"object","properties":{"topic":{"type":"string","enum":["billing","technical","other"]},"urgent":{"type":"boolean"}
 },"required":["topic","urgent"],"additionalProperties":false}'
+                        jsonSchemaStrict: true
             otherwise:
               steps:
                 # the schema from a file
@@ -44,7 +46,6 @@
                     uri: "kamelet:openai-chat-action"
                     parameters:
                       baseUrl: '{{chat.server.url}}/v1'
-                      apiKey: 'none'
                       model: '{{chat.model}}'
                       jsonSchema: 'resource:file:ticket-schema.json'
         - setHeader:
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/openai/openai-chat-action-json.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/openai/openai-chat-action-json.citrus.it.yaml
index f5688fc52..bc25c0b85 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/openai/openai-chat-action-json.citrus.it.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/openai/openai-chat-action-json.citrus.it.yaml
@@ -38,15 +38,12 @@ actions:
                 - name: "chat.model"
                   value: "${chat.model}"
 
-  # message 1: the request asks for an answer that follows the JSON schema
+  # message 1: the request, without an API key, asks for an answer that 
follows the JSON schema strictly
   - http:
       server: "openAiServer"
       receiveRequest:
         POST:
           path: "/v1/chat/completions"
-          headers:
-            - name: "Authorization"
-              value: "Bearer none"
           body:
             data: |
               {
@@ -58,13 +55,15 @@ actions:
                   "type": "json_schema",
                   "json_schema": {
                     "name": "camel_schema",
+                    "strict": true,
                     "schema": {
                       "type": "object",
                       "properties": {
                         "topic": { "type": "string", "enum": ["billing", 
"technical", "other"] },
                         "urgent": { "type": "boolean" }
                       },
-                      "required": ["topic", "urgent"]
+                      "required": ["topic", "urgent"],
+                      "additionalProperties": false
                     }
                   }
                 }
@@ -122,15 +121,12 @@ actions:
           reasonPhrase: "OK"
           version: "HTTP/1.1"
 
-  # message 2: the request asks for an answer that follows the JSON schema
+  # message 2: the request asks for an answer that follows the JSON schema, 
not strictly (the default)
   - http:
       server: "openAiServer"
       receiveRequest:
         POST:
           path: "/v1/chat/completions"
-          headers:
-            - name: "Authorization"
-              value: "Bearer none"
           body:
             data: |
               {

Reply via email to