@baiq-bq/image-creation-agent 0.0.0-stage → 0.1.4

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.
package/README.md CHANGED
@@ -1,3 +1,91 @@
1
- # Temporary Holding Version
1
+ # @baiq-bq/image-creation-agent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Create images from a written brief and optional visual references in a Node.js backend. The agent plans the composition, generates one image and can review its provenance against the supplied references. BQ brand rules apply to every image. The library returns image bytes, structured results and usage accounting.
4
+
5
+ ## Installation
6
+
7
+ Requires Node.js 24 or later. The package ships ESM and CommonJS builds with TypeScript declarations.
8
+
9
+ ```sh
10
+ npm install @baiq-bq/image-creation-agent @baiq-bq/llmclient @ai-sdk/google
11
+ ```
12
+
13
+ The example uses the Google adapter. Install the SDK for the provider you actually configure. Pass credentials to your `llmclient` adapter on the server.
14
+
15
+ ## Create an image from a brief
16
+
17
+ ```ts
18
+ import { writeFile } from 'node:fs/promises';
19
+ import { createImageCreationAgent } from '@baiq-bq/image-creation-agent';
20
+ import { createLlmClient, ImageModel, LanguageModel } from '@baiq-bq/llmclient';
21
+ import { googleAdapter } from '@baiq-bq/llmclient/providers/google';
22
+
23
+ const apiKey = process.env.GOOGLE_API_KEY;
24
+ if (!apiKey) throw new Error('Set GOOGLE_API_KEY before running this example.');
25
+
26
+ const client = createLlmClient({ providers: [googleAdapter({ apiKey })] });
27
+ const agent = createImageCreationAgent({ client });
28
+ const result = await agent.create({
29
+ description: 'An editorial photograph of a blue ceramic mug on a light table, with soft natural light and no lettering.',
30
+ styleGuide: 'Natural materials and a softly blurred background.',
31
+ models: {
32
+ planning: LanguageModel.Gemini38Flash,
33
+ generation: ImageModel.Gemini31FlashImage,
34
+ },
35
+ imageOptions: { aspectRatio: '4:3' },
36
+ });
37
+
38
+ const extension = result.image.mediaType.split('/')[1];
39
+ await writeFile(`mug.${extension}`, result.image.bytes);
40
+ console.log(result.status, result.warnings, result.accounting);
41
+ ```
42
+
43
+ ## Generate from references in strict mode
44
+
45
+ Reuse the agent above and replace these example URLs with accessible images.
46
+
47
+ ```ts
48
+ const composite = await agent.create({
49
+ description: 'Combine the car body from the first image with the wings from the second. Add the headline “Ready to fly”.',
50
+ referenceImages: [
51
+ 'https://your-cdn.example/car.jpg',
52
+ 'https://your-cdn.example/wings.jpg',
53
+ ],
54
+ strictMode: true,
55
+ models: {
56
+ analysis: LanguageModel.Gemini38Flash,
57
+ planning: LanguageModel.Gemini38Flash,
58
+ generation: ImageModel.Gemini31FlashImage,
59
+ review: LanguageModel.Gemini38Flash,
60
+ },
61
+ maxRepairs: 1,
62
+ });
63
+
64
+ console.log(composite.status, composite.plan.conflicts, composite.review);
65
+ ```
66
+
67
+ Strict mode traces important artistic elements, such as prominent objects and graphical logos, to visible parts of the references. It allows recomposition and transformation of those parts. Text and decoration can be added independently. The agent checks text for spelling and legibility. Review compares the candidate with the original references and can make one correction from those same references. Provenance review is a model assessment.
68
+
69
+ ## Request options
70
+
71
+ - `description` is required. `styleGuide` adds guidance within the permanent BQ brand rules.
72
+ - `referenceImages` accepts up to five URLs, subject to the selected models' file limits. Analysis runs when there are references and style extraction or strict mode is enabled. Set `extractStyleFromImages: false` to skip style extraction. Strict mode still inventories source elements.
73
+ - `models.planning` and `models.generation` are required. Supply `models.analysis` for reference analysis and `models.review` for strict mode. The agent validates the stages it will run against the injected client's capabilities. Custom model IDs inferred by that client are supported.
74
+ - `imageOptions` accepts supported `size`, `aspectRatio`, `seed` and `providerOptions`. `maxRepairs` accepts `0` or `1` and defaults to `1` in strict mode.
75
+ - `timeoutMs` defaults to 300,000 ms for the whole operation, including downloads, provider retries and correction. Pass an `AbortSignal` as `signal` to cancel.
76
+
77
+ [BQ brand](https://bq.land) rules guide composition, color, typography and visual assets when applicable. The package exports `BQ_BRAND_STYLE_GUIDE` and `BQ_BRAND_MCP_INSTRUCTIONS` for applications that need to expose these rules before accepting requests.
78
+
79
+ ## Results and errors
80
+
81
+ - `generated` means the image was created in standard mode, where automatic visual review is skipped.
82
+ - `verified` means the strict candidate passed model review and the agent's checks.
83
+ - `unverified` includes the latest valid candidate if provenance remains unresolved, defects persist or a post-generation step fails. Inspect `warnings`, `plan` and `review` before using it.
84
+
85
+ The result includes `image.bytes`, `image.mediaType`, `analysis`, `plan`, `review`, `warnings`, `steps` and `accounting`. Store the returned bytes in your application if needed. Technical failures can throw `ImageCreationError`; inspect its `code`, `phase`, `steps`, `accounting` and available artifacts.
86
+
87
+ Each model call's accounting is preserved in `steps`. The top-level `accounting` totals the calls once. Set custom prices in `llmclient` when needed. USD estimates can be partial or unknown when the client lacks usage or pricing data.
88
+
89
+ ## Image and network limits
90
+
91
+ References and results must be static PNG, JPEG or WebP, up to 5 MiB and 40 million pixels each. The agent checks decoded content and rejects corrupt or animated images. Reference downloads require public HTTP(S) URLs on ports 80 or 443. Redirects and resolved destinations are checked. Strict review needs a model that can receive every reference and the candidate in one request. Provider limits may be lower than the agent limits.