ChatMotor logo

Effortlessly Integrate OpenAI’s API into Your Java & C# Applications

ChatMotor simplifies the integration of OpenAI’s API, handling all HTTP requests, large data chunking, and teletype streaming for you.

With functional APIs for tasks like translation, transcription, text-to-speech, and image management, you can develop and deploy Java applications based on conversational AI seamlessly and efficiently. Support for C# applications is planned for future releases.

				
						// Build a ChatMotor instance.
	ChatMotor chatMotor = ChatMotor.builder().build();

	String filePath ="/path/to/your/large-file.html";
	String responsePath = filePath + ".translated.html";
	
	// Build a translation request with ChatMotor.
	// Works with large texts, preserving the original format 
	// when rendered.
	// Large files are automatically chunked into smaller parts 
	// for processing, with multi-threading enabled to speed up 
	// results.
	// This process applies to all APIs, ensuring efficient 
	// handling of large texts.
	MotorLargeTranslationRequest translationRequest 
	    = MotorLargeTranslationRequest.builder()
		    .aiModel("gpt-4")
		    .chatMotor(chatMotor)
		    .filePath(filePath)
		    .languageCode("en")
		    .build();

	// Execute the translation request
	MotorLargeResponse response = translationRequest.execute();

	// APis never throw Exceptions, never return null values.
	// Built-in safety to prevent potential runtime errors.
	if (response.isResponseOk()) {
	    // Dump the translated text to a file 
	     try (InputStream in = response.getInputStream();) {
		 Files.copy(in, Paths.get(responsePath), 
			 StandardCopyOption.REPLACE_EXISTING);
	     }
	} else {
	     // Treat errors
	     // See the MotorLargeResponse class for more details.
	}

				
			

Don’t lose time (or your hair) building on OpenAI’s low level API’s

We’ve launched several Java apps based on ChatGPT and OpenAI. In the end, we built our own toolkit to handle OpenAI API’s as they have some shortcomings:

No built-in volume handling for some OpenAI API functions.

Hard to manage large requests and responses, especially with big datasets.

Handling raw HTTP requests and retries is error-prone and cumbersome.

No failover service if current quota is exceeded or rate limit reached.

No easy built-in mechanism for managing progressive results streaming.

OpenAI APIs lack support for some audio formats.

Wanna speed up integration of OpenAI’s API?
You’re in the right place

Looking to bring AI in your app right away, without diving in the doc?

Aiming to streamline and enhance interactions with ChatGPT’s API?

Seeking to improve customer usage of advanced OpenAI models?

Discover ChatMotor, the first API to Streamline OpenAI’s Integration

painters_palette
text_speaker
translate

COMPLETE OPENAI MAPPING & EXTENDED FUNCTIONNAL APIs

We’ve made it way easier to use each model and juggle file formats

Rich mapping of all OpenAI API’s
With ChatMotor, you’ll find it’s easy to code Text-2-Speech, Transcription, Image Generation (Dall-E 2 & 3), Vision (image to answer) and translation with rich text format (HTML, Word, PDF).

				
						 // Build a translation request to the ChatMotor.
	 MotorLargeTranslationRequest translationRequest 
	 	= MotorLargeTranslationRequest.builder()
        		.aiModel("gpt-4")
        		.chatMotor(chatMotor)
        		.motorAiOptions(options)
        		.filePath(/"path/to/text.txt")
        		.languageCode("en")
        		.build();
	 
	 // Execute the request.
	 MotorLargeResponse response
	     = translationRequest.execute();
	     
	 if (response.isResponseOk()) {
	     String outFile = "/path/to/translated.txt";
	     Path path = new File(outFile).toPath();

	     try (InputStream in = response.getInputStream();) {
		 Files.copy(in, path, 
		    StandardCopyOption.REPLACE_EXISTING);
	     }
	 }
				
			
objects_transform

LARGE REQUEST CHUNKING

Enjoy More than OpenAI’s context window. Transform large contents.

And don’t fret about the size of your requests and responses.

No request Size Limit
ChatMotor automates request sequencing, allowing users to handle large queries without any size limitations.

No output file size limits
ChatMotor lets you bypass OpenAI’s output prompt token limitations (4K). You can chain requests and responses, and the result will be dumped and streamed into a file.

Bulk Program Your Excel Files
Wouldn’t it be nice for your end users to bulk program their Excel files using a prompt, instead of hard-to-code formulas in the cells or long-to-code Python scripts? This is now possible with MotorLargeRequestLines.

				
					// Build a ChatMotor instance.
ChatMotor chatMotor = ChatMotorTest.getChatMotor();

// Optionally build a MotorAiOptions instance.
MotorAiOptions options = MotorAiOptions.builder()
    .temperature(0.0) // Controls the randomness of the AI responses
    .maxTokens(4000) // Defines the maximum number of tokens in each response
    .build();

MotorSystemMessage motorSystemMessage = new MotorSystemMessage(
    "I will provide you with temperature measurements in Fahrenheit in a text file. "
    + "Convert the temperatures to degrees Celsius and add ';true' at the end of the line "
    + "if the temperature is above 20 degrees Celsius. "
    + "Do not add any comments and maintain the exact input format "
    + "without adding any new CR/LF characters.");

// Make a request to the ChatMotor. 
// Convert the CSV file following prompt.
MotorLargeRequestLines request 
    = MotorLargeRequestLines.builder()
    .chatMotor(chatMotor)
    .motorAiOptions(options)
    .systemMessage(motorSystemMessage)
    .filePath("/path/to/Fahrenheit.csv")
    .build();

// Execute the request.
MotorLargeResponse response = request.execute();

if (response.isResponseOk()) {
     String outFile = "/path/to/Celsius.csv";
     Path path = new File(outFile).toPath();

     try (InputStream in = response.getInputStream();) {
     Files.copy(in, path, 
        StandardCopyOption.REPLACE_EXISTING);
     }
} else {
    //Treat error
}
				
			
earth_network
repeat
alarmclock

TRANSPARENT HTTP HANDLING & OPENAI QUOTAS

Just code what you want to happen.
Don’t worry about managing HTTP requests

Automatic Retry in Case of Error
ChatMotor handles HTTP requests automatically and offers retry functionality with capping and delay management. This ensures robust and reliable communication, reducing the likelihood of errors disrupting operations.

Failover Management
If your account exceeds its quota or hits the rate limit, ChatMotor ensures continuity with a failover mechanism. A secondary OpenAI key will be used automatically if the primary key fails.

Thread Timeout Management
ChatMotor allows you to set a timeout for API requests to ensure efficient resource management and prevent indefinite blocking, maintaining the responsiveness of your application.

				
						// Define the max number of retries for the API requests 
	// and the retry interval between API request retries
	int maxRetries = 4;
	Duration retryInterval = Duration.ofMillis(4000);
	
	// Define a failover API key to be automatically 
	// used in case the primary API key fails
	String failoverApiKey = "[the failover api key]";
	
	// Define the timeout for the API requests threads
	Duration timeout = Duration.ofSeconds(200);
	
	//  Build the ChatMotor instance with all the parameters
	ChatMotor chatMotor = ChatMotor.builder()
		   .maxRetries(maxRetries)
		   .retryInterval(retryInterval)
		   .failoverApiKey(failoverApiKey)
		   .timeout(timeout)
		   .build();
		   
	// Build a transcription request.
	MotorTranscriptionRequest request = 
	   MotorTranscriptionRequest.builder()
		.chatMotor(chatMotor)
		.filePath("/path/to/audio/file.mp3")
		.build();

	// Execute the transcribe request.
	MotorLargeResponse largeReponse = request.execute();
	// Etc...
 
				
			
text_field

EASY OPENAI STREAMING

Teletype like ChatGPT. It’s as easy as accessing your Java Reader.

Progressive display of results
ChatMotor allows easy progressive display of responses, akin to the ChatGPT browser version.
The stream may be redirected to a File, a Queue, a Swing component, etc.

				
					 // Build a request to the ChatMotor.
 MotorRequest motorRequest = MotorRequest.builder()
    .chatMotor(chatMotor)
    .messages(motorMessages)
    .build();
 
 // Execute the request and display immediately 
 // the response in the console.
 // This uses a dedicated listener for println.
 MotorResponseListener listener = 
    new ConsoleResponseListener();
 MotorStreamStatus status =
    motorRequest.executeAsStream(listener);
				
			
shield
message
motorcycle_helmet

ERROR MANAGEMENT

Handle Errors Gracefully. Decode OpenAI Error Messages. Never Get Null Values.

No Exceptions Thrown
ChatMotor requests don’t throw exceptions, making it easy to manage errors without disrupting your application’s flow.

Detailed Error Messages
We decode OpenAI error messages, providing comprehensive details for effective troubleshooting.

No Null Values Returned
We ensure that methods never return null values, providing default values to maintain predictable and robust behavior.

				
					// Execute the translation request (see code above)
MotorLargeResponse response = translationRequest.execute();

if (response.isResponseOk()) {
    // Treat response here.
} else {

    OpenAiError openAiError = response.getOpenAiError();
    OpenAiErrorType errorType = openAiError.getType();

    if (errorType != OpenAiErrorType.NO_OPENAI_ERROR) {
    	System.out.println("OpenAI has returned an error : " 
    		+ openAiError);
    
    	// Take specific action depending on the error code:
    	if (errorType.equals(OpenAiErrorType.SERVER_ERROR)) {
    	    // ...
    	} else if (errorType.equals(OpenAiErrorType.TOKENS)) {
    	    // ..
    	} else {
    	    // Etc.
    	}

    } else {
	    System.out.println("throwable   : " 
		    + response.getThrowable());
    }
}

				
			

You think Java’s good, but C# would be even better?

We’ve got you covered!
ChatMotor for C# is coming soon in private Beta.

Of course, no spam or other unpleasantness.

Logo_C_sharp.svg
openai-logo

Access the power of OpenAI in your code in minutes with ChatMotor

clock

Enhanced Efficiency. No time wasted.
By simplifying the management of requests and answers, ChatMotor API enables developers to focus on building engaging conversational experiences. Without being bogged down by technical complexities.

repeat

Improved Reliability. Hassle-free production.
With automatic retry functionality, ChatMotor enhances the reliability of interactions with the ChatGPT API, ensuring uninterrupted service even in the face of temporary communication issues.

document_gear

Flexibility. Scalability. Say bye to limitations.
By removing prompt size limitations and by automating sequencing, ChatMotor enables flexible and scalable integration of OpenAI. This lets businesses adapt and grow conversational AI applications effortlessly.

install

Easy installation & programming.
With our clear and complete Javadoc, user guide and code samples, get started and coding in minutes. You can go to market faster with bullet proof code – which rocks for your users and customers!

Wanna push OpenAI’s API to production quickly?
Then, what are you waiting for!?

ChatMotor takes care of all HTTP handling, large requests chucking and teletype streaming, so you can push new Java/C# applications based on conversational AI effortlessly.

Companies that already use ChatMotor 

Welcome to ChatMotor API:
Elevate Your Java Applications with Advanced AI Capabilities

We provide easy to use Java APis for ChatGPT and OpenAI.

Welcome to ChatMotor API, your comprehensive solution for integrating the powerful capabilities of ChatGPT into your Java applications. Designed to streamline the integration process, ChatMotor API offers:

  • Seamless Data Management: Efficient handling of streaming data with automatic retry mechanisms and easy timeout setups
  • Unlimited Input Prompt Size: No restrictions on input prompt size, with automatic sequencing for prompts exceeding 4000 tokens.
  • Advanced Features: Includes summarization, strategic summaries, content extraction, and filtering.
  • Enhanced AI Functionalities: Offers transcription of audio formats (except dss), text-to-speech conversion, and vision calls for text generation from images.
  • Developer-Friendly: Ideal for both beginners and experienced developers, providing the tools and resources needed to enhance applications with advanced AI capabilities.
  • Purpose-Driven Design: Allows ChatGPT API application developers to focus on what they want to achieve without worrying about the technical details of how to implement it.

 

Explore the power of ChatMotor API and elevate your Java applications with cutting-edge AI functionalities.