OpenAI
JVM since3.32.0 Native since3.32.0
OpenAI endpoint for chat completion.
Maven coordinates
Or add the coordinates to your existing project:
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-openai</artifactId>
</dependency> Check the User guide for more information about writing Camel Quarkus applications.
Usage
Structured output with output class in native mode
When using structured output with the outputClass option in native mode, you must ensure that the target class is registered for reflection.
This can be done with the @RegisterForReflection annotation or configuration property quarkus.camel.native.reflection.include-patterns. For example:
@RegisterForReflection
public class MyStructuredOutputClass {
...
} public class Routes extends RouteBuilder {
@Override
public void configure() {
from("direct:chat")
.to("openai:chat-completion?outputClass=" + MyStructuredOutputClass.class.getName());
}
} Structured output with JSON schema from classpath resource in native mode
When loading JSON schema classpath resources in native mode, you must ensure the resource is included in the native application.
For example, given a route like the following.
public class Routes extends RouteBuilder {
@Override
public void configure() {
from("direct:chat")
.to("openai:chat-completion?jsonSchema=resource:classpath:schemas/mySchema.json");
}
} Add the following to application.properties.
quarkus.native.resources.includes=schemas/mySchema.json Refer to the Native mode user guide for more information.