Hi maintainers,
I'm evaluating using SimpleOpenAI in a high-concurrency, low-latency application running on Java 21+, and I want to leverage Virtual Threads for better scalability and simpler code structure.
However, I noticed that all public methods return CompletableFuture<T> — which suggests an async/callback-based model. This works fine, but it doesn't automatically benefit from Virtual Threads, since CompletableFuture callbacks typically run on the common fork-join pool or a fixed executor, not on virtual threads.
My Questions:
-
Is there a synchronous API available?
For example: String chatCompletion(String prompt) instead of CompletableFuture<String> chatCompletionAsync(...).
→ If yes, I can safely call it inside a Thread.startVirtualThread(...) or StructuredTaskScope.
-
If only async APIs exist:
- Are the underlying HTTP calls (e.g., via
HttpClient) configured to be compatible with Virtual Threads?
- Can I safely
.join() the CompletableFuture inside a Virtual Thread without blocking real threads?
-
Best practices for using this library with Virtual Threads:
Could you provide an example of how to properly integrate SimpleOpenAI into a virtual-threaded workflow?
-
Future plans:
Are there any plans to add native Virtual Thread support (e.g., sync methods, or integration with StructuredTaskScope)?
Why this matters:
With Virtual Threads, we can write simple, blocking-style code while achieving massive concurrency. But if the library internally blocks carrier threads or uses non-VT-friendly executors, we lose those benefits.
Thanks for your time and for maintaining this great library!
Hi maintainers,
I'm evaluating using SimpleOpenAI in a high-concurrency, low-latency application running on Java 21+, and I want to leverage Virtual Threads for better scalability and simpler code structure.
However, I noticed that all public methods return
CompletableFuture<T>— which suggests an async/callback-based model. This works fine, but it doesn't automatically benefit from Virtual Threads, sinceCompletableFuturecallbacks typically run on the common fork-join pool or a fixed executor, not on virtual threads.My Questions:
Is there a synchronous API available?
For example:
String chatCompletion(String prompt)instead ofCompletableFuture<String> chatCompletionAsync(...).→ If yes, I can safely call it inside a
Thread.startVirtualThread(...)orStructuredTaskScope.If only async APIs exist:
HttpClient) configured to be compatible with Virtual Threads?.join()theCompletableFutureinside a Virtual Thread without blocking real threads?Best practices for using this library with Virtual Threads:
Could you provide an example of how to properly integrate SimpleOpenAI into a virtual-threaded workflow?
Future plans:
Are there any plans to add native Virtual Thread support (e.g., sync methods, or integration with
StructuredTaskScope)?Why this matters:
With Virtual Threads, we can write simple, blocking-style code while achieving massive concurrency. But if the library internally blocks carrier threads or uses non-VT-friendly executors, we lose those benefits.
Thanks for your time and for maintaining this great library!