What problem does it solve?
Adding LLM capabilities to a Scala Golem agent is tricky because agents compile to JavaScript via Scala.js, so JVM HTTP clients and most Scala libraries simply do not work. This Skill guides you through the working approaches for calling OpenAI-style chat completion and embedding APIs from a Scala agent.
Core Features & Use Cases
- Direct REST API calls with fetch: Call LLM provider endpoints using the global
fetch function available in Scala.js, the most reliable approach.
- ZIO HTTP client option: Use
zio-http with a typed client for ZIO-based agents.
- Secret management for API keys: Store provider keys with Golem's typed config system using
Secret[String] and the golem secret create CLI command.
- Use Case: Build a chat agent mounted at
/chats/{value} that maintains conversation history in agent state and answers questions through the OpenAI chat completions API.
Quick Start
Add an LLM chat endpoint to my Scala Golem agent that calls the OpenAI API using fetch and stores the API key as a Golem secret.