@seanhogg/builderforce-sdk 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +25 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @seanhogg/builderforce-sdk
2
2
 
3
- Typed TypeScript SDK for the [Builderforce.ai](https://builderforce.ai) LLM gateway. OpenAI-compatible chat completions with tool calling and structured output, embeddings, model registry, and usage analytics — all behind a single tenant API key. Vendor failover (OpenRouter / Cerebras / Ollama / Claude / GPT / Gemini / Grok) is handled server-side so your code only knows about Builderforce.
3
+ Typed TypeScript SDK for the [Builderforce.ai](https://builderforce.ai) LLM gateway. OpenAI-compatible chat completions with tool calling and structured output, embeddings, image generation (Together → FluxAPI cascade), model registry, and usage analytics — all behind a single tenant API key. Vendor failover (OpenRouter / Cerebras / Ollama / Claude / GPT / Gemini / Grok / Flux) is handled server-side so your code only knows about Builderforce.
4
4
 
5
5
  - **Vanilla `fetch` / `AbortController` / `ReadableStream` / `TextDecoder`** — runs on Node 18+, Cloudflare Workers, browsers, edge runtimes.
6
- - **Zero runtime dependencies.** ~23 kB compressed, ~102 kB unpacked.
6
+ - **Zero runtime dependencies.** ~34 kB compressed, ~154 kB unpacked.
7
7
  - **Dual ESM + CJS + `.d.ts`** out of the box.
8
8
 
9
9
  ## Install
@@ -205,6 +205,29 @@ for (const obj of res.data) {
205
205
 
206
206
  Wired to OpenRouter; default model `nvidia/llama-nemotron-embed-vl-1b-v2:free` (free-tier, competitive with `text-embedding-3-small` for English). Override via `model`.
207
207
 
208
+ ## Image generation
209
+
210
+ ```ts
211
+ const res = await client.images.generate({
212
+ prompt: 'A studio photo of a corgi astronaut, soft rim light',
213
+ size: '1024x1024',
214
+ n: 1,
215
+ });
216
+
217
+ for (const img of res.data) {
218
+ console.log(img.url); // hosted URL (default)
219
+ // img.b64_json // when `response_format: 'b64_json'`
220
+ // img.revised_prompt // vendor-side prompt rewrite, if any
221
+ }
222
+
223
+ console.log(res._builderforce?.resolvedModel); // which model actually served
224
+ console.log(res._builderforce?.resolvedVendor); // 'together' | 'fluxapi' | …
225
+ ```
226
+
227
+ OpenAI-compatible surface — same `prompt` / `size` / `n` / `response_format: 'url' | 'b64_json'` shape. Behind the scenes the gateway cascades free Together vendors → premium FluxAPI fallback, so a saturated free pool falls through instead of returning a 429. Vendor-prefix the `model` (`together/<id>`, `fluxapi/flux-kontext-pro`) to pin; bare ids resolve via catalog lookup. Same `useCase` / `metadata` / `idempotencyKey` / `timeoutMs` / `signal` options as chat, with the same billing trace-back semantics.
228
+
229
+ Each generated image is billed against the tenant's daily token budget at a flat ~1000-token rate, so `plan_token_limit_exceeded` 429s + the `Don't retry terminal errors` pattern below apply identically to images.
230
+
208
231
  ## Per-call options
209
232
 
210
233
  Override defaults for individual calls:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seanhogg/builderforce-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Typed SDK for the Builderforce.ai LLM gateway — chat completions with tool-calling and structured output, embeddings, image generation, models, and usage analytics over an OpenAI-compatible surface.",
5
5
  "license": "MIT",
6
6
  "author": "Sean Hogg",