Test the latest AI features in Kotlin

Craig Dunn

Hello prompt engineers,

Last week we looked at one of the new OpenAI features – Assistants – in the web playground, but good news: the OpenAI Kotlin library is already being updated with the new APIs and you can start to try them out right now in your Android codebase with snapshot package builds. With a few minor configuration changes you can start testing the latest AI features and get ready for a supported package release.

Use OpenAI Kotlin library snapshots

While new features are being added to the Kotlin library, you can track progress from this GitHub issue and the related PRs including support for the updated Images API as well as the Assistants API. Not all features will be complete (at the time of writing).

The owner (aallam) of the openai-kotlin repo is publishing pre-release snapshot builds of these features for developers to play with prior to an official release. You can see the changes required to test the snapshot in this JetchatAI pull request:

  1. Add the snapshot package source to the settings.gradle.kts file:
    maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
  2. Update the openai package version reference to 3.6.0-SNAPSHOT (in gradle/libs.versions.toml):

    openai = "com.aallam.openai:openai-client:3.6.0-SNAPSHOT"
  3. You can now start working with the “beta” API implementations (such as the DALL·E 3 image support)

Once the completed 3.6.0 release is available, don’t forget to remove the snapshots package source and update the version reference to a stable number.

Test with DALL·E 3

One of the new features announced at OpenAI Dev Day is DALL·E 3 support in the Image generation API. You can read more in the FAQs and documentation.

To use the updated API, first reference the snapshot builds as described above, and then add the new model declaration to the ImageCreation constructor:

val imageRequest = ImageCreation(prompt = prompt, model = ModelId("dall-e-3"))

Note that the model parameter did not exist in previous builds of the OpenAI Kotlin library, so if you see any compile errors then re-check your gradle changes to ensure you’re referencing the latest snapshot.

The images in Figure 1 compare the same prompt being run on DALL·E 2 and DALL·E 3 in the JetchatAI demo:

Screenshots of two JetchatAI chats, the left showing an image from DALL-E2 and the right showing an image from DALL-E 3. The DALLE-E 3 image is hyper-real and looks more impressive.
Figure 1: image response from DALL·E 2 and DALL·E 3 for the prompt “a bucolic image”

Have fun playing with DALL·E 3 and the other new APIs!

Resources and feedback

Refer to the OpenAI blog for more details on the Dev Day announcements, and the openai-kotlin repo for updates on support for the new features. 

We’d love your feedback on this post, including any tips or tricks you’ve learned from playing around with ChatGPT prompts. 

If you have any thoughts or questions, use the feedback forum or message us on Twitter @surfaceduodev


Discussion is closed.

Feedback usabilla icon