Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计通过

ideogram-sdk-patternsideogram SDK 模式

Agent Skill

ideogram-sdk-patterns 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

517

周安装

22

GitHub Stars

2,073

下载量

181
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:ideogram-sdk-patterns(ideogram SDK 模式)
来源仓库:https://github.com/jeremylongshore/claude-code-plugins-plus-skills
仓库路径:skills/ideogram-sdk-patterns
安装命令:
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill ideogram-sdk-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill ideogram-sdk-patterns

简介

ideogram-sdk-patterns 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中整理仓库状态与变更事项。

  • 适用于围绕代码提交、分支管理和团队协作进行信息梳理与分析。
  • 通过 npx skills add 命令安装,需确认权限范围和维护状态后再使用。
  • 建议结合原始 README 核验具体用法,避免触发不必要的联网或文件操作。
  • 使用前请评估是否会执行命令或读写文件,确保符合安全策略。

SKILL.md

Ideogram SDK Patterns

Overview

Production-ready patterns for Ideogram's REST API. Since Ideogram has no official SDK, these patterns provide type-safe wrappers, retry logic, response validation, and multi-tenant support for the api.ideogram.ai endpoints.

Prerequisites

  • Completed ideogram-install-auth setup
  • Familiarity with async/await and fetch API
  • Understanding of Ideogram response lifecycle (URLs expire)

Instructions

Step 1: Singleton Client with Auto-Download

// src/ideogram/client.ts
import { writeFileSync, mkdirSync } from "fs";
import { join } from "path";

const API_BASE = "https://api.ideogram.ai";

let instance: IdeogramClient | null = null;

export function getIdeogramClient(): IdeogramClient {
  if (!instance) {
    const key = process.env.IDEOGRAM_API_KEY;
    if (!key) throw new Error("IDEOGRAM_API_KEY not set");
    instance = new IdeogramClient(key);
  }
  return instance;
}

export class IdeogramClient {
  constructor(private apiKey: string) {}

  async generate(prompt: string, options: {
    model?: string;
    style_type?: string;
    aspect_ratio?: string;
    negative_prompt?: string;
    magic_prompt_option?: string;
    num_images?: number;
    seed?: number;
  } = {}) {
    const response = await fetch(`${API_BASE}/generate`, {
      method: "POST",
      headers: { "Api-Key": this.apiKey, "Content-Type": "application/json" },
      body: JSON.stringify({
        image_request: {
          prompt,
          model: options.model ?? "V_2",
          style_type: options.style_type ?? "AUTO",
          aspect_ratio: options.aspect_ratio ?? "ASPECT_1_1",
          magic_prompt_option: options.magic_prompt_option ?? "AUTO",
          negative_prompt: options.negative_prompt,
          num_images: options.num_images ?? 1,
          seed: options.seed,
        },
      }),
    });
    return this.handleResponse(response);
  }

  async describe(imagePath: string) {
    const form = new FormData();
    const file = new Blob([await import("fs").then(fs => fs.readFileSync(imagePath))]);
    form.append("image_file", file, "image.png");
    const response = await fetch(`${API_BASE}/describe`, {
      method: "POST",
      headers: { "Api-Key": this.apiKey },
      body: form,
    });
    return this.handleResponse(response);
  }

  async downloadImage(url: string, outputDir: string, filename?: string): Promise<string> {
    mkdirSync(outputDir, { recursive: true });
    const imgResponse = await fetch(url);
    if (!imgResponse.ok) throw new Error(`Download failed: ${imgResponse.status}`);
    const buffer = Buffer.from(await imgResponse.arrayBuffer());
    const outPath = join(outputDir, filename ?? `ideogram-${Date.now()}.png`);
    writeFileSync(outPath, buffer);
    return outPath;
  }

  private async handleResponse(response: Response) {
    if (!response.ok) {
      const body = await response.text();
      throw new IdeogramApiError(response.status, body);
    }
    return response.json();
  }
}

export class IdeogramApiError extends Error {
  constructor(public status: number, public body: string) {
    super(`Ideogram ${status}: ${body}`);
    this.name = "IdeogramApiError";
  }
  get isRateLimited() { return this.status === 429; }
  get isSafetyRejected() { return this.status === 422; }
  get isAuthError() { return this.status === 401; }
}

Step 2: Retry with Exponential Backoff

export async function withRetry<T>(
  operation: () => Promise<T>,
  config = { maxRetries: 3, baseDelayMs: 1000, maxDelayMs: 30000 }
): Promise<T> {
  for (let attempt = 0; attempt <= config.maxRetries; attempt++) {
    try {
      return await operation();
    } catch (err: any) {
      if (attempt === config.maxRetries) throw err;
      // Only retry on 429 (rate limit) or 5xx (server error)
      const status = err.status ?? err.response?.status;
      if (status && status !== 429 && status < 500) throw err;

      const delay = Math.min(
        config.baseDelayMs * Math.pow(2, attempt) + Math.random() * 500,
        config.maxDelayMs
      );
      console.warn(`Ideogram retry ${attempt + 1}/${config.maxRetries} in ${delay.toFixed(0)}ms`);
      await new Promise(r => setTimeout(r, delay));
    }
  }
  throw new Error("Unreachable");
}

// Usage: await withRetry(() => client.generate("a sunset"));

Step 3: Response Validation with Zod

import { z } from "zod";

const ImageResultSchema = z.object({
  url: z.string().url(),
  prompt: z.string(),
  resolution: z.string(),
  is_image_safe: z.boolean(),
  seed: z.number(),
  style_type: z.string().optional(),
});

const GenerateResponseSchema = z.object({
  created: z.string(),
  data: z.array(ImageResultSchema).min(1),
});

export function validateGenerateResponse(raw: unknown) {
  return GenerateResponseSchema.parse(raw);
}

Step 4: Python Client

# ideogram_client.py
import os, requests, hashlib, time
from pathlib import Path

class IdeogramClient:
    BASE_URL = "https://api.ideogram.ai"

    def __init__(self, api_key: str | None = None):
        self.api_key = api_key or os.environ.get("IDEOGRAM_API_KEY", "")
        if not self.api_key:
            raise ValueError("IDEOGRAM_API_KEY required")

    def generate(self, prompt: str, model="V_2", style_type="AUTO",
                 aspect_ratio="ASPECT_1_1", **kwargs) -> dict:
        resp = requests.post(f"{self.BASE_URL}/generate", headers=self._headers(),
            json={"image_request": {"prompt": prompt, "model": model,
                "style_type": style_type, "aspect_ratio": aspect_ratio,
                "magic_prompt_option": kwargs.get("magic_prompt", "AUTO"),
                **{k: v for k, v in kwargs.items() if k != "magic_prompt"}}})
        resp.raise_for_status()
        return resp.json()

    def download(self, url: str, output_dir: str = "./images") -> str:
        Path(output_dir).mkdir(parents=True, exist_ok=True)
        resp = requests.get(url)
        resp.raise_for_status()
        path = f"{output_dir}/ideogram-{int(time.time())}.png"
        Path(path).write_bytes(resp.content)
        return path

    def _headers(self):
        return {"Api-Key": self.api_key, "Content-Type": "application/json"}

Step 5: Multi-Tenant Factory

const tenantClients = new Map<string, IdeogramClient>();

export function getClientForTenant(tenantId: string): IdeogramClient {
  if (!tenantClients.has(tenantId)) {
    const apiKey = getTenantApiKey(tenantId); // from your secret store
    tenantClients.set(tenantId, new IdeogramClient(apiKey));
  }
  return tenantClients.get(tenantId)!;
}

Error Handling

PatternUse CaseBenefit
SingletonShared client across modulesSingle connection, consistent config
Retry wrapperRate limits and transient errorsAutomatic recovery from 429/5xx
Zod validationResponse validationCatches API changes at parse time
Auto-downloadImage persistencePrevents URL expiry data loss
Multi-tenantSaaS platformsPer-customer API key isolation

Output

  • Type-safe client singleton with generate and describe methods
  • Retry logic with exponential backoff and jitter
  • Runtime validation for API responses
  • Auto-download to prevent URL expiration issues

Resources

Next Steps

Apply patterns in ideogram-core-workflow-a for real-world usage.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.56%
按下载量换算63

Claude

29.88%
按下载量换算54

Cursor

16.63%
按下载量换算30

Gemini CLI

9.21%
按下载量换算17

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills