Core OpenAI integration
Interactive form to generate AI responses with customizable prompts, system messages, and model parameters.
Foundation demo from the Scrimba course.
// OpenAI Chat Completion Integration
val openAI = OpenAI(apiKey = "your-openai-api-key")
val response = openAI.createChatCompletion(
prompt = "Explain machine learning",
systemMessage = "You are a helpful assistant",
model = "gpt-3.5-turbo",
maxTokens = 300,
temperature = 0.7
)
println("Response: ${response.text()}")
println("Usage: ${response.usage()}")
openAI.close()