myth-ai
v0.1.0-beta.5
Published
OpenAPI client for @myth-design/api
Readme
myth-ai
Official TypeScript SDK for the MYTH AI Public API - Programmatic access to MYTH AI's generative design capabilities.
Installation
npm install myth-aiAuthentication
All endpoints require a Bearer token. Get your API key from the MYTH AI dashboard.
import { Configuration, ImagesApi } from 'myth-ai';
const config = new Configuration({
basePath: 'https://api.myth-ai.com',
accessToken: 'sk-myth-xxxxx', // Your API key
});
const images = new ImagesApi(config);Quick Start
List Images
import { ImagesApi, Configuration } from 'myth-ai';
const config = new Configuration({
basePath: 'https://api.myth-ai.com',
accessToken: 'sk-myth-xxxxx',
});
const images = new ImagesApi(config);
const result = await images.listImages({
page: 1,
pageSize: 10,
});
console.log(`Total: ${result.total}`);
console.log('Images:', result.items);Create Image from Image
import { ImagesApi, Configuration, RepeatMode } from 'myth-ai';
import { v4 as uuidv4 } from 'uuid';
const result = await images.createImageToImage({
idempotencyKey: uuidv4(),
imageToImageAdvancedRequest: {
url: 'https://example.com/inspiration.jpg',
width: 1024,
height: 1024,
sharpness: 7.5,
repeatMode: RepeatMode.Block,
},
});
console.log('Generation ID:', result.id);
// Poll for completion
let image = await images.getImage({ imageId: result.id });
while (image.status === 'PENDING' || image.status === 'PROCESSING') {
await new Promise(resolve => setTimeout(resolve, 2000));
image = await images.getImage({ imageId: result.id });
}
if (image.status === 'SUCCESS') {
console.log('Download URL:', image.url);
}Upload and Generate
import { UploadsApi, ImagesApi, Configuration } from 'myth-ai';
import { v4 as uuidv4 } from 'uuid';
import { readFileSync } from 'fs';
const uploads = new UploadsApi(config);
const images = new ImagesApi(config);
// Get presigned upload URL
const uploadInfo = await uploads.createUploadUrl({
idempotencyKey: uuidv4(),
presignedUploadRequest: {
contentType: 'image/png',
},
});
// Upload file to S3
const fileBuffer = readFileSync('./inspiration.png');
await fetch(uploadInfo.presignedUrl, {
method: 'PUT',
headers: { 'Content-Type': 'image/png' },
body: fileBuffer,
});
// Generate pattern using uploaded image
const generation = await images.createImageToImage({
idempotencyKey: uuidv4(),
imageToImageAdvancedRequest: {
url: uploadInfo.s3Url,
artifactId: uploadInfo.artifactId,
width: 1024,
height: 1024,
sharpness: 5.0,
repeatMode: RepeatMode.HalfDrop,
},
});
console.log('Generation ID:', generation.id);API Endpoints
All URIs are relative to https://api.myth-ai.com
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | /v1/images | List images |
| GET | /v1/images/{image_id} | Get image details |
| POST | /v1/images | Image to Design (advanced) |
| POST | /v1/images/extract | Pattern extraction |
| POST | /v1/images/prompt-to-image | Image + Text to Design |
| POST | /v1/images/seamless | Make seamless |
| POST | /v1/images/{image_id}/export | Export image |
| POST | /v1/uploads | Get upload URL |
Features
- Full TypeScript Support - Complete type definitions included
- ESM & CommonJS - Works in both Node.js and bundlers
- Async/Await - Modern promise-based API
- Idempotency - Built-in support for idempotent requests
Rate Limiting
Rate limits are enforced based on your plan:
- Free: 100 requests/hour (GET), 10/hour (POST)
- Pro: 1000 requests/hour (GET), 100/hour (POST)
Documentation
- API Reference - Interactive API docs
- Website - Learn more about MYTH AI
License
MIT
