Skip to main content

Firemoon

还没翻译译自英文(ai-sdk.dev)本页 34 段都还没译

Firemoon Studio is an AI platform specializing in high-quality image and video generation models, specifically fine-tunes and state-of-the-art models.

The Firemoon provider for the AI SDK enables you to use these models with a simple, consistent API:

  • Image generation: Generate images today, with early video model support.
  • Model variety: Access multiple model families through a single provider.
  • Provider options: Pass model-specific parameters when you need more control.

Setup

The Firemoon provider is available via the @firemoon/ai-provider module. You can install it with:

pnpm add @firemoon/ai-provider
npm install @firemoon/ai-provider
yarn add @firemoon/ai-provider
bun add @firemoon/ai-provider

Provider Instance

Create a Firemoon provider instance with your API key:

import { createFiremoon } from '@firemoon/ai-provider';

const firemoon = createFiremoon({
  apiKey: process.env.FIREMOON_API_KEY,
});

You can obtain your Firemoon API key from the Firemoon Dashboard.

Image Generation

Firemoon supports various image generation models through the image() method:

import { generateImage } from 'ai';

const result = await generateImage({
  model: firemoon.image('flux/dev'),
  prompt: 'An orangered moon with a dark background',
  size: 'square_hd',
});

console.log(result.images[0]);

Available Models

  • flux/dev - Fast, high-quality image generation
  • flux-2-dev/edit - Fast, high-quality image editing with Flux 2
  • nano-banana - Fast, high-quality image generation
  • nano-banana/edit - High quality image editing by Gemini, also known as Gemini 2.5 Flash Image
  • nano-banana-pro/edit - High quality image editing by Gemini 3 Pro
  • firemoon-studio/memphis-style - Memphis style image generation

You can browse all available models on the Firemoon Studio Models page.

Parameters

Size

You can specify the image size using the size parameter:

const result = await generateImage({
  model: firemoon.image('flux/dev'),
  prompt: 'A beautiful landscape with an orangered moon in the background',
  size: 'square_hd', // or 'landscape_16_9', etc.
});

Or use aspect ratio mapping:

const result = await generateImage({
  model: firemoon.image('flux/dev'),
  prompt: 'A beautiful landscape with an orangered moon in the background',
  aspectRatio: '16:9', // maps to landscape_16_9
});

Seed

For reproducible results, you can specify a seed:

const result = await generateImage({
  model: firemoon.image('flux/dev'),
  prompt: 'A beautiful landscape with an orangered moon in the background',
  seed: 12345,
});

Custom Parameters

You can pass additional parameters specific to Firemoon models:

const result = await generateImage({
  model: firemoon.image('flux/dev'),
  prompt: 'A beautiful landscape with an orangered moon in the background',
  providerOptions: {
    firemoon: {
      // custom parameters
    },
  },
});

Fine-tuned Models

You can use a fine-tuned model by passing the model id to the image() method:

const result = await generateImage({
  model: firemoon.image('firemoon-studio/memphis-style'),
  prompt: 'a man smiling at the camera',
  size: 'landscape_16_9',
  providerOptions: {
    firemoon: {
      lora_scale: 0.6,
      num_images: 1,
      image_size: 'landscape_4_3',
      output_format: 'jpeg',
      guidance_scale: 3.5,
      num_inference_steps: 28,
      enable_safety_checker: true,
    },
  },
});

Quickstart Examples

generateImage

import { createFiremoon } from '@firemoon/ai-provider';
import { generateImage } from 'ai';

const firemoon = createFiremoon({
  apiKey: process.env.FIREMOON_API_KEY,
});

const result = await generateImage({
  model: firemoon.image('flux/dev'),
  prompt: 'A beautiful landscape with an orangered moon in the background',
  aspectRatio: '16:9',
});

console.log(result.images[0]);

Advanced features

  1. Aspect ratio mapping: Use aspectRatio for convenient presets instead of hard-coding sizes.
  2. Reproducible outputs: Provide seed to make results more repeatable.
  3. Model-specific options: Use providerOptions.firemoon to pass through Firemoon parameters.

Error handling

The Firemoon provider throws APICallError for API-related errors:

import { APICallError } from 'ai';

try {
  const result = await generateImage({
    model: firemoon.image('flux/dev'),
    prompt: 'A beautiful landscape with an orangered moon in the background',
  });
} catch (error) {
  if (error instanceof APICallError) {
    console.error('API Error:', error.message);
    console.error('Status:', error.statusCode);
  }
}

Additional resources