Skip to content

UtilitiesTopics: ai, llm, chat, structured-output, openai, anthropic, groq, cloudflare, dry-run

Version
1.0.0
License
MIT
Published
September 10, 2026
Pinned commit
704b75d
Rating
★ 5.0 (1)
Forks
6
Adaptation effort
1.0

@kody/ai

Generic geometric mark (not a vendor logo). This package is not affiliated with OpenAI, Anthropic, Groq, or Cloudflare.

Intent

Give every Kody account reusable, provider-agnostic AI helpers: chat completions, structured JSON generation, and a thin host-side tool loop. Callers pass the provider, model, and their own saved API key. Success means a forked copy can dry-run a request, then generate text or JSON, without anyone baking in personal keys, account ids, or a single vendor.

Live @kody/ai storage is the platform package bucket, not the caller's. Fork first (or packages.invoke the user's copy) before saving defaults.

What it does

  • Chat completions across OpenAI, Anthropic, Groq, Cloudflare Workers AI, and OpenAI-compatible base URLs
  • Structured JSON generation from a JSON Schema
  • Model-only steps with default Kody search/execute tool schemas for host packages
  • Optional tool-using agent turns (search/execute run as package ai)
  • Fork-local provider/model defaults via ./settings (writes need confirm: true)

No jobs or schedules ship in this package.

Prerequisites / setup

API key (secret-backed). There is no AI OAuth integration and no baked-in key. Do not open /connect/oauth for this package. Never paste key values into chat. Agents: see AGENTS.md for import paths, smoke, and dryRun.

SecretProviderHosts to approve
openaiApiKeyOpenAIapi.openai.com
anthropicApiKeyAnthropicapi.anthropic.com
groqApiKeyGroqapi.groq.com
cloudflareApiTokenCloudflare Workers AIapi.cloudflare.com, gateway.ai.cloudflare.com
openaiCompatibleApiKeyCustom OpenAI-compatible base URLthe host you pass as baseUrl

Readable defaults (not secrets) live in this package's packageStorage() after you fork: provider, model, baseUrl, cloudflareAccountId, cloudflareAiGatewayId.

  1. Create an API key in the provider console.
  2. Save the matching secret (pick one provider to start):

https://kody.codes/account/secrets/new?name=openaiApiKey&description=OpenAI%20API%20key%20for%20chat%20completions&allowedHosts=api.openai.com&scope=user

https://kody.codes/account/secrets/new?name=anthropicApiKey&description=Anthropic%20API%20key%20for%20Messages&allowedHosts=api.anthropic.com&scope=user

https://kody.codes/account/secrets/new?name=groqApiKey&description=Groq%20API%20key%20for%20OpenAI-compatible%20chat&allowedHosts=api.groq.com&scope=user

https://kody.codes/account/secrets/new?name=cloudflareApiToken&description=Cloudflare%20API%20token%20for%20Workers%20AI&allowedHosts=api.cloudflare.com,gateway.ai.cloudflare.com&scope=user

https://kody.codes/account/secrets/new?name=openaiCompatibleApiKey&description=API%20key%20for%20an%20OpenAI-compatible%20base%20URL&scope=user

  1. Approve the host(s) listed above for that secret.
  2. Cloudflare also needs cloudflareAccountId in ./settings on your fork (optional cloudflareAiGatewayId if you already have a gateway — this package never creates one).
  3. Run the smoke test.

Additional accounts

Pass account: "work" to use openaiApiKey-work (or the matching provider secret), or pass apiKeySecret explicitly.

https://kody.codes/account/secrets/new?name=openaiApiKey-work&description=OpenAI%20API%20key%20for%20chat%20completions&allowedHosts=api.openai.com&scope=user

Done when

  • A provider secret is saved and its host(s) are approved
  • Smoke test returns { ok: true } (live: false before credentials; models-list only when a secret exists — no completion tokens)
  • ./settings writes refuse unless confirm: true; dryRun: true never calls the vendor

Branding

Keep LICENSE (MIT), ## Intent, and community-icon.svg intact for community listing.

Docs

Report this listing

Log in to report this listing.