| name | ideogram-sdk-patterns |
| description | Apply production-ready Ideogram API patterns for TypeScript and Python.
Use when implementing Ideogram integrations, refactoring API usage,
or establishing team coding standards for Ideogram.
Trigger with phrases like "ideogram SDK patterns", "ideogram best practices",
"ideogram code patterns", "idiomatic ideogram", "ideogram wrapper".
|
| allowed-tools | Read, Write, Edit |
| version | 1.10.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","ideogram","python","typescript","patterns"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
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
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) {}
() {
response = (, {
: ,
: { : ., : },
: .({
: {
prompt,
: options. ?? ,
: options. ?? ,
: options. ?? ,
: options. ?? ,
: options.,
: options. ?? ,
: options.,
},
}),
});
.(response);
}
() {
form = ();
file = ([ ().( fs.(imagePath))]);
form.(, file, );
response = (, {
: ,
: { : . },
: form,
});
.(response);
}
(: , : , ?: ): <> {
(outputDir, { : });
imgResponse = (url);
(!imgResponse.) ();
buffer = .( imgResponse.());
outPath = (outputDir, filename ?? );
(outPath, buffer);
outPath;
}
() {
(!response.) {
body = response.();
(response., body);
}
response.();
}
}
{
() {
();
. = ;
}
() { . === ; }
() { . === ; }
() { . === ; }
}