golem-add-llm-moonbit

Integrates LLM provider REST APIs into MoonBit Golem agents using WASI HTTP.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill golem-add-llm-moonbit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golem-add-llm-moonbit
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/moonbit/golem-add-llm-moonbit
Command: npx skills add https://github.com/golemcloud/golem --skill golem-add-llm-moonbit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

MoonBit has no AI-specific libraries, so developers building Golem agents in MoonBit lack a clear path to add LLM chat, embeddings, or other AI capabilities. This Skill provides working patterns for calling LLM provider REST APIs directly via WASI HTTP from MoonBit agents.

Core Features & Use Cases

  • Direct LLM API Calls: Complete MoonBit code for calling the OpenAI Chat Completions API using WASI HTTP outgoing requests.
  • Multi-Provider Reference Table: Authority, path, and auth header details for OpenAI, Anthropic, Google Gemini, Groq, and Mistral.
  • Secret Management: Guidance on storing API keys as typed secrets with Golem's config system and the golem CLI.
  • Use Case: Build a stateful chat agent in MoonBit that maintains conversation history across turns and answers user questions through an HTTP endpoint backed by GPT-4o.

Quick Start

Add an LLM chat endpoint to my MoonBit Golem agent that calls the OpenAI API using an API key stored as a Golem secret.

Frequently Asked Questions about golem-add-llm-moonbit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call the OpenAI API from a MoonBit Golem agent?

Call the OpenAI Chat Completions API directly using WASI HTTP outgoing requests. Build a POST request to api.openai.com/v1/chat/completions with a Bearer authorization header, write the JSON body to the request stream, then block on the future response and read the reply bytes.

Are there AI or LLM libraries available for MoonBit?

No, there are no AI-specific libraries for MoonBit. The recommended approach is calling LLM provider REST APIs directly using WASI HTTP, the same mechanism used for all outgoing HTTP requests in MoonBit Golem agents.

Which LLM providers work with MoonBit Golem agents?

Any provider with a REST API works, including OpenAI, Anthropic, Google Gemini, Groq, and Mistral. You change the request authority, path, headers, and body to match each provider's API specification.

How do I store API keys securely in a Golem MoonBit agent?

Store API keys as secrets using Golem's typed config system by declaring a @config.Secret[String] field in a config struct. Create the secret with the golem secret create CLI command and access it in code via the config value's get method.

What happens to HTTP requests if a MoonBit Golem agent fails?

All HTTP requests are automatically durably persisted by Golem. On recovery, responses are replayed from the oplog, so the agent does not repeat external API calls after a failure.