├── src ├── api │ ├── .openapi-generator │ │ ├── VERSION │ │ └── FILES │ ├── index.ts │ ├── apis │ │ ├── index.ts │ │ ├── UserApi.ts │ │ ├── DefaultApi.ts │ │ ├── StyleApi.ts │ │ └── ImageApi.ts │ ├── models │ │ ├── index.ts │ │ ├── ImageFormat.ts │ │ ├── ResponseFormat.ts │ │ ├── ImageStyle.ts │ │ ├── ImageFeatures.ts │ │ ├── DescribeImageRequest.ts │ │ ├── ImageSize.ts │ │ ├── SystemStatus.ts │ │ ├── TextLayoutItem.ts │ │ ├── TransformModel.ts │ │ ├── ListStylesResponse.ts │ │ ├── ImageColor.ts │ │ ├── DescribeImageResponse.ts │ │ ├── ListBasicStylesResponse.ts │ │ ├── User.ts │ │ ├── ProcessImageResponse.ts │ │ ├── GenerateImageResponse.ts │ │ ├── UserControls.ts │ │ ├── Image.ts │ │ ├── BasicStyle.ts │ │ ├── Style.ts │ │ ├── CreateStyleResponse.ts │ │ ├── ImageSubStyle.ts │ │ └── GenerateImageRequest.ts │ ├── .openapi-generator-ignore │ └── runtime.ts ├── RecraftApi.ts ├── utils │ ├── upload.ts │ ├── index.ts │ ├── render.ts │ ├── download.ts │ ├── response.ts │ └── parameters.ts ├── tools │ ├── GetUser.ts │ ├── VectorizeImage.ts │ ├── RemoveBackground.ts │ ├── CrispUpscale.ts │ ├── CreativeUpscale.ts │ ├── CreateStyle.ts │ ├── GenerateImage.ts │ ├── ReplaceBackground.ts │ └── ImageToImage.ts ├── RecraftServer.ts └── index.ts ├── .github ├── configs │ ├── .release-please-manifest.json │ └── release-please-config.json └── workflows │ ├── release-please.yml │ └── publish.yml ├── .gitignore ├── glama.json ├── openapitools.json ├── Dockerfile ├── smithery.yaml ├── tsconfig.json ├── images ├── recraft-icon.svg └── recraft.svg ├── LICENSE ├── package.json ├── manifest.json ├── CHANGELOG.md └── README.md /src/api/.openapi-generator/VERSION: -------------------------------------------------------------------------------- 1 | 7.13.0 2 | -------------------------------------------------------------------------------- /.github/configs/.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | ".": "1.6.5" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /dist 3 | /.vscode 4 | 5 | .env* 6 | 7 | yarn.lock 8 | 9 | .DS_Store 10 | -------------------------------------------------------------------------------- /glama.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://glama.ai/mcp/schemas/server.json", 3 | "maintainers": [ 4 | "isaf27", 5 | "nkrcrft" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /src/api/index.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | export * from './runtime'; 4 | export * from './apis/index'; 5 | export * from './models/index'; 6 | -------------------------------------------------------------------------------- /openapitools.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 | "spaces": 2, 4 | "generator-cli": { 5 | "version": "7.13.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/api/apis/index.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | export * from './DefaultApi'; 4 | export * from './ImageApi'; 5 | export * from './StyleApi'; 6 | export * from './UserApi'; 7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:22.12-alpine 2 | 3 | WORKDIR /app 4 | 5 | COPY package.json ./ 6 | RUN npm install 7 | 8 | COPY . . 9 | 10 | RUN npm run build 11 | 12 | ENV NODE_ENV=production 13 | 14 | ENTRYPOINT ["node", "dist/index.js"] 15 | -------------------------------------------------------------------------------- /src/RecraftApi.ts: -------------------------------------------------------------------------------- 1 | import { Configuration, DefaultApi, ImageApi, StyleApi, UserApi } from "./api" 2 | 3 | export type RecraftApi = { 4 | defaultApi: DefaultApi, 5 | imageApi: ImageApi, 6 | styleApi: StyleApi, 7 | userApi: UserApi, 8 | } 9 | 10 | export const createRecraftApi = (config: Configuration): RecraftApi => { 11 | return { 12 | defaultApi: new DefaultApi(config), 13 | imageApi: new ImageApi(config), 14 | styleApi: new StyleApi(config), 15 | userApi: new UserApi(config), 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | name: release-please 2 | on: 3 | push: 4 | branches: [main] 5 | 6 | permissions: 7 | contents: write 8 | pull-requests: write 9 | 10 | jobs: 11 | release-please: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: googleapis/release-please-action@v4 15 | with: 16 | config-file: .github/configs/release-please-config.json 17 | manifest-file: .github/configs/.release-please-manifest.json 18 | token: ${{ secrets.GH_RELEASE_TOKEN }} 19 | -------------------------------------------------------------------------------- /smithery.yaml: -------------------------------------------------------------------------------- 1 | startCommand: 2 | type: stdio 3 | configSchema: 4 | type: object 5 | required: 6 | - RECRAFT_API_KEY 7 | properties: 8 | RECRAFT_API_KEY: 9 | type: string 10 | description: 'Your Recraft API key. Get one at https://www.recraft.ai/profile/api' 11 | commandFunction: 12 | |- 13 | (config) => ({ 14 | command: 'node', 15 | args: ['dist/index.js'], 16 | env: { 17 | RECRAFT_API_KEY: config.RECRAFT_API_KEY, 18 | RECRAFT_REMOTE_RESULTS_STORAGE: "1" 19 | } 20 | }) 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "src", 7 | "outDir": "dist", 8 | "resolveJsonModule": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true, 13 | 14 | "declaration": true, 15 | "removeComments": true, 16 | "noImplicitAny": true, 17 | "strictNullChecks": true, 18 | }, 19 | "include": ["src"], 20 | "exclude": ["node_modules", "dist"] 21 | } 22 | -------------------------------------------------------------------------------- /.github/configs/release-please-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", 3 | "release-type": "node", 4 | "include-component-in-tag": false, 5 | "packages": { 6 | ".": { 7 | "changelog-path": "CHANGELOG.md", 8 | "extra-files": [ 9 | { 10 | "type": "json", 11 | "path": "manifest.json", 12 | "jsonpath": "$.version" 13 | }, 14 | { 15 | "type": "generic", 16 | "path": "src/index.ts" 17 | } 18 | ] 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/utils/upload.ts: -------------------------------------------------------------------------------- 1 | import { writeFile } from "fs/promises" 2 | import path from "path" 3 | import mime from 'mime-types' 4 | import { ImageData } from "." 5 | 6 | export const uploadImage = async (directory: string, name: string, image: ImageData): Promise => { 7 | const { data, mimeType } = image 8 | if (mimeType === 'image/svg+xml') { 9 | const filePath = path.join(directory, `${name}.svg`) 10 | await writeFile(filePath, data, 'utf-8') 11 | return filePath 12 | } else { 13 | const filePath = path.join(directory, `${name}.${mime.extension(mimeType) || 'png'}`) 14 | const buffer = Buffer.from(data, 'base64') 15 | await writeFile(filePath, buffer) 16 | return filePath 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | import { rasterizeSvg } from "./render" 2 | 3 | export type ImageData = { 4 | data: string 5 | mimeType: string 6 | } 7 | 8 | export const imageDataToBlob = async (image: ImageData): Promise => { 9 | let { data, mimeType } = image 10 | 11 | if (mimeType === 'image/svg+xml') { 12 | const rasterized = await rasterizeSvg(data) 13 | data = rasterized.data 14 | mimeType = rasterized.mimeType 15 | } 16 | 17 | const buffer = Buffer.from(data, 'base64') 18 | return new Blob([buffer]) 19 | } 20 | 21 | export const nn = (value: T | null | undefined): T => { 22 | if (value === null || value === undefined) { 23 | throw new Error("Value is null or undefined") 24 | } 25 | return value 26 | } 27 | -------------------------------------------------------------------------------- /src/api/.openapi-generator/FILES: -------------------------------------------------------------------------------- 1 | apis/DefaultApi.ts 2 | apis/ImageApi.ts 3 | apis/StyleApi.ts 4 | apis/UserApi.ts 5 | apis/index.ts 6 | index.ts 7 | models/BasicStyle.ts 8 | models/CreateStyleResponse.ts 9 | models/GenerateImageRequest.ts 10 | models/GenerateImageResponse.ts 11 | models/Image.ts 12 | models/ImageColor.ts 13 | models/ImageFeatures.ts 14 | models/ImageFormat.ts 15 | models/ImageSize.ts 16 | models/ImageStyle.ts 17 | models/ImageSubStyle.ts 18 | models/ListBasicStylesResponse.ts 19 | models/ListStylesResponse.ts 20 | models/ProcessImageResponse.ts 21 | models/ResponseFormat.ts 22 | models/Style.ts 23 | models/SystemStatus.ts 24 | models/TextLayoutItem.ts 25 | models/TransformModel.ts 26 | models/User.ts 27 | models/UserControls.ts 28 | models/index.ts 29 | runtime.ts 30 | -------------------------------------------------------------------------------- /src/api/models/index.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | export * from './BasicStyle'; 4 | export * from './CreateStyleResponse'; 5 | export * from './GenerateImageRequest'; 6 | export * from './GenerateImageResponse'; 7 | export * from './Image'; 8 | export * from './ImageColor'; 9 | export * from './ImageFeatures'; 10 | export * from './ImageFormat'; 11 | export * from './ImageSize'; 12 | export * from './ImageStyle'; 13 | export * from './ImageSubStyle'; 14 | export * from './ListBasicStylesResponse'; 15 | export * from './ListStylesResponse'; 16 | export * from './ProcessImageResponse'; 17 | export * from './ResponseFormat'; 18 | export * from './Style'; 19 | export * from './SystemStatus'; 20 | export * from './TextLayoutItem'; 21 | export * from './TransformModel'; 22 | export * from './User'; 23 | export * from './UserControls'; 24 | -------------------------------------------------------------------------------- /images/recraft-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Recraft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/api/.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | # OpenAPI Generator Ignore 2 | # Generated by openapi-generator https://github.com/openapitools/openapi-generator 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | -------------------------------------------------------------------------------- /src/tools/GetUser.ts: -------------------------------------------------------------------------------- 1 | import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" 2 | import { RecraftServer } from "../RecraftServer" 3 | 4 | const ALMOST_ZERO_CREDITS = 50 5 | 6 | export const getUserTool = { 7 | name: "get_user", 8 | description: "Get information about the current Recraft API user (their email, name, and credit balance).", 9 | inputSchema: { 10 | type: "object", 11 | properties: { 12 | }, 13 | required: [] 14 | } 15 | } 16 | 17 | export const getUserHandler = async (server: RecraftServer, _args: Record): Promise => { 18 | try { 19 | const result = await server.api.userApi.getCurrentUser() 20 | 21 | return { 22 | content: [ 23 | { 24 | type: 'text', 25 | text: `User email: ${result.email}, name: ${result.name}.\nYou have ${result.credits} credits left.` + 26 | ( 27 | result.credits >= ALMOST_ZERO_CREDITS ? 28 | "" : 29 | `\nYou are ${result.credits > 0 ? "almost" : ""} out of credits. Please top up your account on https://www.recraft.ai/profile/api.` 30 | ) 31 | }, 32 | ] 33 | } 34 | } catch (error) { 35 | return { 36 | content: [ 37 | { 38 | type: 'text', 39 | text: `Get user error: ${error}` 40 | } 41 | ], 42 | isError: true 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: publish-on-tag 2 | 3 | on: 4 | push: 5 | tags: ['v*'] 6 | 7 | permissions: 8 | contents: write 9 | 10 | jobs: 11 | publish: 12 | runs-on: ubuntu-latest 13 | 14 | env: 15 | npm_config_cpu: wasm32 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | 20 | - uses: actions/setup-node@v4 21 | with: 22 | registry-url: https://registry.npmjs.org/ 23 | 24 | - run: npm ci 25 | 26 | - run: npm run build 27 | 28 | - name: Publish 29 | env: 30 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 31 | run: | 32 | NAME=$(node -p "require('./package.json').name") 33 | VERSION=$(node -p "require('./package.json').version") 34 | 35 | echo "Package $NAME version $VERSION" 36 | 37 | if npm view "$NAME@$VERSION" version >/dev/null 2>&1; then 38 | echo "Version already published – skipping." 39 | exit 0 40 | fi 41 | 42 | npm publish --access public 43 | 44 | - name: Build .dxt 45 | run: | 46 | npm i -g @anthropic-ai/dxt 47 | BASENAME=$(node -p "require('./package.json').name.split('/').pop()") 48 | dxt pack . "dist/$BASENAME.dxt" 49 | 50 | - uses: softprops/action-gh-release@v2 51 | with: 52 | files: dist/*.dxt 53 | generate_release_notes: true 54 | -------------------------------------------------------------------------------- /src/utils/render.ts: -------------------------------------------------------------------------------- 1 | import sharp from "sharp" 2 | import { ImageData } from "." 3 | 4 | export const rasterizeSvg = async (svg: string, scale?: number): Promise => { 5 | const svgBuffer = Buffer.from(svg, 'utf-8') 6 | 7 | const { width } = await sharp(svgBuffer).metadata() 8 | 9 | let img = sharp(svgBuffer).webp({quality: 95}) 10 | if (width) img = img.resize({ width: Math.ceil(width * (scale ?? 1.0)) }) 11 | 12 | const rasterizedBuffer = await img.toBuffer() 13 | 14 | return { 15 | data: rasterizedBuffer.toString("base64"), 16 | mimeType: 'image/webp', 17 | } 18 | } 19 | 20 | export const compressImage = async (image: ImageData, scale?: number): Promise => { 21 | const { data } = image 22 | const buffer = Buffer.from(data, 'base64') 23 | 24 | const { width } = await sharp(buffer).metadata() 25 | 26 | let img = sharp(buffer).webp({quality: 95}) 27 | if (width) img = img.resize({ width: Math.ceil(width * (scale ?? 1.0)) }) 28 | 29 | const compressedBuffer = await img.toBuffer() 30 | 31 | return { 32 | data: compressedBuffer.toString('base64'), 33 | mimeType: 'image/webp', 34 | } 35 | } 36 | 37 | export const getImageSize = async (image: ImageData): Promise<{ width: number; height: number }> => { 38 | const buffer = Buffer.from(image.data, (image.mimeType == 'image/svg+xml' ? 'utf-8' : 'base64')) 39 | const { width, height } = await sharp(buffer).metadata() 40 | return { width: width ?? 0, height: height ?? 0 } 41 | } 42 | -------------------------------------------------------------------------------- /src/utils/download.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath } from "url" 2 | import { readFile } from "fs/promises" 3 | import mime from 'mime-types' 4 | import { extname } from "path" 5 | import { ImageData } from "." 6 | 7 | export const downloadImage = async (imageUrl: string): Promise => { 8 | const url = new URL(imageUrl) 9 | 10 | let buffer: Buffer 11 | let mimeType: string 12 | 13 | if (url.protocol === 'file:') { 14 | const filePath = fileURLToPath(imageUrl) 15 | buffer = await readFile(filePath) 16 | mimeType = mime.lookup(extname(filePath)) || 'image/png' 17 | } else { 18 | const response = await fetch(imageUrl) 19 | if (!response.ok) { 20 | throw new Error(`Failed to fetch image: ${response.statusText}, URL: ${imageUrl}`) 21 | } 22 | 23 | const arrayBuffer = await response.arrayBuffer() 24 | buffer = Buffer.from(arrayBuffer) 25 | mimeType = response.headers.get('content-type') || 'image/png' 26 | } 27 | 28 | if (!['image/png', 'image/jpeg', 'image/jpg', 'image/webp', "image/svg+xml"].includes(mimeType)) { 29 | throw new Error(`Unsupported image type: ${mimeType}`) 30 | } 31 | 32 | if (mimeType === 'image/svg+xml') { 33 | return { 34 | data: buffer.toString('utf-8'), 35 | mimeType, 36 | } 37 | } 38 | 39 | return { 40 | data: buffer.toString('base64'), 41 | mimeType, 42 | } 43 | } 44 | 45 | export const downloadImages = async (imageUrls: string[]): Promise => { 46 | const imagePromises = imageUrls.map(downloadImage) 47 | const images = await Promise.all(imagePromises) 48 | return images 49 | } 50 | -------------------------------------------------------------------------------- /src/api/models/ImageFormat.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | /** 17 | * 18 | * @export 19 | */ 20 | export const ImageFormat = { 21 | Webp: 'webp', 22 | Png: 'png' 23 | } as const; 24 | export type ImageFormat = typeof ImageFormat[keyof typeof ImageFormat]; 25 | 26 | 27 | export function instanceOfImageFormat(value: any): boolean { 28 | for (const key in ImageFormat) { 29 | if (Object.prototype.hasOwnProperty.call(ImageFormat, key)) { 30 | if (ImageFormat[key as keyof typeof ImageFormat] === value) { 31 | return true; 32 | } 33 | } 34 | } 35 | return false; 36 | } 37 | 38 | export function ImageFormatFromJSON(json: any): ImageFormat { 39 | return ImageFormatFromJSONTyped(json, false); 40 | } 41 | 42 | export function ImageFormatFromJSONTyped(json: any, ignoreDiscriminator: boolean): ImageFormat { 43 | return json as ImageFormat; 44 | } 45 | 46 | export function ImageFormatToJSON(value?: ImageFormat | null): any { 47 | return value as any; 48 | } 49 | 50 | export function ImageFormatToJSONTyped(value: any, ignoreDiscriminator: boolean): ImageFormat { 51 | return value as ImageFormat; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/api/models/ResponseFormat.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | /** 17 | * 18 | * @export 19 | */ 20 | export const ResponseFormat = { 21 | Url: 'url', 22 | B64Json: 'b64_json' 23 | } as const; 24 | export type ResponseFormat = typeof ResponseFormat[keyof typeof ResponseFormat]; 25 | 26 | 27 | export function instanceOfResponseFormat(value: any): boolean { 28 | for (const key in ResponseFormat) { 29 | if (Object.prototype.hasOwnProperty.call(ResponseFormat, key)) { 30 | if (ResponseFormat[key as keyof typeof ResponseFormat] === value) { 31 | return true; 32 | } 33 | } 34 | } 35 | return false; 36 | } 37 | 38 | export function ResponseFormatFromJSON(json: any): ResponseFormat { 39 | return ResponseFormatFromJSONTyped(json, false); 40 | } 41 | 42 | export function ResponseFormatFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResponseFormat { 43 | return json as ResponseFormat; 44 | } 45 | 46 | export function ResponseFormatToJSON(value?: ResponseFormat | null): any { 47 | return value as any; 48 | } 49 | 50 | export function ResponseFormatToJSONTyped(value: any, ignoreDiscriminator: boolean): ResponseFormat { 51 | return value as ResponseFormat; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/tools/VectorizeImage.ts: -------------------------------------------------------------------------------- 1 | import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" 2 | import { imageDataToBlob } from "../utils" 3 | import z from "zod" 4 | import { RecraftServer } from "../RecraftServer" 5 | import { PARAMETERS } from "../utils/parameters" 6 | import { downloadImage } from "../utils/download" 7 | 8 | export const vectorizeImageTool = { 9 | name: "vectorize_image", 10 | description: "Vectorize an input image using Recraft.\n" + 11 | "This operation takes an input image and returns a vector SVG image, close to it.\n" + 12 | "Local path or URL to resulting image and its preview will be returned in the response.", 13 | inputSchema: { 14 | type: "object", 15 | properties: { 16 | imageURI: PARAMETERS.imageURI, 17 | }, 18 | required: ["imageURI"] 19 | } 20 | } 21 | 22 | export const vectorizeImageHandler = async (server: RecraftServer, args: Record): Promise => { 23 | try { 24 | const { imageURI } = z.object({ 25 | imageURI: z.string(), 26 | }).parse(args) 27 | 28 | const imageData = await downloadImage(imageURI) 29 | 30 | const result = await server.api.imageApi.vectorizeImage({ 31 | image: await imageDataToBlob(imageData), 32 | responseFormat: 'url', 33 | expire: server.isLocalResultsStorage, 34 | }) 35 | 36 | return await server.transformSingleImageOperationToCallToolResult(result.image, 'Vectorized given image.') 37 | } catch (error) { 38 | return { 39 | content: [ 40 | { 41 | type: 'text', 42 | text: `Vectorization error: ${error}` 43 | } 44 | ], 45 | isError: true 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/api/models/ImageStyle.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | /** 17 | * 18 | * @export 19 | */ 20 | export const ImageStyle = { 21 | DigitalIllustration: 'digital_illustration', 22 | Icon: 'icon', 23 | RealisticImage: 'realistic_image', 24 | VectorIllustration: 'vector_illustration', 25 | LogoRaster: 'logo_raster' 26 | } as const; 27 | export type ImageStyle = typeof ImageStyle[keyof typeof ImageStyle]; 28 | 29 | 30 | export function instanceOfImageStyle(value: any): boolean { 31 | for (const key in ImageStyle) { 32 | if (Object.prototype.hasOwnProperty.call(ImageStyle, key)) { 33 | if (ImageStyle[key as keyof typeof ImageStyle] === value) { 34 | return true; 35 | } 36 | } 37 | } 38 | return false; 39 | } 40 | 41 | export function ImageStyleFromJSON(json: any): ImageStyle { 42 | return ImageStyleFromJSONTyped(json, false); 43 | } 44 | 45 | export function ImageStyleFromJSONTyped(json: any, ignoreDiscriminator: boolean): ImageStyle { 46 | return json as ImageStyle; 47 | } 48 | 49 | export function ImageStyleToJSON(value?: ImageStyle | null): any { 50 | return value as any; 51 | } 52 | 53 | export function ImageStyleToJSONTyped(value: any, ignoreDiscriminator: boolean): ImageStyle { 54 | return value as ImageStyle; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/tools/RemoveBackground.ts: -------------------------------------------------------------------------------- 1 | import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" 2 | import { imageDataToBlob } from "../utils" 3 | import z from "zod" 4 | import { RecraftServer } from "../RecraftServer" 5 | import { PARAMETERS } from "../utils/parameters" 6 | import { downloadImage } from "../utils/download" 7 | 8 | export const removeBackgroundTool = { 9 | name: "remove_background", 10 | description: "Remove background in the input image using Recraft.\n" + 11 | "This operation takes an input image and returns the same image with detected background removed. Raster image will be always returned.\n" + 12 | "Local path or URL to resulting image and its preview will be returned in the response.", 13 | inputSchema: { 14 | type: "object", 15 | properties: { 16 | imageURI: PARAMETERS.imageURI, 17 | }, 18 | required: ["imageURI"] 19 | } 20 | } 21 | 22 | export const removeBackgroundHandler = async (server: RecraftServer, args: Record): Promise => { 23 | try { 24 | const { imageURI } = z.object({ 25 | imageURI: z.string(), 26 | }).parse(args) 27 | 28 | const imageData = await downloadImage(imageURI) 29 | 30 | const result = await server.api.imageApi.removeBackground({ 31 | image: await imageDataToBlob(imageData), 32 | responseFormat: 'url', 33 | expire: server.isLocalResultsStorage, 34 | }) 35 | 36 | return await server.transformSingleImageOperationToCallToolResult(result.image, 'Removed background.') 37 | } catch (error) { 38 | return { 39 | content: [ 40 | { 41 | type: 'text', 42 | text: `Remove Background error: ${error}` 43 | } 44 | ], 45 | isError: true 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/tools/CrispUpscale.ts: -------------------------------------------------------------------------------- 1 | import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" 2 | import { imageDataToBlob } from "../utils" 3 | import z from "zod" 4 | import { RecraftServer } from "../RecraftServer" 5 | import { PARAMETERS } from "../utils/parameters" 6 | import { downloadImage } from "../utils/download" 7 | 8 | export const crispUpscaleTool = { 9 | name: "crisp_upscale", 10 | description: "Crisp upscale of the input image using Recraft.\n" + 11 | "This operation takes an input image and returns an upscaled image, making the image sharper and cleaner.\n" + 12 | "This version of upscale is much cheaper and faster than creative upscale.\n" + 13 | "Local path or URL to resulting image and its preview will be returned in the response.", 14 | inputSchema: { 15 | type: "object", 16 | properties: { 17 | imageURI: PARAMETERS.imageURI, 18 | }, 19 | required: ["imageURI"] 20 | } 21 | } 22 | 23 | export const crispUpscaleHandler = async (server: RecraftServer, args: Record): Promise => { 24 | try { 25 | const { imageURI } = z.object({ 26 | imageURI: z.string(), 27 | }).parse(args) 28 | 29 | const imageData = await downloadImage(imageURI) 30 | 31 | const result = await server.api.imageApi.crispUpscale({ 32 | image: await imageDataToBlob(imageData), 33 | responseFormat: 'url', 34 | expire: server.isLocalResultsStorage, 35 | }) 36 | 37 | return await server.transformSingleImageOperationToCallToolResult(result.image, 'Crisp upscale completed.') 38 | } catch (error) { 39 | return { 40 | content: [ 41 | { 42 | type: 'text', 43 | text: `Crisp upscale error: ${error}` 44 | } 45 | ], 46 | isError: true 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/tools/CreativeUpscale.ts: -------------------------------------------------------------------------------- 1 | import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" 2 | import { imageDataToBlob } from "../utils" 3 | import z from "zod" 4 | import { RecraftServer } from "../RecraftServer" 5 | import { PARAMETERS } from "../utils/parameters" 6 | import { downloadImage } from "../utils/download" 7 | 8 | export const creativeUpscaleTool = { 9 | name: "creative_upscale", 10 | description: "Creative upscale of the input image using Recraft.\n" + 11 | "This operation takes an input image and returns an upscaled image, boosting resolution with a focus on refining small details and faces.\n" + 12 | "This version of upscale is expensive and slower than crisp upscale.\n" + 13 | "Local path or URL to resulting image and its preview will be returned in the response.", 14 | inputSchema: { 15 | type: "object", 16 | properties: { 17 | imageURI: PARAMETERS.imageURI, 18 | }, 19 | required: ["imageURI"] 20 | } 21 | } 22 | 23 | export const creativeUpscaleHandler = async (server: RecraftServer, args: Record): Promise => { 24 | try { 25 | const { imageURI } = z.object({ 26 | imageURI: z.string(), 27 | }).parse(args) 28 | 29 | const imageData = await downloadImage(imageURI) 30 | 31 | const result = await server.api.imageApi.creativeUpscale({ 32 | image: await imageDataToBlob(imageData), 33 | responseFormat: 'url', 34 | expire: server.isLocalResultsStorage, 35 | }) 36 | 37 | return await server.transformSingleImageOperationToCallToolResult(result.image, 'Creative upscale completed.') 38 | } catch (error) { 39 | return { 40 | content: [ 41 | { 42 | type: 'text', 43 | text: `Creative upscale error: ${error}` 44 | } 45 | ], 46 | isError: true 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/api/models/ImageFeatures.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | import { mapValues } from '../runtime'; 16 | /** 17 | * 18 | * @export 19 | * @interface ImageFeatures 20 | */ 21 | export interface ImageFeatures { 22 | /** 23 | * 24 | * @type {number} 25 | * @memberof ImageFeatures 26 | */ 27 | nsfwScore?: number; 28 | } 29 | 30 | /** 31 | * Check if a given object implements the ImageFeatures interface. 32 | */ 33 | export function instanceOfImageFeatures(value: object): value is ImageFeatures { 34 | return true; 35 | } 36 | 37 | export function ImageFeaturesFromJSON(json: any): ImageFeatures { 38 | return ImageFeaturesFromJSONTyped(json, false); 39 | } 40 | 41 | export function ImageFeaturesFromJSONTyped(json: any, ignoreDiscriminator: boolean): ImageFeatures { 42 | if (json == null) { 43 | return json; 44 | } 45 | return { 46 | 47 | 'nsfwScore': json['nsfw_score'] == null ? undefined : json['nsfw_score'], 48 | }; 49 | } 50 | 51 | export function ImageFeaturesToJSON(json: any): ImageFeatures { 52 | return ImageFeaturesToJSONTyped(json, false); 53 | } 54 | 55 | export function ImageFeaturesToJSONTyped(value?: ImageFeatures | null, ignoreDiscriminator: boolean = false): any { 56 | if (value == null) { 57 | return value; 58 | } 59 | 60 | return { 61 | 62 | 'nsfw_score': value['nsfwScore'], 63 | }; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/api/models/DescribeImageRequest.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | import { mapValues } from '../runtime'; 16 | /** 17 | * 18 | * @export 19 | * @interface DescribeImageRequest 20 | */ 21 | export interface DescribeImageRequest { 22 | /** 23 | * 24 | * @type {Blob} 25 | * @memberof DescribeImageRequest 26 | */ 27 | image: Blob; 28 | } 29 | 30 | /** 31 | * Check if a given object implements the DescribeImageRequest interface. 32 | */ 33 | export function instanceOfDescribeImageRequest(value: object): value is DescribeImageRequest { 34 | if (!('image' in value) || value['image'] === undefined) return false; 35 | return true; 36 | } 37 | 38 | export function DescribeImageRequestFromJSON(json: any): DescribeImageRequest { 39 | return DescribeImageRequestFromJSONTyped(json, false); 40 | } 41 | 42 | export function DescribeImageRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): DescribeImageRequest { 43 | if (json == null) { 44 | return json; 45 | } 46 | return { 47 | 48 | 'image': json['image'], 49 | }; 50 | } 51 | 52 | export function DescribeImageRequestToJSON(json: any): DescribeImageRequest { 53 | return DescribeImageRequestToJSONTyped(json, false); 54 | } 55 | 56 | export function DescribeImageRequestToJSONTyped(value?: DescribeImageRequest | null, ignoreDiscriminator: boolean = false): any { 57 | if (value == null) { 58 | return value; 59 | } 60 | 61 | return { 62 | 63 | 'image': value['image'], 64 | }; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/api/models/ImageSize.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | /** 17 | * 18 | * @export 19 | */ 20 | export const ImageSize = { 21 | _1024x1024: '1024x1024', 22 | _1365x1024: '1365x1024', 23 | _1024x1365: '1024x1365', 24 | _1536x1024: '1536x1024', 25 | _1024x1536: '1024x1536', 26 | _1820x1024: '1820x1024', 27 | _1024x1820: '1024x1820', 28 | _1024x2048: '1024x2048', 29 | _2048x1024: '2048x1024', 30 | _1434x1024: '1434x1024', 31 | _1024x1434: '1024x1434', 32 | _1024x1280: '1024x1280', 33 | _1280x1024: '1280x1024', 34 | _1024x1707: '1024x1707', 35 | _1707x1024: '1707x1024' 36 | } as const; 37 | export type ImageSize = typeof ImageSize[keyof typeof ImageSize]; 38 | 39 | 40 | export function instanceOfImageSize(value: any): boolean { 41 | for (const key in ImageSize) { 42 | if (Object.prototype.hasOwnProperty.call(ImageSize, key)) { 43 | if (ImageSize[key as keyof typeof ImageSize] === value) { 44 | return true; 45 | } 46 | } 47 | } 48 | return false; 49 | } 50 | 51 | export function ImageSizeFromJSON(json: any): ImageSize { 52 | return ImageSizeFromJSONTyped(json, false); 53 | } 54 | 55 | export function ImageSizeFromJSONTyped(json: any, ignoreDiscriminator: boolean): ImageSize { 56 | return json as ImageSize; 57 | } 58 | 59 | export function ImageSizeToJSON(value?: ImageSize | null): any { 60 | return value as any; 61 | } 62 | 63 | export function ImageSizeToJSONTyped(value: any, ignoreDiscriminator: boolean): ImageSize { 64 | return value as ImageSize; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/api/apis/UserApi.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | import * as runtime from '../runtime'; 17 | import type { 18 | User, 19 | } from '../models/index'; 20 | import { 21 | UserFromJSON, 22 | UserToJSON, 23 | } from '../models/index'; 24 | 25 | /** 26 | * 27 | */ 28 | export class UserApi extends runtime.BaseAPI { 29 | 30 | /** 31 | * Get current user info 32 | */ 33 | async getCurrentUserRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { 34 | const queryParameters: any = {}; 35 | 36 | const headerParameters: runtime.HTTPHeaders = {}; 37 | 38 | if (this.configuration && this.configuration.accessToken) { 39 | const token = this.configuration.accessToken; 40 | const tokenString = await token("auth0", []); 41 | 42 | if (tokenString) { 43 | headerParameters["Authorization"] = `Bearer ${tokenString}`; 44 | } 45 | } 46 | const response = await this.request({ 47 | path: `/v1/users/me`, 48 | method: 'GET', 49 | headers: headerParameters, 50 | query: queryParameters, 51 | }, initOverrides); 52 | 53 | return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); 54 | } 55 | 56 | /** 57 | * Get current user info 58 | */ 59 | async getCurrentUser(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { 60 | const response = await this.getCurrentUserRaw(initOverrides); 61 | return await response.value(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "commonjs", 3 | "name": "@recraft-ai/mcp-recraft-server", 4 | "version": "1.6.5", 5 | "publishConfig": { 6 | "access": "public" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/recraft-ai/mcp-recraft-server.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/recraft-ai/mcp-recraft-server/issues" 14 | }, 15 | "bin": { 16 | "mcp-recraft-server": "dist/index.js" 17 | }, 18 | "homepage": "https://github.com/recraft-ai/mcp-recraft-server#readme", 19 | "main": "dist/index.js", 20 | "description": "MCP Server implementation for recraft.ai API", 21 | "scripts": { 22 | "dev": "ts-node src/index.ts", 23 | "build": "tsc -p tsconfig.json", 24 | "start": "node dist/index.js", 25 | "inspect": "tsc -p tsconfig.json && npx -y @modelcontextprotocol/inspector node dist/index.js", 26 | "typecheck": "tsc --noEmit", 27 | "gen-oapi": "openapi-generator-cli generate -i $npm_package_config_openapi_schema -g typescript-fetch -o $npm_package_config_openapi_services --type-mappings=Date=string" 28 | }, 29 | "config": { 30 | "openapi": { 31 | "schema": "https://external.api.recraft.ai/doc/spec/api.yaml", 32 | "services": "src/api" 33 | } 34 | }, 35 | "keywords": [ 36 | "recraft", 37 | "mcp", 38 | "model context protocol", 39 | "mcp server", 40 | "ai", 41 | "recraft ai", 42 | "image generation", 43 | "image editing", 44 | "image vectorization", 45 | "image upscaling" 46 | ], 47 | "author": "Recraft (https://recraft.ai/)", 48 | "license": "MIT", 49 | "devDependencies": { 50 | "@openapitools/openapi-generator-cli": "^2.20.0", 51 | "@types/dotenv": "^6.1.1", 52 | "@types/mime-types": "^2.1.4", 53 | "@types/node": "^22.15.3", 54 | "ts-node": "^10.9.2", 55 | "typescript": "^5.8.3" 56 | }, 57 | "dependencies": { 58 | "@modelcontextprotocol/sdk": "^1.11.0", 59 | "dotenv": "^16.5.0", 60 | "mime-types": "^3.0.1", 61 | "sharp": "^0.34.2", 62 | "zod": "^3.24.4" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/api/models/SystemStatus.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | import { mapValues } from '../runtime'; 16 | /** 17 | * 18 | * @export 19 | * @interface SystemStatus 20 | */ 21 | export interface SystemStatus { 22 | /** 23 | * 24 | * @type {boolean} 25 | * @memberof SystemStatus 26 | */ 27 | generation: boolean; 28 | /** 29 | * 30 | * @type {boolean} 31 | * @memberof SystemStatus 32 | */ 33 | service: boolean; 34 | } 35 | 36 | /** 37 | * Check if a given object implements the SystemStatus interface. 38 | */ 39 | export function instanceOfSystemStatus(value: object): value is SystemStatus { 40 | if (!('generation' in value) || value['generation'] === undefined) return false; 41 | if (!('service' in value) || value['service'] === undefined) return false; 42 | return true; 43 | } 44 | 45 | export function SystemStatusFromJSON(json: any): SystemStatus { 46 | return SystemStatusFromJSONTyped(json, false); 47 | } 48 | 49 | export function SystemStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): SystemStatus { 50 | if (json == null) { 51 | return json; 52 | } 53 | return { 54 | 55 | 'generation': json['generation'], 56 | 'service': json['service'], 57 | }; 58 | } 59 | 60 | export function SystemStatusToJSON(json: any): SystemStatus { 61 | return SystemStatusToJSONTyped(json, false); 62 | } 63 | 64 | export function SystemStatusToJSONTyped(value?: SystemStatus | null, ignoreDiscriminator: boolean = false): any { 65 | if (value == null) { 66 | return value; 67 | } 68 | 69 | return { 70 | 71 | 'generation': value['generation'], 72 | 'service': value['service'], 73 | }; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/api/models/TextLayoutItem.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | import { mapValues } from '../runtime'; 16 | /** 17 | * 18 | * @export 19 | * @interface TextLayoutItem 20 | */ 21 | export interface TextLayoutItem { 22 | /** 23 | * 24 | * @type {Array>} 25 | * @memberof TextLayoutItem 26 | */ 27 | bbox: Array>; 28 | /** 29 | * 30 | * @type {string} 31 | * @memberof TextLayoutItem 32 | */ 33 | text: string; 34 | } 35 | 36 | /** 37 | * Check if a given object implements the TextLayoutItem interface. 38 | */ 39 | export function instanceOfTextLayoutItem(value: object): value is TextLayoutItem { 40 | if (!('bbox' in value) || value['bbox'] === undefined) return false; 41 | if (!('text' in value) || value['text'] === undefined) return false; 42 | return true; 43 | } 44 | 45 | export function TextLayoutItemFromJSON(json: any): TextLayoutItem { 46 | return TextLayoutItemFromJSONTyped(json, false); 47 | } 48 | 49 | export function TextLayoutItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): TextLayoutItem { 50 | if (json == null) { 51 | return json; 52 | } 53 | return { 54 | 55 | 'bbox': json['bbox'], 56 | 'text': json['text'], 57 | }; 58 | } 59 | 60 | export function TextLayoutItemToJSON(json: any): TextLayoutItem { 61 | return TextLayoutItemToJSONTyped(json, false); 62 | } 63 | 64 | export function TextLayoutItemToJSONTyped(value?: TextLayoutItem | null, ignoreDiscriminator: boolean = false): any { 65 | if (value == null) { 66 | return value; 67 | } 68 | 69 | return { 70 | 71 | 'bbox': value['bbox'], 72 | 'text': value['text'], 73 | }; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/api/models/TransformModel.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | /** 17 | * 18 | * @export 19 | */ 20 | export const TransformModel = { 21 | Refm1: 'refm1', 22 | Recraft20b: 'recraft20b', 23 | Recraftv2: 'recraftv2', 24 | Recraftv3: 'recraftv3', 25 | Flux1KontextPro: 'flux1_kontext_pro', 26 | Flux1KontextMax: 'flux1_kontext_max', 27 | Flux11pro: 'flux1_1pro', 28 | Flux1dev: 'flux1dev', 29 | Imagen3: 'imagen3', 30 | Imagen4: 'imagen4', 31 | Imagen4Ultra: 'imagen4_ultra', 32 | HidreamI1Dev: 'hidream_i1_dev', 33 | GptImage1Low: 'gpt_image_1_low', 34 | GptImage1Medium: 'gpt_image_1_medium', 35 | GptImage1High: 'gpt_image_1_high' 36 | } as const; 37 | export type TransformModel = typeof TransformModel[keyof typeof TransformModel]; 38 | 39 | 40 | export function instanceOfTransformModel(value: any): boolean { 41 | for (const key in TransformModel) { 42 | if (Object.prototype.hasOwnProperty.call(TransformModel, key)) { 43 | if (TransformModel[key as keyof typeof TransformModel] === value) { 44 | return true; 45 | } 46 | } 47 | } 48 | return false; 49 | } 50 | 51 | export function TransformModelFromJSON(json: any): TransformModel { 52 | return TransformModelFromJSONTyped(json, false); 53 | } 54 | 55 | export function TransformModelFromJSONTyped(json: any, ignoreDiscriminator: boolean): TransformModel { 56 | return json as TransformModel; 57 | } 58 | 59 | export function TransformModelToJSON(value?: TransformModel | null): any { 60 | return value as any; 61 | } 62 | 63 | export function TransformModelToJSONTyped(value: any, ignoreDiscriminator: boolean): TransformModel { 64 | return value as TransformModel; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/api/models/ListStylesResponse.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * recraft.ai external api 5 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) 6 | * 7 | * The version of the OpenAPI document: 0.0.1 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | import { mapValues } from '../runtime'; 16 | import type { Style } from './Style'; 17 | import { 18 | StyleFromJSON, 19 | StyleFromJSONTyped, 20 | StyleToJSON, 21 | StyleToJSONTyped, 22 | } from './Style'; 23 | 24 | /** 25 | * 26 | * @export 27 | * @interface ListStylesResponse 28 | */ 29 | export interface ListStylesResponse { 30 | /** 31 | * 32 | * @type {Array