Intent
Harden @stackbilt/llm-providers as the reusable provider/capability layer behind a Cloudflare Worker API router for coding-agent clients.
The Worker should be able to delegate model choice, structured-output handling, tool capability checks, failover, cache hints, and provider request/response normalization through public library contracts.
Use Case
The downstream gateway wants to expose Ollama/OpenAI/Anthropic-compatible endpoints while routing each request to the best available model:
- cheap JSON/structured-output model
- tool-safe model
- code model
- Workers AI LoRA reviewer/critic model
- frontier fallback
- local/remote provider bridge
Contract Surfaces To Review
- canonical request/response shape
- route preflight/introspection
- cache hint semantics
- provider/model capability metadata for JSON, tools, streaming, multimodal, LoRA, and code tasks
- fallback and degradation explanations
- response normalization for compatibility endpoints
Acceptance Criteria
- A Worker/router can ask for route selection using a canonical request without provider-specific branching.
- Capability metadata is expressive enough to choose models for JSON, tools, code, structured output, and LoRA-backed reviewer paths.
- Cache hints are concrete enough for a Worker implementation using KV/Cache API/D1/R2 without baking Cloudflare storage into the library.
- Route inspection returns enough explanation for a gateway debug endpoint.
- Public docs include a gateway/router integration example that avoids private Stackbilt-only assumptions.
Intent
Harden
@stackbilt/llm-providersas the reusable provider/capability layer behind a Cloudflare Worker API router for coding-agent clients.The Worker should be able to delegate model choice, structured-output handling, tool capability checks, failover, cache hints, and provider request/response normalization through public library contracts.
Use Case
The downstream gateway wants to expose Ollama/OpenAI/Anthropic-compatible endpoints while routing each request to the best available model:
Contract Surfaces To Review
Acceptance Criteria