npm.io
0.2.1 • Published 13h ago

@martini-film/client

Licence
MIT
Version
0.2.1
Deps
1
Size
24 kB
Vulns
0
Weekly
0

@martini-film/client

The JavaScript and TypeScript client for the Martini Generation API.

npm install --save @martini-film/client
import { createMartiniClient } from '@martini-film/client'

const martini = createMartiniClient({
  apiKey: process.env.MARTINI_API_KEY,
})

const result = await martini.subscribe('nano-banana-2', {
  input: {
    prompt: 'A practical miniature moon base photographed on 35mm film.',
  },
  projectId,
  canvasId,
  placement: 'auto',
  idempotencyKey: 'shot-42',
})

console.log(result.data.images[0].url)
console.log(result.data.olive_cost)

The client provides typed model IDs and an asynchronous queue interface for generation jobs. Submit and status responses include the snapshotted olive_cost once pricing is available, and result responses always include it. An overlapping retry of the same idempotent submission can briefly omit the field while the original request is still being priced. The snapshotted cost does not change if model pricing changes later.

Queue URL fields returned from queue.submit(), queue.status(), and onQueueUpdate use the configured Martini API domain, such as https://api.martini.film/fal/queue/.... The SDK keeps the Fal-compatible proxy details internal.

projectId and canvasId optionally override the API key's default project and canvas and must be supplied together. placement currently accepts auto. Use idempotencyKey to safely retry the same logical submission.

Base64 media inputs

Media URL fields accept public HTTPS URLs, Martini-hosted URLs, or base64 data URLs. Put the data URL directly in the normal field; there is no separate base64 property or upload call.

const result = await martini.subscribe('bytedance/seedance-2.0/reference-to-video', {
  input: {
    prompt: 'Follow the camera movement from @Video1.',
    video_urls: [`data:video/mp4;base64,${videoBase64}`],
  },
})

Limits apply to decoded or fetched media: 10 MB per image, 30 MB per MP4 video reference, and 15 MB per MP3 or WAV reference. The complete request body is limited to 72 MiB. Base64 adds roughly 33% overhead, so use HTTPS URLs for large or multiple references. Binary File and Blob values are not uploaded automatically.

Supported methods:

  • subscribe()
  • queue.submit()
  • queue.status()
  • queue.result()

The API key is a server-side secret. Do not embed it in browser bundles or public environment variables.