Schema-First

AI-Enhanced Entities

Use AI to generate cleaner entity names from database schemas

If you want to use AI to clean up the generated entities, you can use the NameParser.UsingLLM option. Currently OpenAI and Ollama are supported.

// GeneratedEntitiesExample.kt
package my.example.app

fun myFunction() {
  sql.generate(
    Code.Entities(
      CodeVersion.Fixed("1.0.0"),
      DatabaseDriver.Postgres("jdbc:postgresql://<db-host>:<db-port>/<db-name>"),
      "my.example.app",
      nameParser = NameParser.UsingLLM(LLM.OpenAI())
    )
  )
}

Be sure to set your OpenAI API key in the .codegen.properties for example:

# MyProject/.codegen.properties
user=postgres                  # For the database
password=postgres              # For the database
api-key=jsnfdkjsnf24920924...  # For OpenAI

For more details, have a look at the Code Generation sample using AI: exoquery-sample-codegen-ai