Skip to main content
Kotlin agent that uses OpenAI API with Bindu SDK.

Code

Skill Configuration

Create skills/kotlin-openai-skill/skill.yaml:

How It Works

Kotlin SDK Integration
  • bindufy() function wraps Kotlin logic as Bindu agent
  • Automatic microservice generation with DID and auth
  • A2A protocol compliance handled by SDK
  • Language-agnostic agent development
OpenAI API Communication
  • HttpClient makes direct API calls to OpenAI
  • JSON message formatting with Gson
  • Bearer token authentication
  • Response parsing and content extraction
Message Processing
  • ChatMessage objects for conversation history
  • Role-based message formatting (user/assistant)
  • Suspended function for async API calls
  • Direct content return to Bindu

Dependencies

Environment Setup

Set your OpenAI API key:

Build Requirements

Add to build.gradle.kts:

Run

Examples:
  • “Explain the benefits of using Kotlin for backend development”
  • “What are the key features of Kotlin coroutines?”
  • “How do I integrate OpenAI API with Kotlin applications?”

Example API Calls

Frontend Setup

Open http://localhost:5173 and try to chat with the Kotlin OpenAI agent