oc-crofai
v0.4.4
Published
OpenCode plugin for CrofAI — dynamically discovers available models
Maintainers
Readme
oc-crofai
An OpenCode plugin that adds CrofAI as a first-class provider.
CrofAI provides cheap access to open-weight LLMs. This plugin dynamically discovers available models from CrofAI's API, so you always see the latest models without updating the plugin.
Installation
opencode plugin -g oc-crofaiRemoval
# 1. Remove from OpenCode's config
vi ~/.config/opencode/opencode.json
# Remove the oc-crofai entry from the plugins array
# 2. Delete the plugin package
rm -fr ~/.cache/opencode/packages/oc-crofai@latest/
# 3. Delete the model cache
rm ~/.cache/opencode/crofai-models.jsonUsage
- Get an API key from crof.ai
- OpenCode will prompt you to enter your CrofAI API key when you first use the provider
- Select "CrofAI" as your provider and choose a model
Alternatively, set the CROFAI_API_KEY environment variable:
export CROFAI_API_KEY="your-api-key-here"How It Works
The plugin uses three OpenCode hooks:
config— Registers CrofAI as a provider with@ai-sdk/openai-compatibleSDK integrationprovider— Fetcheshttps://crof.ai/v1/modelson startup and maps the response (context length, pricing, reasoning capabilities) to OpenCode's model schema. Models are sorted alphabetically and cached to disk for instant startup, with background refresh to keep them current.auth— Provides interactive API key entry with automaticCROFAI_API_KEYenv var fallback
Features
- Disk cache with background refresh — Models load instantly from cache on startup; fresh data is fetched in the background so subsequent calls always see the latest models
- 1-hour cache TTL — Stale caches are discarded and re-fetched automatically
- Cache schema version — Old cached data from previous plugin versions is automatically discarded
- 10s fetch timeout — Prevents hangs if the API is unreachable
- Model sorting — Models are sorted alphabetically for consistent ordering in the UI
- Vision detection — Vision-capable models are automatically detected by scraping CrofAI's pricing page; no hardcoded list to maintain
- Reasoning variants — All reasoning-capable models include variants for controlling thinking depth (none/low/medium/high)
Vision Support
Vision-capable models are automatically detected from CrofAI's pricing page, so models with image input are marked accordingly in the model list.
Thinking / Reasoning Support
Reasoning variants are injected via the config hook, based on teppyboy/opencode-crofai's approach.
All reasoning-capable models include four variants for controlling thinking depth:
| Variant | Reasoning Effort | Effect |
|---------|-----------------|--------|
| none | "none" | Disables reasoning — reduces latency and cost |
| low | "low" | Minimal thinking, faster responses |
| medium | "medium" | Balanced (default) |
| high | "high" | Maximum thinking, best reasoning |
To use a variant, set it in your OpenCode agent config:
agent:
build:
model: crofai/kimi-k2.6
variant: highLicense
MIT
