@aigne/ideogram 0.2.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## [0.2.0](https://github.com/AIGNE-io/aigne-framework/compare/ideogram-v0.1.0...ideogram-v0.2.0) (2025-08-27)
4
+
5
+
6
+ ### Features
7
+
8
+ * **models:** support gemini and ideogram images models ([#412](https://github.com/AIGNE-io/aigne-framework/issues/412)) ([6534fec](https://github.com/AIGNE-io/aigne-framework/commit/6534fecb0bdfb4b0a4440d44c0e563b9a029a68f))
9
+ * **models:** support gemini and ideogram images models ([#412](https://github.com/AIGNE-io/aigne-framework/issues/412)) ([6534fec](https://github.com/AIGNE-io/aigne-framework/commit/6534fecb0bdfb4b0a4440d44c0e563b9a029a68f))
package/LICENSE.md ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that
84
+ organization. **control** means ownership of substantially all the assets of an
85
+ entity, or the power to direct its management and policies by vote, contract, or
86
+ otherwise. Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** means anything you do with the software requiring one of your licenses.
92
+
93
+ **trademark** means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @aigne/ideogram
2
+
3
+ <p align="center">
4
+ <picture>
5
+ <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo-dark.svg" media="(prefers-color-scheme: dark)">
6
+ <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo.svg" media="(prefers-color-scheme: light)">
7
+ <img src="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo.svg" alt="AIGNE Logo" width="400" />
8
+ </picture>
9
+ </p>
10
+
11
+ [![GitHub star chart](https://img.shields.io/github/stars/AIGNE-io/aigne-framework?style=flat-square)](https://star-history.com/#AIGNE-io/aigne-framework)
12
+ [![Open Issues](https://img.shields.io/github/issues-raw/AIGNE-io/aigne-framework?style=flat-square)](https://github.com/AIGNE-io/aigne-framework/issues)
13
+ [![codecov](https://codecov.io/gh/AIGNE-io/aigne-framework/graph/badge.svg?token=DO07834RQL)](https://codecov.io/gh/AIGNE-io/aigne-framework)
14
+ [![NPM Version](https://img.shields.io/npm/v/@aigne/ideogram)](https://www.npmjs.com/package/@aigne/ideogram)
15
+ [![Elastic-2.0 licensed](https://img.shields.io/npm/l/@aigne/ideogram)](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE.md)
16
+
17
+ AIGNE Ideogram SDK for integrating with Ideogram's image generation models and API services within the [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework).
18
+
19
+ ## Introduction
20
+
21
+ `@aigne/ideogram` provides a seamless integration between the AIGNE Framework and Ideogram's powerful image generation models and APIs. This package enables developers to easily leverage Ideogram's advanced image generation capabilities in their AIGNE applications, providing a consistent interface across the framework while taking advantage of Ideogram's state-of-the-art image synthesis technology.
22
+
23
+
24
+ ## Installation
25
+
26
+ ### Using npm
27
+
28
+ ```bash
29
+ npm install @aigne/ideogram
30
+ ```
31
+
32
+ ### Using yarn
33
+
34
+ ```bash
35
+ yarn add @aigne/ideogram
36
+ ```
37
+
38
+ ### Using pnpm
39
+
40
+ ```bash
41
+ pnpm add @aigne/ideogram
42
+ ```
43
+
44
+ ## Basic Usage
45
+
46
+ ```typescript
47
+ import { IdeogramImageModel } from "@aigne/ideogram";
48
+
49
+ const model = new IdeogramImageModel({
50
+ apiKey: "your-api-key", // Optional if set in env variables
51
+ });
52
+
53
+ const result = await model.invoke({
54
+ prompt: "A serene mountain landscape at sunset with golden light",
55
+ });
56
+
57
+ console.log(result);
58
+ /* Output:
59
+ {
60
+ images: [
61
+ {
62
+ url: "https://api.ideogram.ai/generation/...",
63
+ }
64
+ ],
65
+ usage: {
66
+ promptTokens: 0
67
+ imageCount: 0
68
+ }
69
+ }
70
+ */
71
+ ```
72
+ ## Environment Variables
73
+
74
+ Set the following environment variable for automatic API key detection:
75
+
76
+ ```bash
77
+ export IDEOGRAM_API_KEY="your-ideogram-api-key"
78
+ ```
79
+
80
+ ## License
81
+
82
+ Elastic-2.0
@@ -0,0 +1,36 @@
1
+ import { ImageModel, type ImageModelInput, type ImageModelOptions, type ImageModelOutput } from "@aigne/core";
2
+ export interface IdeogramImageModelInput extends ImageModelInput {
3
+ seed?: number;
4
+ resolution?: string;
5
+ aspectRatio?: string;
6
+ renderingSpeed?: string;
7
+ magicPrompt?: string;
8
+ negativePrompt?: string;
9
+ numImages?: number;
10
+ colorPalette?: any;
11
+ styleCodes?: string[];
12
+ styleType?: string;
13
+ }
14
+ export interface IdeogramImageModelOutput extends ImageModelOutput {
15
+ }
16
+ export interface IdeogramImageModelOptions extends ImageModelOptions<IdeogramImageModelInput, IdeogramImageModelOutput> {
17
+ apiKey?: string;
18
+ baseURL?: string;
19
+ modelOptions?: Omit<Partial<IdeogramImageModelInput>, "model">;
20
+ }
21
+ export declare class IdeogramImageModel extends ImageModel<IdeogramImageModelInput, IdeogramImageModelOutput> {
22
+ options?: IdeogramImageModelOptions | undefined;
23
+ constructor(options?: IdeogramImageModelOptions | undefined);
24
+ protected apiKeyEnvName: string;
25
+ get credential(): {
26
+ url: string;
27
+ apiKey: string | undefined;
28
+ };
29
+ get modelOptions(): Omit<Partial<IdeogramImageModelInput>, "model"> | undefined;
30
+ /**
31
+ * Process the input and generate a response
32
+ * @param input The input to process
33
+ * @returns The generated response
34
+ */
35
+ process(input: IdeogramImageModelInput): Promise<ImageModelOutput>;
36
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdeogramImageModel = void 0;
4
+ const core_1 = require("@aigne/core");
5
+ const camelize_js_1 = require("@aigne/core/utils/camelize.js");
6
+ const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
7
+ const zod_1 = require("zod");
8
+ const IDEOGRAM_BASE_URL = "https://api.ideogram.ai/v1/ideogram-v3/generate";
9
+ const ideogramImageModelInputSchema = core_1.imageModelInputSchema.extend({});
10
+ const ideogramImageModelOptionsSchema = zod_1.z.object({
11
+ apiKey: zod_1.z.string().optional(),
12
+ baseURL: zod_1.z.string().optional(),
13
+ modelOptions: zod_1.z.object({}).optional(),
14
+ clientOptions: zod_1.z.object({}).optional(),
15
+ });
16
+ class IdeogramImageModel extends core_1.ImageModel {
17
+ options;
18
+ constructor(options) {
19
+ super({
20
+ ...options,
21
+ inputSchema: ideogramImageModelInputSchema,
22
+ description: options?.description ?? "Draw or edit image by Ideogram image models",
23
+ });
24
+ this.options = options;
25
+ if (options)
26
+ (0, type_utils_js_1.checkArguments)(this.name, ideogramImageModelOptionsSchema, options);
27
+ }
28
+ apiKeyEnvName = "IDEOGRAM_API_KEY";
29
+ get credential() {
30
+ return {
31
+ url: this.options?.baseURL || process.env.IDEOGRAM_BASE_URL || IDEOGRAM_BASE_URL,
32
+ apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],
33
+ };
34
+ }
35
+ get modelOptions() {
36
+ return this.options?.modelOptions;
37
+ }
38
+ /**
39
+ * Process the input and generate a response
40
+ * @param input The input to process
41
+ * @returns The generated response
42
+ */
43
+ async process(input) {
44
+ const model = input.model;
45
+ const formData = new FormData();
46
+ const inputKeys = [
47
+ "prompt",
48
+ "seed",
49
+ "resolution",
50
+ "aspectRatio",
51
+ "renderingSpeed",
52
+ "magicPrompt",
53
+ "negativePrompt",
54
+ "colorPalette",
55
+ "styleCodes",
56
+ "styleType",
57
+ ];
58
+ const mergedInput = (0, camelize_js_1.snakelize)((0, type_utils_js_1.pick)({ ...this.modelOptions, ...input }, inputKeys));
59
+ if (input.n) {
60
+ formData.append("num_images", input.n.toString());
61
+ }
62
+ Object.keys(mergedInput).forEach((key) => {
63
+ if (mergedInput[key]) {
64
+ formData.append(key, mergedInput[key]);
65
+ }
66
+ });
67
+ const { url, apiKey } = this.credential;
68
+ if (!apiKey)
69
+ throw new Error(`${this.name} requires an API key. Please provide it via \`options.apiKey\`, or set the \`${this.apiKeyEnvName}\` environment variable`);
70
+ const response = await fetch(url, {
71
+ method: "POST",
72
+ headers: { "api-key": apiKey },
73
+ body: formData,
74
+ });
75
+ if (!response.ok) {
76
+ const error = await response.text();
77
+ throw new Error(`Ideogram API error: ${response.status} ${response.statusText} ${error}`);
78
+ }
79
+ const data = await response.json();
80
+ return {
81
+ images: data.data.map((item) => ({ url: item.url })),
82
+ usage: {
83
+ inputTokens: 0,
84
+ outputTokens: 0,
85
+ },
86
+ model,
87
+ };
88
+ }
89
+ }
90
+ exports.IdeogramImageModel = IdeogramImageModel;
@@ -0,0 +1 @@
1
+ export * from "./ideogram-image-model.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ideogram-image-model.js"), exports);
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,36 @@
1
+ import { ImageModel, type ImageModelInput, type ImageModelOptions, type ImageModelOutput } from "@aigne/core";
2
+ export interface IdeogramImageModelInput extends ImageModelInput {
3
+ seed?: number;
4
+ resolution?: string;
5
+ aspectRatio?: string;
6
+ renderingSpeed?: string;
7
+ magicPrompt?: string;
8
+ negativePrompt?: string;
9
+ numImages?: number;
10
+ colorPalette?: any;
11
+ styleCodes?: string[];
12
+ styleType?: string;
13
+ }
14
+ export interface IdeogramImageModelOutput extends ImageModelOutput {
15
+ }
16
+ export interface IdeogramImageModelOptions extends ImageModelOptions<IdeogramImageModelInput, IdeogramImageModelOutput> {
17
+ apiKey?: string;
18
+ baseURL?: string;
19
+ modelOptions?: Omit<Partial<IdeogramImageModelInput>, "model">;
20
+ }
21
+ export declare class IdeogramImageModel extends ImageModel<IdeogramImageModelInput, IdeogramImageModelOutput> {
22
+ options?: IdeogramImageModelOptions | undefined;
23
+ constructor(options?: IdeogramImageModelOptions | undefined);
24
+ protected apiKeyEnvName: string;
25
+ get credential(): {
26
+ url: string;
27
+ apiKey: string | undefined;
28
+ };
29
+ get modelOptions(): Omit<Partial<IdeogramImageModelInput>, "model"> | undefined;
30
+ /**
31
+ * Process the input and generate a response
32
+ * @param input The input to process
33
+ * @returns The generated response
34
+ */
35
+ process(input: IdeogramImageModelInput): Promise<ImageModelOutput>;
36
+ }
@@ -0,0 +1 @@
1
+ export * from "./ideogram-image-model.js";
@@ -0,0 +1,36 @@
1
+ import { ImageModel, type ImageModelInput, type ImageModelOptions, type ImageModelOutput } from "@aigne/core";
2
+ export interface IdeogramImageModelInput extends ImageModelInput {
3
+ seed?: number;
4
+ resolution?: string;
5
+ aspectRatio?: string;
6
+ renderingSpeed?: string;
7
+ magicPrompt?: string;
8
+ negativePrompt?: string;
9
+ numImages?: number;
10
+ colorPalette?: any;
11
+ styleCodes?: string[];
12
+ styleType?: string;
13
+ }
14
+ export interface IdeogramImageModelOutput extends ImageModelOutput {
15
+ }
16
+ export interface IdeogramImageModelOptions extends ImageModelOptions<IdeogramImageModelInput, IdeogramImageModelOutput> {
17
+ apiKey?: string;
18
+ baseURL?: string;
19
+ modelOptions?: Omit<Partial<IdeogramImageModelInput>, "model">;
20
+ }
21
+ export declare class IdeogramImageModel extends ImageModel<IdeogramImageModelInput, IdeogramImageModelOutput> {
22
+ options?: IdeogramImageModelOptions | undefined;
23
+ constructor(options?: IdeogramImageModelOptions | undefined);
24
+ protected apiKeyEnvName: string;
25
+ get credential(): {
26
+ url: string;
27
+ apiKey: string | undefined;
28
+ };
29
+ get modelOptions(): Omit<Partial<IdeogramImageModelInput>, "model"> | undefined;
30
+ /**
31
+ * Process the input and generate a response
32
+ * @param input The input to process
33
+ * @returns The generated response
34
+ */
35
+ process(input: IdeogramImageModelInput): Promise<ImageModelOutput>;
36
+ }
@@ -0,0 +1,86 @@
1
+ import { ImageModel, imageModelInputSchema, } from "@aigne/core";
2
+ import { snakelize } from "@aigne/core/utils/camelize.js";
3
+ import { checkArguments, pick } from "@aigne/core/utils/type-utils.js";
4
+ import { z } from "zod";
5
+ const IDEOGRAM_BASE_URL = "https://api.ideogram.ai/v1/ideogram-v3/generate";
6
+ const ideogramImageModelInputSchema = imageModelInputSchema.extend({});
7
+ const ideogramImageModelOptionsSchema = z.object({
8
+ apiKey: z.string().optional(),
9
+ baseURL: z.string().optional(),
10
+ modelOptions: z.object({}).optional(),
11
+ clientOptions: z.object({}).optional(),
12
+ });
13
+ export class IdeogramImageModel extends ImageModel {
14
+ options;
15
+ constructor(options) {
16
+ super({
17
+ ...options,
18
+ inputSchema: ideogramImageModelInputSchema,
19
+ description: options?.description ?? "Draw or edit image by Ideogram image models",
20
+ });
21
+ this.options = options;
22
+ if (options)
23
+ checkArguments(this.name, ideogramImageModelOptionsSchema, options);
24
+ }
25
+ apiKeyEnvName = "IDEOGRAM_API_KEY";
26
+ get credential() {
27
+ return {
28
+ url: this.options?.baseURL || process.env.IDEOGRAM_BASE_URL || IDEOGRAM_BASE_URL,
29
+ apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],
30
+ };
31
+ }
32
+ get modelOptions() {
33
+ return this.options?.modelOptions;
34
+ }
35
+ /**
36
+ * Process the input and generate a response
37
+ * @param input The input to process
38
+ * @returns The generated response
39
+ */
40
+ async process(input) {
41
+ const model = input.model;
42
+ const formData = new FormData();
43
+ const inputKeys = [
44
+ "prompt",
45
+ "seed",
46
+ "resolution",
47
+ "aspectRatio",
48
+ "renderingSpeed",
49
+ "magicPrompt",
50
+ "negativePrompt",
51
+ "colorPalette",
52
+ "styleCodes",
53
+ "styleType",
54
+ ];
55
+ const mergedInput = snakelize(pick({ ...this.modelOptions, ...input }, inputKeys));
56
+ if (input.n) {
57
+ formData.append("num_images", input.n.toString());
58
+ }
59
+ Object.keys(mergedInput).forEach((key) => {
60
+ if (mergedInput[key]) {
61
+ formData.append(key, mergedInput[key]);
62
+ }
63
+ });
64
+ const { url, apiKey } = this.credential;
65
+ if (!apiKey)
66
+ throw new Error(`${this.name} requires an API key. Please provide it via \`options.apiKey\`, or set the \`${this.apiKeyEnvName}\` environment variable`);
67
+ const response = await fetch(url, {
68
+ method: "POST",
69
+ headers: { "api-key": apiKey },
70
+ body: formData,
71
+ });
72
+ if (!response.ok) {
73
+ const error = await response.text();
74
+ throw new Error(`Ideogram API error: ${response.status} ${response.statusText} ${error}`);
75
+ }
76
+ const data = await response.json();
77
+ return {
78
+ images: data.data.map((item) => ({ url: item.url })),
79
+ usage: {
80
+ inputTokens: 0,
81
+ outputTokens: 0,
82
+ },
83
+ model,
84
+ };
85
+ }
86
+ }
@@ -0,0 +1 @@
1
+ export * from "./ideogram-image-model.js";
@@ -0,0 +1 @@
1
+ export * from "./ideogram-image-model.js";
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@aigne/ideogram",
3
+ "description": "AIGNE Ideogram SDK for integrating with Ideogram's image models and API services",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
8
+ "homepage": "https://www.aigne.io/framework",
9
+ "license": "Elastic-2.0",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/AIGNE-io/aigne-framework"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/AIGNE-io/aigne-framework/issues"
16
+ },
17
+ "files": [
18
+ "lib/cjs",
19
+ "lib/dts",
20
+ "lib/esm",
21
+ "LICENSE",
22
+ "README.md",
23
+ "CHANGELOG.md"
24
+ ],
25
+ "type": "module",
26
+ "main": "./lib/cjs/index.js",
27
+ "module": "./lib/esm/index.js",
28
+ "types": "./lib/dts/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "import": "./lib/esm/index.js",
32
+ "require": "./lib/cjs/index.js",
33
+ "types": "./lib/dts/index.d.ts"
34
+ }
35
+ },
36
+ "dependencies": {
37
+ "@aigne/core": "1.55.1"
38
+ },
39
+ "devDependencies": {
40
+ "@types/bun": "^1.2.18",
41
+ "@types/node": "^24.0.12",
42
+ "detect-port": "^2.1.0",
43
+ "hono": "^4.9.4",
44
+ "npm-run-all": "^4.1.5",
45
+ "rimraf": "^6.0.1",
46
+ "typescript": "^5.8.3",
47
+ "zod": "3.25.67"
48
+ },
49
+ "version": "0.2.0",
50
+ "scripts": {
51
+ "lint": "tsc --noEmit",
52
+ "build": "tsc --build scripts/tsconfig.build.json",
53
+ "clean": "rimraf lib test/coverage",
54
+ "test": "bun test",
55
+ "test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text",
56
+ "postbuild": "node ../../scripts/post-build-lib.mjs"
57
+ }
58
+ }