Skip to content

pipe2-ai/sdk-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@pipe2-ai/sdk

Official TypeScript SDK for Pipe2.ai — run AI media pipelines (video generation, image generation, text-to-speech, video reframing) and track their results.

Fully typed, with real-time subscriptions over WebSocket.

Install

npm install @pipe2-ai/sdk
# or: bun add @pipe2-ai/sdk

Authenticate

createClient takes a bearer token — a personal access token from your Pipe2.ai account, or a user JWT.

import { createClient, type Pipe2SDK } from '@pipe2-ai/sdk';

const client = createClient(process.env.PIPE2_TOKEN!);

It defaults to the production endpoint https://api.pipe2.ai/v1/graphql. Pass a second argument to point elsewhere, and a third to override the WebSocket URL used for subscriptions.

Run a pipeline

Pipeline inputs vary per pipeline, so they are passed as JSON. Browse the catalog and each pipeline's inputs at pipe2.ai.

const { run_pipeline } = await client.RunPipeline({
  pipeline_slug: 'video-generator',
  input: { prompt: 'a red fox in falling snow, cinematic' },
});

console.log('run:', run_pipeline?.run_id);

// Runs are asynchronous — fetch the current status by run id, and repeat
// until it reaches a terminal state.
const { pipeline_runs_by_pk } = await client.GetPipelineRun({
  id: run_pipeline!.run_id,
});
console.log('status:', pipeline_runs_by_pk?.status);

Estimate cost before running

Runs are billed in credits. EstimatePipelineCost returns the price for a given pipeline and input without starting anything.

const estimate = await client.EstimatePipelineCost({
  pipeline_slug: 'video-generator',
  input: { prompt: 'a red fox in falling snow' },
});

Browse pipelines

const { pipelines } = await client.GetPipelines();

Related

  • Pipe2.ai — pipeline catalog, pricing, and docs
  • pipe2-cli — agent-native command line tool
  • sdk-go — Go client

License

Apache-2.0

About

Official TypeScript SDK for the Pipe2.ai API — run AI media pipelines (video, image, speech) and track results.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages